diff options
Diffstat (limited to 'platform/x11')
-rw-r--r-- | platform/x11/os_x11.cpp | 46 | ||||
-rw-r--r-- | platform/x11/os_x11.h | 1 |
2 files changed, 24 insertions, 23 deletions
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index c210a03688..b59fab7088 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -195,14 +195,13 @@ void OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_au XIDeviceInfo *dev = &info[i]; if (!dev->enabled) continue; - /*if (dev->use != XIMasterPointer) - continue;*/ + if (!(dev->use == XIMasterPointer || dev->use == XIFloatingSlave)) + continue; bool direct_touch = false; for (int j = 0; j < dev->num_classes; j++) { if (dev->classes[j]->type == XITouchClass && ((XITouchClassInfo *)dev->classes[j])->mode == XIDirectTouch) { direct_touch = true; - printf("%d) %d %s\n", i, dev->attachment, dev->name); break; } } @@ -215,7 +214,7 @@ void OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_au XIFreeDeviceInfo(info); if (!touch.devices.size()) { - fprintf(stderr, "No suitable touch device found\n"); + fprintf(stderr, "No touch devices found\n"); } } } @@ -286,6 +285,8 @@ void OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_au RasterizerGLES3::make_current(); + context_gl->set_use_vsync(current_videomode.use_vsync); + #endif visual_server = memnew(VisualServerRaster); @@ -357,7 +358,7 @@ void OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_au // Must be alive after this block static unsigned char mask_data[XIMaskLen(XI_LASTEVENT)] = {}; - touch.event_mask.deviceid = XIAllMasterDevices; + touch.event_mask.deviceid = XIAllDevices; touch.event_mask.mask_len = sizeof(mask_data); touch.event_mask.mask = mask_data; @@ -368,12 +369,14 @@ void OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_au XISelectEvents(x11_display, x11_window, &touch.event_mask, 1); - XIClearMask(touch.event_mask.mask, XI_TouchOwnership); + // Disabled by now since grabbing also blocks mouse events + // (they are received as extended events instead of standard events) + /*XIClearMask(touch.event_mask.mask, XI_TouchOwnership); // Grab touch devices to avoid OS gesture interference for (int i = 0; i < touch.devices.size(); ++i) { XIGrabDevice(x11_display, touch.devices[i], x11_window, CurrentTime, None, XIGrabModeAsync, XIGrabModeAsync, False, &touch.event_mask); - } + }*/ } #endif @@ -510,15 +513,14 @@ void OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_au power_manager = memnew(PowerX11); XEvent xevent; - while (XCheckIfEvent(x11_display, &xevent, _check_window_events, NULL)) { - _window_changed(&xevent); + while (XPending(x11_display) > 0) { + XNextEvent(x11_display, &xevent); + if (xevent.type == ConfigureNotify) { + _window_changed(&xevent); + } } } -int OS_X11::_check_window_events(Display *display, XEvent *event, char *arg) { - if (event->type == ConfigureNotify) return 1; - return 0; -} void OS_X11::xim_destroy_callback(::XIM im, ::XPointer client_data, ::XPointer call_data) { @@ -1511,7 +1513,7 @@ void OS_X11::process_xevents() { #ifdef TOUCH_ENABLED if (XGetEventData(x11_display, &event.xcookie)) { - if (event.xcookie.extension == touch.opcode) { + if (event.xcookie.type == GenericEvent && event.xcookie.extension == touch.opcode) { XIDeviceEvent *event_data = (XIDeviceEvent *)event.xcookie.data; int index = event_data->detail; @@ -1520,7 +1522,8 @@ void OS_X11::process_xevents() { switch (event_data->evtype) { case XI_TouchBegin: // Fall-through - XIAllowTouchEvents(x11_display, event_data->deviceid, event_data->detail, x11_window, XIAcceptTouch); + // Disabled hand-in-hand with the grabbing + //XIAllowTouchEvents(x11_display, event_data->deviceid, event_data->detail, x11_window, XIAcceptTouch); case XI_TouchEnd: { @@ -1566,9 +1569,8 @@ void OS_X11::process_xevents() { } break; } } - - XFreeEventData(x11_display, &event.xcookie); } + XFreeEventData(x11_display, &event.xcookie); #endif switch (event.type) { @@ -1614,10 +1616,10 @@ void OS_X11::process_xevents() { GrabModeAsync, GrabModeAsync, x11_window, None, CurrentTime); } #ifdef TOUCH_ENABLED - // Grab touch devices to avoid OS gesture interference - for (int i = 0; i < touch.devices.size(); ++i) { + // Grab touch devices to avoid OS gesture interference + /*for (int i = 0; i < touch.devices.size(); ++i) { XIGrabDevice(x11_display, touch.devices[i], x11_window, CurrentTime, None, XIGrabModeAsync, XIGrabModeAsync, False, &touch.event_mask); - } + }*/ #endif if (xic) { XSetICFocus(xic); @@ -1637,9 +1639,9 @@ void OS_X11::process_xevents() { } #ifdef TOUCH_ENABLED // Ungrab touch devices so input works as usual while we are unfocused - for (int i = 0; i < touch.devices.size(); ++i) { + /*for (int i = 0; i < touch.devices.size(); ++i) { XIUngrabDevice(x11_display, touch.devices[i], CurrentTime); - } + }*/ // Release every pointer to avoid sticky points for (Map<int, Vector2>::Element *E = touch.state.front(); E; E = E->next()) { diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h index 84dff2e089..244c69ee2b 100644 --- a/platform/x11/os_x11.h +++ b/platform/x11/os_x11.h @@ -199,7 +199,6 @@ protected: virtual void set_main_loop(MainLoop *p_main_loop); void _window_changed(XEvent *xevent); - static int _check_window_events(Display *display, XEvent *xevent, char *arg); public: virtual String get_name(); |