Repository: kivy/kivy

Issue:
SDL_dropfile doesn't work with elevated permissions
### 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

```python
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](https://gist.github.com/aqiank/efa6eefcc81157982acc)

```C
#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();
}
```
SDL_dropfile doesn't work with elevated permissions
### 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

```python
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](https://gist.github.com/aqiank/efa6eefcc81157982acc)

```C
#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();
}
```


Discussion:
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.
https://blogs.msdn.microsoft.com/patricka/2010/01/28/q-why-doesnt-drag-and-drop-work-when-my-application-is-running-elevated-a-mandatory-integrity-control-and-uipi/. [Maybe](https://helgeklein.com/blog/2010/03/how-to-enable-drag-and-drop-for-an-elevated-mfc-application-on-vistawindows-7/)
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.
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.
https://blogs.msdn.microsoft.com/patricka/2010/01/28/q-why-doesnt-drag-and-drop-work-when-my-application-is-running-elevated-a-mandatory-integrity-control-and-uipi/. [Maybe](https://helgeklein.com/blog/2010/03/how-to-enable-drag-and-drop-for-an-elevated-mfc-application-on-vistawindows-7/)
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.

Resolving patch:
diff --git a/kivy/core/window/__init__.py b/kivy/core/window/__init__.py
--- a/kivy/core/window/__init__.py
+++ b/kivy/core/window/__init__.py
@@ -307,6 +307,12 @@ class WindowBase(EventDispatcher):
         `on_dropfile`: str
             Fired when a file is dropped on the application.
 
+            .. note::
+                This event doesn't work for apps with elevated permissions,
+                because the OS API calls are filtered. Check issue
+                `#4999 <https://github.com/kivy/kivy/issues/4999>`_ for
+                pointers to workarounds.
+
         `on_memorywarning`:
             Fired when the platform have memory issue (iOS / Android mostly)
             You can listen to this one, and clean whatever you can.


Test patch: