frames: Clutterify frame event handling

This lets us remove our horrible X11-based, GDK-based hacky frame event
handling in favor of a more sane one in Clutter.
This commit is contained in:
Jasper St. Pierre
2015-01-19 11:27:27 -08:00
parent ce14bde08d
commit d561b3b18f
10 changed files with 105 additions and 326 deletions

View File

@ -85,6 +85,10 @@ typedef enum {
* Events go to windows normally. */
META_EVENT_ROUTE_NORMAL,
/* In a window operation like moving or resizing. All events
* goes to MetaWindow, but not to the actual client window. */
META_EVENT_ROUTE_WINDOW_OP,
/* In a compositor grab operation. All events go to the
* compositor plugin. */
META_EVENT_ROUTE_COMPOSITOR_GRAB,
@ -93,9 +97,8 @@ typedef enum {
* the Wayland application. */
META_EVENT_ROUTE_WAYLAND_POPUP,
/* In a window operation like moving or resizing. All events
* goes to MetaWindow, but not to the actual client window. */
META_EVENT_ROUTE_WINDOW_OP,
/* The user is clicking on a window button. */
META_EVENT_ROUTE_FRAME_BUTTON,
} MetaEventRoute;
typedef gboolean (*MetaAlarmFilter) (MetaDisplay *display,

View File

@ -1802,6 +1802,9 @@ get_event_route_from_grab_op (MetaGrabOp op)
case META_GRAB_OP_WAYLAND_POPUP:
return META_EVENT_ROUTE_WAYLAND_POPUP;
case META_GRAB_OP_FRAME_BUTTON:
return META_EVENT_ROUTE_FRAME_BUTTON;
default:
g_assert_not_reached ();
}

View File

@ -66,9 +66,10 @@ get_window_for_event (MetaDisplay *display,
else
return NULL;
}
case META_EVENT_ROUTE_WAYLAND_POPUP:
case META_EVENT_ROUTE_WINDOW_OP:
case META_EVENT_ROUTE_COMPOSITOR_GRAB:
case META_EVENT_ROUTE_WAYLAND_POPUP:
case META_EVENT_ROUTE_FRAME_BUTTON:
return display->grab_window;
default:
g_assert_not_reached ();
@ -261,7 +262,8 @@ meta_display_handle_event (MetaDisplay *display,
* event, and if it doesn't, replay the event to release our
* own sync grab. */
if (display->event_route == META_EVENT_ROUTE_WINDOW_OP)
if (display->event_route == META_EVENT_ROUTE_WINDOW_OP ||
display->event_route == META_EVENT_ROUTE_FRAME_BUTTON)
{
bypass_clutter = TRUE;
bypass_wayland = TRUE;

View File

@ -106,19 +106,6 @@ meta_window_ensure_frame (MetaWindow *window)
XChangeWindowAttributes (window->display->xdisplay,
frame->xwindow, CWEventMask, &attrs);
{
unsigned char mask_bits[XIMaskLen (XI_LASTEVENT)] = { 0 };
XIEventMask mask = { XIAllMasterDevices, sizeof (mask_bits), mask_bits };
XISetMask (mask.mask, XI_ButtonPress);
XISetMask (mask.mask, XI_ButtonRelease);
XISetMask (mask.mask, XI_Motion);
XISetMask (mask.mask, XI_Enter);
XISetMask (mask.mask, XI_Leave);
XISelectEvents (window->display->xdisplay, frame->xwindow, &mask, 1);
}
meta_display_register_x_window (window->display, &frame->xwindow, window);
meta_error_trap_push (window->display);
@ -158,10 +145,23 @@ meta_window_ensure_frame (MetaWindow *window)
MetaBackend *backend = meta_get_backend ();
if (META_IS_BACKEND_X11 (backend))
{
/* Since the backend takes keygrabs on another connection, make sure
* to sync the GTK+ connection to ensure that the frame window has
* been created on the server at this point. */
Display *xdisplay = meta_backend_x11_get_xdisplay (META_BACKEND_X11 (backend));
/* Since the backend selects for events on another connection,
* make sure to sync the GTK+ connection to ensure that the
* frame window has been created on the server at this point. */
XSync (window->display->xdisplay, False);
unsigned char mask_bits[XIMaskLen (XI_LASTEVENT)] = { 0 };
XIEventMask mask = { XIAllMasterDevices, sizeof (mask_bits), mask_bits };
XISetMask (mask.mask, XI_ButtonPress);
XISetMask (mask.mask, XI_ButtonRelease);
XISetMask (mask.mask, XI_Motion);
XISetMask (mask.mask, XI_Enter);
XISetMask (mask.mask, XI_Leave);
XISelectEvents (xdisplay, frame->xwindow, &mask, 1);
}
}

View File

@ -7773,6 +7773,9 @@ meta_window_handle_ungrabbed_event (MetaWindow *window,
gboolean unmodified;
gboolean is_window_grab;
if (window->frame && meta_ui_frame_handle_event (window->frame->ui_frame, event))
return;
if (event->type != CLUTTER_BUTTON_PRESS)
return;