Skip to content

Commit

Permalink
Fixup Gtk3 Gdk device handling
Browse files Browse the repository at this point in the history
  • Loading branch information
dnk authored and infirit committed Oct 27, 2014
1 parent aaa378f commit e2f29ac
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 8 deletions.
15 changes: 9 additions & 6 deletions src/core/display.c
Expand Up @@ -82,9 +82,10 @@
#include <X11/extensions/Xdamage.h>
#include <X11/extensions/Xfixes.h>
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#endif

#include <gdk/gdkx.h>

#include <string.h>

#define GRAB_OP_IS_WINDOW_SWITCH(g) \
Expand Down Expand Up @@ -1469,15 +1470,17 @@ static gboolean maybe_send_event_to_gtk(MetaDisplay* display, XEvent* xevent)
* (client-side) subwindow for individual menu items.
*/

if (gdk_display_pointer_is_grabbed(gdk_display))
{
return FALSE;
}

#if GTK_CHECK_VERSION (3, 0, 0)
GdkDeviceManager *device_manager = gdk_display_get_device_manager (gdk_display);
GdkDevice *device = gdk_device_manager_get_client_pointer (device_manager);

if (gdk_display_device_is_grabbed(gdk_display, device))
#else
if (gdk_display_pointer_is_grabbed(gdk_display))
#endif
{
return FALSE;
}

switch (xevent->type)
{
Expand Down
10 changes: 10 additions & 0 deletions src/ui/frames.c
Expand Up @@ -2027,7 +2027,12 @@ meta_frames_motion_notify_event (GtkWidget *widget,
MetaFrameControl control;
int x, y;

#if GTK_CHECK_VERSION (3, 0, 0)
gdk_window_get_device_position (frame->window, event->device,
&x, &y, NULL);
#else
gdk_window_get_pointer (frame->window, &x, &y, NULL);
#endif

/* Control is set to none unless it matches
* the current grab
Expand Down Expand Up @@ -2072,7 +2077,12 @@ meta_frames_motion_notify_event (GtkWidget *widget,
MetaFrameControl control;
int x, y;

#if GTK_CHECK_VERSION (3, 0, 0)
gdk_window_get_device_position (frame->window, event->device,
&x, &y, NULL);
#else
gdk_window_get_pointer (frame->window, &x, &y, NULL);
#endif

control = get_control (frames, frame, x, y);

Expand Down
15 changes: 13 additions & 2 deletions src/ui/ui.c
Expand Up @@ -95,6 +95,7 @@ maybe_redirect_mouse_event (XEvent *xevent)
MetaUI *ui;
#if GTK_CHECK_VERSION (3, 0, 0)
GdkDeviceManager *gmanager;
GdkDevice *gdevice;
GdkEvent *gevent;
#else
GdkEvent gevent;
Expand Down Expand Up @@ -132,11 +133,20 @@ maybe_redirect_mouse_event (XEvent *xevent)
if (gdk_window == NULL)
return FALSE;

#if GTK_CHECK_VERSION (3, 0, 0)
gmanager = gdk_display_get_device_manager (gdisplay);
gdevice = gdk_device_manager_get_client_pointer (gmanager);
#endif

/* If GDK already thinks it has a grab, we better let it see events; this
* is the menu-navigation case and events need to get sent to the appropriate
* (client-side) subwindow for individual menu items.
*/
#if GTK_CHECK_VERSION (3, 0, 0)
if (gdk_display_device_is_grabbed (gdisplay, gdevice))
#else
if (gdk_display_pointer_is_grabbed (gdisplay))
#endif
return FALSE;

#if !GTK_CHECK_VERSION (3, 0, 0)
Expand Down Expand Up @@ -245,8 +255,7 @@ maybe_redirect_mouse_event (XEvent *xevent)

/* If we've gotten here, we've filled in the gdk_event and should send it on */
#if GTK_CHECK_VERSION (3, 0, 0)
gmanager = gdk_display_get_device_manager (gdisplay);
gdk_event_set_device (gevent, gdk_device_manager_get_client_pointer (gmanager)); gtk_main_do_event (gevent);
gdk_event_set_device (gevent, gdevice);
gdk_event_free (gevent);
#else
gtk_main_do_event (&gevent);
Expand Down Expand Up @@ -464,6 +473,7 @@ meta_ui_map_frame (MetaUI *ui,
GdkWindow *window;

GdkDisplay *display;

display = gdk_x11_lookup_xdisplay (ui->xdisplay);
window = gdk_x11_window_lookup_for_display (display, xwindow);

Expand All @@ -478,6 +488,7 @@ meta_ui_unmap_frame (MetaUI *ui,
GdkWindow *window;

GdkDisplay *display;

display = gdk_x11_lookup_xdisplay (ui->xdisplay);
window = gdk_x11_window_lookup_for_display (display, xwindow);

Expand Down

0 comments on commit e2f29ac

Please sign in to comment.