Kivy: SDL_dropfile doesn't work with elevated permissions

Created on 18 Feb 2017  路  5Comments  路  Source: kivy/kivy

Versions

  • OS: Windows
  • SDL: 2.0.5

Description

Although this is pretty much SDL2 only issue, we'll need some mention in the docs at least. I can't find any related issue in their bug tracker, so if someone is already registered there, it might be useful to poke them, or check if it's not fixed with their master/trunk branch.

Code and Logs

from kivy.app import runTouchApp
from kivy.core.window import Window

def _drop(window, file_path):
    print(file_path)

Window.bind(on_dropfile=_drop)
runTouchApp()

SDL2 example

#include <SDL2/SDL.h>

int main() {
    SDL_Init(SDL_INIT_EVERYTHING);
    SDL_Window *window = SDL_CreateWindow(
        "Drag-and-Drop",
        SDL_WINDOWPOS_UNDEFINED,
        SDL_WINDOWPOS_UNDEFINED,
        800, 600, SDL_WINDOW_SHOWN
    );

    int running = 1;
    while (running) {
        SDL_Event event;
        while (SDL_PollEvent(&event)) {
            switch (event.type) {
            case SDL_DROPFILE:
                printf("Dropped file: %s\n", event.drop.file);
                break;
            case SDL_QUIT:
                running = 0;
                break;
            }
        }
    }

    SDL_DestroyWindow(window);
    SDL_Quit();
}
upstream

Most helpful comment

We probably should just document the issue and then close it.

All 5 comments

But did you drop the file also from a elevated permission window? To be sure it is there issue ; I would open windows explorer/file browser in elevated permissions too; as I imagine Linux would display the same behavior. I think it is actually an OS thing that generally tries to prevent such context exchanges; with the only exception I believe being the copy and paste buffer.

I believe it's Windows' only thing, but I haven't tested on e.g. Ubuntu, so you're welcome to try sudo python multiple_dropfile.py from examples, or one of the blocks of code above.

Re the elevated permissions, I believe cmd /c explorer launched as admin should be sufficient to get elevated permissions, but even then there's no-go situation and nothing is returned from the event.

So really; this is probably not in Kivy's domain to fix; and in fact is probably outside of SDL's. That is unless we plan to expose a way to change the message passing filter per MIC level on Windows; but I also believe you would have a similar problem on Linux; as they too have begun to have deeper separation of of sudo processes; even though they are run as the same user, but definitely there is a difference between a sudo and non-sudo process. So a fix for Linux would also have to be discovered and likely exposed too; but I think such details should be left to the programmer to implement as needed for their problem domain. That is just my 2 cents though.

We probably should just document the issue and then close it.

Was this page helpful?
0 / 5 - 0 ratings