Enable events for external X11 windows
Fixes https://github.com/libsdl-org/SDL/issues/3825 Fixes https://github.com/libsdl-org/SDL/issues/5142 Fixes https://github.com/libsdl-org/SDL/issues/9503
This commit is contained in:
@@ -421,6 +421,42 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, Window w)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void SetupWindowInput(SDL_VideoDevice *_this, SDL_Window *window)
|
||||||
|
{
|
||||||
|
long fevent = 0;
|
||||||
|
SDL_WindowData *data = window->internal;
|
||||||
|
Window xwindow = data->xwindow;
|
||||||
|
|
||||||
|
#ifdef X_HAVE_UTF8_STRING
|
||||||
|
if (SDL_X11_HAVE_UTF8 && data->ic) {
|
||||||
|
X11_XGetICValues(data->ic, XNFilterEvents, &fevent, NULL);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
X11_Xinput2SelectTouch(_this, window);
|
||||||
|
|
||||||
|
{
|
||||||
|
unsigned int x11_keyboard_events = KeyPressMask | KeyReleaseMask;
|
||||||
|
unsigned int x11_pointer_events = ButtonPressMask | ButtonReleaseMask | PointerMotionMask;
|
||||||
|
|
||||||
|
X11_Xinput2SelectMouseAndKeyboard(_this, window);
|
||||||
|
|
||||||
|
/* If XInput2 can handle pointer and keyboard events, we don't track them here */
|
||||||
|
if (data->xinput2_keyboard_enabled) {
|
||||||
|
x11_keyboard_events = 0;
|
||||||
|
}
|
||||||
|
if (data->xinput2_mouse_enabled) {
|
||||||
|
x11_pointer_events = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
X11_XSelectInput(data->videodata->display, xwindow,
|
||||||
|
(FocusChangeMask | EnterWindowMask | LeaveWindowMask | ExposureMask |
|
||||||
|
x11_keyboard_events | x11_pointer_events |
|
||||||
|
PropertyChangeMask | StructureNotifyMask |
|
||||||
|
KeymapStateMask | fevent));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void SetWindowBordered(Display *display, int screen, Window window, SDL_bool border)
|
static void SetWindowBordered(Display *display, int screen, Window window, SDL_bool border)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@@ -461,6 +497,8 @@ int X11_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesI
|
|||||||
if (SetupWindowData(_this, window, w) < 0) {
|
if (SetupWindowData(_this, window, w) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetupWindowInput(_this, window);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -486,7 +524,6 @@ int X11_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesI
|
|||||||
const char *wintype_name = NULL;
|
const char *wintype_name = NULL;
|
||||||
long compositor = 1;
|
long compositor = 1;
|
||||||
Atom _NET_WM_PID;
|
Atom _NET_WM_PID;
|
||||||
long fevent = 0;
|
|
||||||
const char *hint = NULL;
|
const char *hint = NULL;
|
||||||
int win_x, win_y;
|
int win_x, win_y;
|
||||||
SDL_bool undefined_position = SDL_FALSE;
|
SDL_bool undefined_position = SDL_FALSE;
|
||||||
@@ -783,12 +820,6 @@ int X11_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesI
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef X_HAVE_UTF8_STRING
|
|
||||||
if (SDL_X11_HAVE_UTF8 && windowdata->ic) {
|
|
||||||
X11_XGetICValues(windowdata->ic, XNFilterEvents, &fevent, NULL);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef SDL_VIDEO_DRIVER_X11_XSHAPE
|
#ifdef SDL_VIDEO_DRIVER_X11_XSHAPE
|
||||||
/* Tooltips do not receive input */
|
/* Tooltips do not receive input */
|
||||||
if (window->flags & SDL_WINDOW_TOOLTIP) {
|
if (window->flags & SDL_WINDOW_TOOLTIP) {
|
||||||
@@ -798,28 +829,7 @@ int X11_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesI
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
X11_Xinput2SelectTouch(_this, window);
|
SetupWindowInput(_this, window);
|
||||||
|
|
||||||
{
|
|
||||||
unsigned int x11_keyboard_events = KeyPressMask | KeyReleaseMask;
|
|
||||||
unsigned int x11_pointer_events = ButtonPressMask | ButtonReleaseMask | PointerMotionMask;
|
|
||||||
|
|
||||||
X11_Xinput2SelectMouseAndKeyboard(_this, window);
|
|
||||||
|
|
||||||
/* If XInput2 can handle pointer and keyboard events, we don't track them here */
|
|
||||||
if (windowdata->xinput2_keyboard_enabled) {
|
|
||||||
x11_keyboard_events = 0;
|
|
||||||
}
|
|
||||||
if (windowdata->xinput2_mouse_enabled) {
|
|
||||||
x11_pointer_events = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
X11_XSelectInput(display, w,
|
|
||||||
(FocusChangeMask | EnterWindowMask | LeaveWindowMask | ExposureMask |
|
|
||||||
x11_keyboard_events | x11_pointer_events |
|
|
||||||
PropertyChangeMask | StructureNotifyMask |
|
|
||||||
KeymapStateMask | fevent));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* For _ICC_PROFILE. */
|
/* For _ICC_PROFILE. */
|
||||||
X11_XSelectInput(display, RootWindow(display, screen), PropertyChangeMask);
|
X11_XSelectInput(display, RootWindow(display, screen), PropertyChangeMask);
|
||||||
|
|||||||
Reference in New Issue
Block a user