diff --git a/src/core/constraints.c b/src/core/constraints.c index a1140d5f5..86a3effe4 100644 --- a/src/core/constraints.c +++ b/src/core/constraints.c @@ -121,6 +121,8 @@ typedef enum typedef struct { + MetaBackend *backend; + MetaRectangle orig; MetaRectangle current; MetaRectangle temporary; @@ -205,7 +207,8 @@ static gboolean constrain_partially_onscreen (MetaWindow *window, ConstraintPriority priority, gboolean check_only); -static void setup_constraint_info (ConstraintInfo *info, +static void setup_constraint_info (MetaBackend *backend, + ConstraintInfo *info, MetaWindow *window, MetaMoveResizeFlags flags, MetaGravity resize_gravity, @@ -291,6 +294,9 @@ meta_window_constrain (MetaWindow *window, int *rel_x, int *rel_y) { + MetaDisplay *display = meta_window_get_display (window); + MetaContext *context = meta_display_get_context (display); + MetaBackend *backend = meta_context_get_backend (context); ConstraintInfo info; ConstraintPriority priority = PRIORITY_MINIMUM; gboolean satisfied = FALSE; @@ -301,7 +307,8 @@ meta_window_constrain (MetaWindow *window, orig->x, orig->y, orig->width, orig->height, new->x, new->y, new->width, new->height); - setup_constraint_info (&info, + setup_constraint_info (backend, + &info, window, flags, resize_gravity, @@ -338,20 +345,21 @@ meta_window_constrain (MetaWindow *window, } static void -setup_constraint_info (ConstraintInfo *info, +setup_constraint_info (MetaBackend *backend, + ConstraintInfo *info, MetaWindow *window, MetaMoveResizeFlags flags, MetaGravity resize_gravity, const MetaRectangle *orig, MetaRectangle *new) { - MetaBackend *backend = meta_get_backend (); MetaMonitorManager *monitor_manager = meta_backend_get_monitor_manager (backend); MetaLogicalMonitor *logical_monitor; MetaWorkspace *cur_workspace; MetaPlacementRule *placement_rule; + info->backend = backend; info->orig = *orig; info->current = *new; info->temporary = *orig; @@ -532,9 +540,8 @@ place_window_if_needed(MetaWindow *window, !window->minimized && !window->fullscreen) { - MetaBackend *backend = meta_get_backend (); MetaMonitorManager *monitor_manager = - meta_backend_get_monitor_manager (backend); + meta_backend_get_monitor_manager (info->backend); MetaRectangle orig_rect; MetaRectangle placed_rect; MetaWorkspace *cur_workspace; @@ -1688,9 +1695,8 @@ constrain_to_single_monitor (MetaWindow *window, ConstraintPriority priority, gboolean check_only) { - MetaBackend *backend = meta_get_backend (); MetaMonitorManager *monitor_manager = - meta_backend_get_monitor_manager (backend); + meta_backend_get_monitor_manager (info->backend); if (priority > PRIORITY_ENTIRELY_VISIBLE_ON_SINGLE_MONITOR) return TRUE; diff --git a/src/core/display.c b/src/core/display.c index 804936781..c5a353369 100644 --- a/src/core/display.c +++ b/src/core/display.c @@ -211,6 +211,24 @@ meta_display_show_osd (MetaDisplay *display, const gchar *icon_name, const gchar *message); +static MetaBackend * +backend_from_display (MetaDisplay *display) +{ + MetaContext *context = meta_display_get_context (display); + + return meta_context_get_backend (context); +} + +#ifdef HAVE_WAYLAND +static MetaWaylandCompositor * +wayland_compositor_from_display (MetaDisplay *display) +{ + MetaContext *context = meta_display_get_context (display); + + return meta_context_get_wayland_compositor (context); +} +#endif + static void meta_display_get_property(GObject *object, guint prop_id, @@ -614,7 +632,7 @@ meta_display_remove_pending_pings_for_window (MetaDisplay *display, static MetaCompositor * create_compositor (MetaDisplay *display) { - MetaBackend *backend = meta_get_backend (); + MetaBackend *backend = backend_from_display (display); #ifdef HAVE_WAYLAND #ifdef HAVE_NATIVE_BACKEND @@ -643,7 +661,7 @@ meta_display_cancel_touch (MetaDisplay *display) if (!meta_is_wayland_compositor ()) return; - compositor = meta_wayland_compositor_get_default (); + compositor = wayland_compositor_from_display (display); meta_wayland_touch_cancel (compositor->seat->touch); #endif } @@ -667,7 +685,7 @@ gesture_tracker_state_changed (MetaGestureTracker *tracker, { MetaBackend *backend; - backend = meta_get_backend (); + backend = backend_from_display (display); meta_backend_finish_touch_sequence (backend, sequence, state); break; } @@ -795,7 +813,7 @@ meta_display_init_x11 (MetaDisplay *display, GAsyncReadyCallback callback, gpointer user_data) { - MetaWaylandCompositor *compositor = meta_wayland_compositor_get_default (); + MetaWaylandCompositor *compositor = wayland_compositor_from_display (display); g_autoptr (GTask) task = NULL; @@ -933,7 +951,7 @@ meta_display_new (MetaContext *context, if (meta_is_wayland_compositor ()) { MetaWaylandCompositor *wayland_compositor = - meta_wayland_compositor_get_default (); + wayland_compositor_from_display (display); MetaX11DisplayPolicy x11_display_policy; meta_wayland_compositor_init_display (wayland_compositor, display); @@ -1277,7 +1295,7 @@ meta_grab_op_is_moving (MetaGrabOp op) gboolean meta_display_windows_are_interactable (MetaDisplay *display) { - MetaBackend *backend = meta_get_backend (); + MetaBackend *backend = backend_from_display (display); MetaStage *stage = META_STAGE (meta_backend_get_stage (backend)); if (clutter_stage_get_grab_actor (CLUTTER_STAGE (stage))) @@ -1427,9 +1445,9 @@ void meta_display_sync_wayland_input_focus (MetaDisplay *display) { #ifdef HAVE_WAYLAND - MetaWaylandCompositor *compositor = meta_wayland_compositor_get_default (); + MetaWaylandCompositor *compositor = wayland_compositor_from_display (display); MetaWindow *focus_window = NULL; - MetaBackend *backend = meta_get_backend (); + MetaBackend *backend = backend_from_display (display); ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend); ClutterSeat *seat = clutter_backend_get_default_seat (clutter_backend); MetaStage *stage = META_STAGE (meta_backend_get_stage (backend)); @@ -1739,7 +1757,7 @@ root_cursor_prepare_at (MetaCursorSpriteXcursor *sprite_xcursor, MetaDisplay *display) { MetaCursorSprite *cursor_sprite = META_CURSOR_SPRITE (sprite_xcursor); - MetaBackend *backend = meta_get_backend (); + MetaBackend *backend = backend_from_display (display); if (meta_backend_is_stage_views_scaled (backend)) { @@ -1787,7 +1805,7 @@ meta_display_reload_cursor (MetaDisplay *display) { MetaCursor cursor = display->current_cursor; MetaCursorSpriteXcursor *sprite_xcursor; - MetaBackend *backend = meta_get_backend (); + MetaBackend *backend = backend_from_display (display); MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend); sprite_xcursor = meta_cursor_sprite_xcursor_new (cursor, cursor_tracker); @@ -1882,7 +1900,7 @@ meta_display_begin_grab_op (MetaDisplay *display, int root_x, int root_y) { - MetaBackend *backend = meta_get_backend (); + MetaBackend *backend = backend_from_display (display); MetaWindow *grab_window = NULL; MetaEventRoute event_route; @@ -1931,7 +1949,8 @@ meta_display_begin_grab_op (MetaDisplay *display, if (pointer_already_grabbed) display->grab_have_pointer = TRUE; - if (META_IS_BACKEND_X11 (meta_get_backend ()) && display->x11_display) + if (META_IS_BACKEND_X11 (backend_from_display (display)) && + display->x11_display) { /* Since grab operations often happen as a result of implicit * pointer operations on the display X11 connection, we need @@ -2046,7 +2065,7 @@ meta_display_end_grab_op (MetaDisplay *display, if (display->grab_have_pointer) { - MetaBackend *backend = meta_get_backend (); + MetaBackend *backend = backend_from_display (display); meta_backend_ungrab_device (backend, META_VIRTUAL_CORE_POINTER_ID, timestamp); } @@ -2896,7 +2915,7 @@ meta_display_get_size (MetaDisplay *display, int *width, int *height) { - MetaBackend *backend = meta_get_backend (); + MetaBackend *backend = backend_from_display (display); MetaMonitorManager *monitor_manager = meta_backend_get_monitor_manager (backend); int display_width, display_height; @@ -3015,7 +3034,7 @@ meta_display_request_pad_osd (MetaDisplay *display, ClutterInputDevice *pad, gboolean edition_mode) { - MetaBackend *backend = meta_get_backend (); + MetaBackend *backend = backend_from_display (display); MetaInputMapper *input_mapper; const gchar *layout_path = NULL; ClutterActor *osd; @@ -3032,7 +3051,7 @@ meta_display_request_pad_osd (MetaDisplay *display, if (display->current_pad_osd) return; - input_mapper = meta_backend_get_input_mapper (meta_get_backend ()); + input_mapper = meta_backend_get_input_mapper (backend_from_display (display)); if (input_mapper) { @@ -3086,7 +3105,7 @@ meta_display_get_pad_action_label (MetaDisplay *display, MetaWaylandTabletSeat *tablet_seat; MetaWaylandTabletPad *tablet_pad = NULL; - compositor = meta_wayland_compositor_get_default (); + compositor = wayland_compositor_from_display (display); tablet_seat = meta_wayland_tablet_manager_ensure_seat (compositor->tablet_manager, compositor->seat); if (tablet_seat) @@ -3124,7 +3143,7 @@ lookup_tablet_monitor (MetaDisplay *display, MetaLogicalMonitor *monitor; gint monitor_idx = -1; - input_mapper = meta_backend_get_input_mapper (meta_get_backend ()); + input_mapper = meta_backend_get_input_mapper (backend_from_display (display)); if (!input_mapper) return -1; @@ -3488,7 +3507,7 @@ static gboolean check_fullscreen_func (gpointer data) { MetaDisplay *display = data; - MetaBackend *backend = meta_get_backend (); + MetaBackend *backend = backend_from_display (display); MetaMonitorManager *monitor_manager = meta_backend_get_monitor_manager (backend); GList *logical_monitors, *l; @@ -3605,7 +3624,7 @@ int meta_display_get_monitor_index_for_rect (MetaDisplay *display, MetaRectangle *rect) { - MetaBackend *backend = meta_get_backend (); + MetaBackend *backend = backend_from_display (display); MetaMonitorManager *monitor_manager = meta_backend_get_monitor_manager (backend); MetaLogicalMonitor *logical_monitor; @@ -3623,7 +3642,7 @@ meta_display_get_monitor_neighbor_index (MetaDisplay *display, int which_monitor, MetaDisplayDirection direction) { - MetaBackend *backend = meta_get_backend (); + MetaBackend *backend = backend_from_display (display); MetaMonitorManager *monitor_manager = meta_backend_get_monitor_manager (backend); MetaLogicalMonitor *logical_monitor; @@ -3649,7 +3668,7 @@ meta_display_get_monitor_neighbor_index (MetaDisplay *display, int meta_display_get_current_monitor (MetaDisplay *display) { - MetaBackend *backend = meta_get_backend (); + MetaBackend *backend = backend_from_display (display); MetaLogicalMonitor *logical_monitor; logical_monitor = meta_backend_get_current_logical_monitor (backend); @@ -3672,7 +3691,7 @@ meta_display_get_current_monitor (MetaDisplay *display) int meta_display_get_n_monitors (MetaDisplay *display) { - MetaBackend *backend = meta_get_backend (); + MetaBackend *backend = backend_from_display (display); MetaMonitorManager *monitor_manager = meta_backend_get_monitor_manager (backend); @@ -3692,7 +3711,7 @@ meta_display_get_n_monitors (MetaDisplay *display) int meta_display_get_primary_monitor (MetaDisplay *display) { - MetaBackend *backend = meta_get_backend (); + MetaBackend *backend = backend_from_display (display); MetaMonitorManager *monitor_manager = meta_backend_get_monitor_manager (backend); MetaLogicalMonitor *logical_monitor; @@ -3720,7 +3739,7 @@ meta_display_get_monitor_geometry (MetaDisplay *display, int monitor, MetaRectangle *geometry) { - MetaBackend *backend = meta_get_backend (); + MetaBackend *backend = backend_from_display (display); MetaMonitorManager *monitor_manager = meta_backend_get_monitor_manager (backend); MetaLogicalMonitor *logical_monitor; @@ -3752,7 +3771,7 @@ float meta_display_get_monitor_scale (MetaDisplay *display, int monitor) { - MetaBackend *backend = meta_get_backend (); + MetaBackend *backend = backend_from_display (display); MetaMonitorManager *monitor_manager = meta_backend_get_monitor_manager (backend); MetaLogicalMonitor *logical_monitor; @@ -3788,7 +3807,7 @@ gboolean meta_display_get_monitor_in_fullscreen (MetaDisplay *display, int monitor) { - MetaBackend *backend = meta_get_backend (); + MetaBackend *backend = backend_from_display (display); MetaMonitorManager *monitor_manager = meta_backend_get_monitor_manager (backend); MetaLogicalMonitor *logical_monitor; diff --git a/src/core/events.c b/src/core/events.c index ecb87a9c2..00dee866a 100644 --- a/src/core/events.c +++ b/src/core/events.c @@ -231,11 +231,12 @@ meta_display_handle_event (MetaDisplay *display, MetaGestureTracker *gesture_tracker; ClutterEventSequence *sequence; gboolean has_grab; +#ifdef HAVE_WAYLAND + MetaWaylandCompositor *wayland_compositor; +#endif #ifdef HAVE_WAYLAND - MetaWaylandCompositor *wayland_compositor = NULL; - if (meta_is_wayland_compositor ()) - wayland_compositor = meta_wayland_compositor_get_default (); + wayland_compositor = meta_context_get_wayland_compositor (context); #endif has_grab = stage_has_grab (display); diff --git a/src/core/keybindings.c b/src/core/keybindings.c index 17c5fe75b..8ff61a94c 100644 --- a/src/core/keybindings.c +++ b/src/core/keybindings.c @@ -1420,6 +1420,10 @@ meta_change_keygrab (MetaKeyBindingManager *keys, gboolean grab, MetaResolvedKeyCombo *resolved_combo) { + MetaBackendX11 *backend_x11; + Display *xdisplay; + GArray *mods; + int i; unsigned char mask_bits[XIMaskLen (XI_LASTEVENT)] = { 0 }; XIEventMask mask = { XIAllMasterDevices, sizeof (mask_bits), mask_bits }; @@ -1429,10 +1433,8 @@ meta_change_keygrab (MetaKeyBindingManager *keys, if (meta_is_wayland_compositor ()) return; - MetaBackendX11 *backend = META_BACKEND_X11 (meta_get_backend ()); - Display *xdisplay = meta_backend_x11_get_xdisplay (backend); - GArray *mods; - int i; + backend_x11 = META_BACKEND_X11 (keys->backend); + xdisplay = meta_backend_x11_get_xdisplay (backend_x11); /* Grab keycode/modmask, together with * all combinations of ignored modifiers. @@ -1753,10 +1755,13 @@ meta_display_ungrab_accelerator (MetaDisplay *display, } static gboolean -grab_keyboard (Window xwindow, - guint32 timestamp, - int grab_mode) +grab_keyboard (MetaBackend *backend, + Window xwindow, + uint32_t timestamp, + int grab_mode) { + MetaBackendX11 *backend_x11; + Display *xdisplay; int grab_status; unsigned char mask_bits[XIMaskLen (XI_LASTEVENT)] = { 0 }; @@ -1772,8 +1777,8 @@ grab_keyboard (Window xwindow, * presses */ - MetaBackendX11 *backend = META_BACKEND_X11 (meta_get_backend ()); - Display *xdisplay = meta_backend_x11_get_xdisplay (backend); + backend_x11 = META_BACKEND_X11 (backend); + xdisplay = meta_backend_x11_get_xdisplay (backend_x11); /* Strictly, we only need to set grab_mode on the keyboard device * while the pointer should always be XIGrabModeAsync. Unfortunately @@ -1797,13 +1802,17 @@ grab_keyboard (Window xwindow, } static void -ungrab_keyboard (guint32 timestamp) +ungrab_keyboard (MetaBackend *backend, + uint32_t timestamp) { + MetaBackendX11 *backend_x11; + Display *xdisplay; + if (meta_is_wayland_compositor ()) return; - MetaBackendX11 *backend = META_BACKEND_X11 (meta_get_backend ()); - Display *xdisplay = meta_backend_x11_get_xdisplay (backend); + backend_x11 = META_BACKEND_X11 (backend); + xdisplay = meta_backend_x11_get_xdisplay (backend_x11); XIUngrabDevice (xdisplay, META_VIRTUAL_CORE_KEYBOARD_ID, timestamp); } @@ -1812,6 +1821,9 @@ gboolean meta_window_grab_all_keys (MetaWindow *window, guint32 timestamp) { + MetaDisplay *display = meta_window_get_display (window); + MetaContext *context = meta_display_get_context (display); + MetaBackend *backend = meta_context_get_backend (context); Window grabwindow; gboolean retval = TRUE; @@ -1835,7 +1847,7 @@ meta_window_grab_all_keys (MetaWindow *window, meta_topic (META_DEBUG_KEYBINDINGS, "Grabbing all keys on window %s", window->desc); - retval = grab_keyboard (grabwindow, timestamp, XIGrabModeAsync); + retval = grab_keyboard (backend, grabwindow, timestamp, XIGrabModeAsync); } if (retval) { @@ -1854,7 +1866,13 @@ meta_window_ungrab_all_keys (MetaWindow *window, if (window->all_keys_grabbed) { if (!meta_is_wayland_compositor()) - ungrab_keyboard (timestamp); + { + MetaDisplay *display = meta_window_get_display (window); + MetaContext *context = meta_display_get_context (display); + MetaBackend *backend = meta_context_get_backend (context); + + ungrab_keyboard (backend, timestamp); + } window->grab_on_frame = FALSE; window->all_keys_grabbed = FALSE; @@ -1868,25 +1886,30 @@ meta_window_ungrab_all_keys (MetaWindow *window, void meta_display_freeze_keyboard (MetaDisplay *display, guint32 timestamp) { - MetaBackend *backend = meta_get_backend (); + MetaContext *context = meta_display_get_context (display); + MetaBackend *backend = meta_context_get_backend (context); if (!META_IS_BACKEND_X11 (backend)) return; Window window = meta_backend_x11_get_xwindow (META_BACKEND_X11 (backend)); - grab_keyboard (window, timestamp, XIGrabModeSync); + grab_keyboard (backend, window, timestamp, XIGrabModeSync); } void meta_display_ungrab_keyboard (MetaDisplay *display, guint32 timestamp) { - ungrab_keyboard (timestamp); + MetaContext *context = meta_display_get_context (display); + MetaBackend *backend = meta_context_get_backend (context); + + ungrab_keyboard (backend, timestamp); } void meta_display_unfreeze_keyboard (MetaDisplay *display, guint32 timestamp) { - MetaBackend *backend = meta_get_backend (); + MetaContext *context = meta_display_get_context (display); + MetaBackend *backend = meta_context_get_backend (context); if (!META_IS_BACKEND_X11 (backend)) return; @@ -2259,7 +2282,9 @@ process_key_event (MetaDisplay *display, } { - MetaBackend *backend = meta_get_backend (); + MetaContext *context = meta_display_get_context (display); + MetaBackend *backend = meta_context_get_backend (context); + if (META_IS_BACKEND_X11 (backend)) { Display *xdisplay = meta_backend_x11_get_xdisplay (META_BACKEND_X11 (backend)); @@ -3473,7 +3498,8 @@ handle_move_to_monitor (MetaDisplay *display, MetaKeyBinding *binding, gpointer dummy) { - MetaBackend *backend = meta_get_backend (); + MetaContext *context = meta_display_get_context (display); + MetaBackend *backend = meta_context_get_backend (context); MetaMonitorManager *monitor_manager = meta_backend_get_monitor_manager (backend); gint which = binding->handler->data; @@ -3594,7 +3620,8 @@ handle_switch_monitor (MetaDisplay *display, MetaKeyBinding *binding, gpointer dummy) { - MetaBackend *backend = meta_get_backend (); + MetaContext *context = meta_display_get_context (display); + MetaBackend *backend = meta_context_get_backend (context); MetaMonitorManager *monitor_manager = meta_backend_get_monitor_manager (backend); MetaMonitorSwitchConfigType config_type = @@ -3614,7 +3641,8 @@ handle_rotate_monitor (MetaDisplay *display, MetaKeyBinding *binding, gpointer dummy) { - MetaBackend *backend = meta_get_backend (); + MetaContext *context = meta_display_get_context (display); + MetaBackend *backend = meta_context_get_backend (context); MetaMonitorManager *monitor_manager = meta_backend_get_monitor_manager (backend); @@ -3949,7 +3977,8 @@ init_builtin_key_bindings (MetaDisplay *display) handle_rotate_monitor, 0); #ifdef HAVE_NATIVE_BACKEND - MetaBackend *backend = meta_get_backend (); + MetaContext *context = meta_display_get_context (display); + MetaBackend *backend = meta_context_get_backend (context); if (META_IS_BACKEND_NATIVE (backend)) { add_builtin_keybinding (display, @@ -4452,7 +4481,8 @@ void meta_display_init_keys (MetaDisplay *display) { MetaKeyBindingManager *keys = &display->key_binding_manager; - MetaBackend *backend = meta_get_backend (); + MetaContext *context = meta_display_get_context (display); + MetaBackend *backend = meta_context_get_backend (context); MetaKeyHandler *handler; keys->backend = backend; diff --git a/src/core/meta-clipboard-manager.c b/src/core/meta-clipboard-manager.c index 794195f41..b84550176 100644 --- a/src/core/meta-clipboard-manager.c +++ b/src/core/meta-clipboard-manager.c @@ -22,6 +22,7 @@ #include "config.h" #include "core/meta-clipboard-manager.h" +#include "core/meta-selection-private.h" #include "meta/meta-selection-source-memory.h" #define MAX_TEXT_SIZE (4 * 1024 * 1024) /* 4MB */ @@ -68,7 +69,7 @@ transfer_cb (MetaSelection *selection, GAsyncResult *result, GOutputStream *output) { - MetaDisplay *display = meta_get_display (); + MetaDisplay *display = meta_selection_get_display (selection); GError *error = NULL; if (!meta_selection_transfer_finish (selection, result, &error)) diff --git a/src/core/meta-context-main.c b/src/core/meta-context-main.c index 5baa7c9f5..8fee10cd5 100644 --- a/src/core/meta-context-main.c +++ b/src/core/meta-context-main.c @@ -343,7 +343,8 @@ static gboolean add_persistent_virtual_monitors (MetaContextMain *context_main, GError **error) { - MetaBackend *backend = meta_get_backend (); + MetaContext *context = META_CONTEXT (context_main); + MetaBackend *backend = meta_context_get_backend (context); MetaMonitorManager *monitor_manager = meta_backend_get_monitor_manager (backend); GList *l; diff --git a/src/core/meta-launch-context.c b/src/core/meta-launch-context.c index cccba79f1..7eaf05e38 100644 --- a/src/core/meta-launch-context.c +++ b/src/core/meta-launch-context.c @@ -176,6 +176,7 @@ meta_launch_context_get_startup_notify_id (GAppLaunchContext *launch_context, sn = meta_display_get_startup_notification (context->display); seq = g_object_new (META_TYPE_STARTUP_SEQUENCE, + "display", context->display, "id", startup_id, "application-id", application_id, "name", g_app_info_get_name (info), diff --git a/src/core/meta-selection-private.h b/src/core/meta-selection-private.h index de9caf9bf..5c04849f7 100644 --- a/src/core/meta-selection-private.h +++ b/src/core/meta-selection-private.h @@ -29,4 +29,6 @@ MetaSelectionSource * meta_selection_get_current_owner (MetaSelection *selection, MetaSelectionType selection_type); +MetaDisplay * meta_selection_get_display (MetaSelection *selection); + #endif /* META_SELECTION_PRIVATE_H */ diff --git a/src/core/meta-selection.c b/src/core/meta-selection.c index 411db4971..849f21240 100644 --- a/src/core/meta-selection.c +++ b/src/core/meta-selection.c @@ -488,3 +488,9 @@ meta_selection_get_current_owner (MetaSelection *selection, return selection->owners[selection_type]; } + +MetaDisplay * +meta_selection_get_display (MetaSelection *selection) +{ + return selection->display; +} diff --git a/src/core/place.c b/src/core/place.c index 1075fe20d..f692214cf 100644 --- a/src/core/place.c +++ b/src/core/place.c @@ -84,7 +84,9 @@ find_next_cascade (MetaWindow *window, int *new_x, int *new_y) { - MetaBackend *backend = meta_get_backend (); + MetaDisplay *display = meta_window_get_display (window); + MetaContext *context = meta_display_get_context (display); + MetaBackend *backend = meta_context_get_backend (context); GList *tmp; GList *sorted; int cascade_x, cascade_y; @@ -665,7 +667,9 @@ meta_window_place (MetaWindow *window, int *new_x, int *new_y) { - MetaBackend *backend = meta_get_backend (); + MetaDisplay *display = meta_window_get_display (window); + MetaContext *context = meta_display_get_context (display); + MetaBackend *backend = meta_context_get_backend (context); GList *windows = NULL; MetaLogicalMonitor *logical_monitor; diff --git a/src/core/stack-tracker.c b/src/core/stack-tracker.c index 9c217a08c..24d5d25db 100644 --- a/src/core/stack-tracker.c +++ b/src/core/stack-tracker.c @@ -584,7 +584,13 @@ void meta_stack_tracker_free (MetaStackTracker *tracker) { if (tracker->sync_stack_later) - meta_later_remove (tracker->sync_stack_later); + { + MetaCompositor *compositor = + meta_display_get_compositor (tracker->display); + MetaLaters *laters = meta_compositor_get_laters (compositor); + + meta_laters_remove (laters, tracker->sync_stack_later); + } g_array_free (tracker->verified_stack, TRUE); if (tracker->predicted_stack) @@ -919,7 +925,10 @@ meta_stack_tracker_sync_stack (MetaStackTracker *tracker) if (tracker->sync_stack_later) { - meta_later_remove (tracker->sync_stack_later); + MetaLaters *laters; + + laters = meta_compositor_get_laters (tracker->display->compositor); + meta_laters_remove (laters, tracker->sync_stack_later); tracker->sync_stack_later = 0; } @@ -987,12 +996,15 @@ stack_tracker_sync_stack_later (gpointer data) void meta_stack_tracker_queue_sync_stack (MetaStackTracker *tracker) { - if (tracker->sync_stack_later == 0) - { - tracker->sync_stack_later = meta_later_add (META_LATER_SYNC_STACK, - stack_tracker_sync_stack_later, - tracker, NULL); - } + MetaLaters *laters; + + if (tracker->sync_stack_later != 0) + return; + + laters = meta_compositor_get_laters (tracker->display->compositor); + tracker->sync_stack_later = meta_laters_add (laters, META_LATER_SYNC_STACK, + stack_tracker_sync_stack_later, + tracker, NULL); } /* When moving an X window we sometimes need an X based sibling. diff --git a/src/core/startup-notification-private.h b/src/core/startup-notification-private.h index 5bdf2ac1a..608ca6852 100644 --- a/src/core/startup-notification-private.h +++ b/src/core/startup-notification-private.h @@ -49,4 +49,6 @@ MetaStartupSequence * meta_startup_notification_lookup_sequence (MetaStartupNotification *sn, const gchar *id); +MetaDisplay * meta_startup_sequence_get_display (MetaStartupSequence *seq); + #endif /* META_STARTUP_NOTIFICATION_PRIVATE_H */ diff --git a/src/core/startup-notification.c b/src/core/startup-notification.c index bf46f43d3..371ec35ff 100644 --- a/src/core/startup-notification.c +++ b/src/core/startup-notification.c @@ -49,6 +49,7 @@ enum enum { PROP_SEQ_0, + PROP_SEQ_DISPLAY, PROP_SEQ_ID, PROP_SEQ_TIMESTAMP, PROP_SEQ_ICON_NAME, @@ -93,7 +94,10 @@ struct _MetaStartupNotification guint startup_sequence_timeout_id; }; -typedef struct { +typedef struct +{ + MetaDisplay *display; + char *wmclass; char *name; char *application_id; @@ -183,6 +187,9 @@ meta_startup_sequence_set_property (GObject *object, switch (prop_id) { + case PROP_SEQ_DISPLAY: + priv->display = g_value_get_object (value); + break; case PROP_SEQ_ID: priv->id = g_value_dup_string (value); break; @@ -224,6 +231,9 @@ meta_startup_sequence_get_property (GObject *object, switch (prop_id) { + case PROP_SEQ_DISPLAY: + g_value_set_object (value, priv->display); + break; case PROP_SEQ_ID: g_value_set_string (value, priv->id); break; @@ -275,6 +285,13 @@ meta_startup_sequence_class_init (MetaStartupSequenceClass *klass) 0, NULL, NULL, NULL, G_TYPE_NONE, 0); + seq_props[PROP_SEQ_DISPLAY] = + g_param_spec_object ("display", + "Display", + "Display", + META_TYPE_DISPLAY, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY); seq_props[PROP_SEQ_ID] = g_param_spec_string ("id", "ID", @@ -455,6 +472,17 @@ meta_startup_sequence_get_wmclass (MetaStartupSequence *seq) return priv->wmclass; } +MetaDisplay * +meta_startup_sequence_get_display (MetaStartupSequence *seq) +{ + MetaStartupSequencePrivate *priv; + + g_return_val_if_fail (META_IS_STARTUP_SEQUENCE (seq), NULL); + + priv = meta_startup_sequence_get_instance_private (seq); + return priv->display; +} + static void on_sequence_completed (MetaStartupSequence *seq, MetaStartupNotification *sn) diff --git a/src/core/window.c b/src/core/window.c index f11ea7351..d046d505c 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -224,6 +224,15 @@ enum static guint window_signals[LAST_SIGNAL] = { 0 }; +static MetaBackend * +backend_from_window (MetaWindow *window) +{ + MetaDisplay *display = meta_window_get_display (window); + MetaContext *context = meta_display_get_context (display); + + return meta_context_get_backend (context); +} + static void prefs_changed_callback (MetaPreference pref, gpointer data) @@ -986,7 +995,7 @@ meta_window_main_monitor_changed (MetaWindow *window, MetaLogicalMonitor * meta_window_find_monitor_from_frame_rect (MetaWindow *window) { - MetaBackend *backend = meta_get_backend (); + MetaBackend *backend = backend_from_window (window); MetaMonitorManager *monitor_manager = meta_backend_get_monitor_manager (backend); MetaRectangle window_rect; @@ -3634,7 +3643,7 @@ static MetaLogicalMonitor * find_monitor_by_winsys_id (MetaWindow *window, uint64_t winsys_id) { - MetaBackend *backend = meta_get_backend (); + MetaBackend *backend = backend_from_window (window); MetaMonitorManager *monitor_manager = meta_backend_get_monitor_manager (backend); GList *logical_monitors, *l; @@ -4626,7 +4635,7 @@ meta_window_focus (MetaWindow *window, } } - backend = meta_get_backend (); + backend = backend_from_window (window); stage = CLUTTER_STAGE (meta_backend_get_stage (backend)); if (window->display->event_route == META_EVENT_ROUTE_NORMAL && @@ -5771,7 +5780,7 @@ update_move_maybe_tile (MetaWindow *window, int x, int y) { - MetaBackend *backend = meta_get_backend (); + MetaBackend *backend = backend_from_window (window); MetaMonitorManager *monitor_manager = meta_backend_get_monitor_manager (backend); MetaLogicalMonitor *logical_monitor; @@ -5927,7 +5936,7 @@ update_move (MetaWindow *window, else if ((window->shaken_loose || META_WINDOW_MAXIMIZED (window)) && window->tile_mode != META_TILE_LEFT && window->tile_mode != META_TILE_RIGHT) { - MetaBackend *backend = meta_get_backend (); + MetaBackend *backend = backend_from_window (window); MetaMonitorManager *monitor_manager = meta_backend_get_monitor_manager (backend); int n_logical_monitors; @@ -6418,7 +6427,7 @@ meta_window_get_work_area_for_monitor (MetaWindow *window, int which_monitor, MetaRectangle *area) { - MetaBackend *backend = meta_get_backend (); + MetaBackend *backend = backend_from_window (window); MetaMonitorManager *monitor_manager = meta_backend_get_monitor_manager (backend); MetaLogicalMonitor *logical_monitor; @@ -8106,7 +8115,7 @@ window_has_pointer_wayland (MetaWindow *window) seat = clutter_backend_get_default_seat (clutter_get_default_backend ()); dev = clutter_seat_get_pointer (seat); - stage = CLUTTER_STAGE (meta_backend_get_stage (meta_get_backend ())); + stage = CLUTTER_STAGE (meta_backend_get_stage (backend_from_window (window))); pointer_actor = clutter_stage_get_device_actor (stage, dev, NULL); window_actor = CLUTTER_ACTOR (meta_window_get_compositor_private (window)); @@ -8151,7 +8160,7 @@ window_focus_on_pointer_rest_callback (gpointer data) MetaFocusData *focus_data = data; MetaWindow *window = focus_data->window; MetaDisplay *display = window->display; - MetaBackend *backend = meta_get_backend (); + MetaBackend *backend = backend_from_window (window); MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend); graphene_point_t point; guint32 timestamp; diff --git a/src/core/workspace.c b/src/core/workspace.c index e933995f3..5e7b325b1 100644 --- a/src/core/workspace.c +++ b/src/core/workspace.c @@ -850,7 +850,8 @@ copy_strut_list(GSList *original) static void ensure_work_areas_validated (MetaWorkspace *workspace) { - MetaBackend *backend = meta_get_backend (); + MetaContext *context = meta_display_get_context (workspace->display); + MetaBackend *backend = meta_context_get_backend (context); MetaMonitorManager *monitor_manager = meta_backend_get_monitor_manager (backend); GList *windows; @@ -1070,7 +1071,8 @@ void meta_workspace_set_builtin_struts (MetaWorkspace *workspace, GSList *struts) { - MetaBackend *backend = meta_get_backend (); + MetaContext *context = meta_display_get_context (workspace->display); + MetaBackend *backend = meta_context_get_backend (context); MetaMonitorManager *monitor_manager = meta_backend_get_monitor_manager (backend); MetaDisplay *display = workspace->display; @@ -1163,7 +1165,8 @@ meta_workspace_get_work_area_for_monitor (MetaWorkspace *workspace, int which_monitor, MetaRectangle *area) { - MetaBackend *backend = meta_get_backend(); + MetaContext *context = meta_display_get_context (workspace->display); + MetaBackend *backend = meta_context_get_backend (context); MetaMonitorManager *monitor_manager = meta_backend_get_monitor_manager (backend); MetaLogicalMonitor *logical_monitor; @@ -1550,7 +1553,8 @@ static MetaWindow * get_pointer_window (MetaWorkspace *workspace, MetaWindow *not_this_one) { - MetaBackend *backend = meta_get_backend (); + MetaContext *context = meta_display_get_context (workspace->display); + MetaBackend *backend = meta_context_get_backend (context); MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend); graphene_point_t point; diff --git a/src/wayland/meta-wayland-activation.c b/src/wayland/meta-wayland-activation.c index 89f7ca221..ae4596bbd 100644 --- a/src/wayland/meta-wayland-activation.c +++ b/src/wayland/meta-wayland-activation.c @@ -56,6 +56,15 @@ struct _MetaXdgActivationToken gboolean committed; }; +static MetaDisplay * +display_from_activation (MetaWaylandActivation *activation) +{ + MetaContext *context = + meta_wayland_compositor_get_context (activation->compositor); + + return meta_context_get_display (context); +} + static void unbind_resource (struct wl_resource *resource) { @@ -104,7 +113,7 @@ sequence_complete_cb (MetaStartupSequence *sequence, MetaXdgActivationToken *token) { MetaWaylandActivation *activation = token->activation; - MetaDisplay *display = meta_get_display (); + MetaDisplay *display = meta_startup_sequence_get_display (sequence); if (!g_hash_table_contains (activation->tokens, token->token)) return; @@ -148,7 +157,7 @@ token_commit (struct wl_client *client, { MetaXdgActivationToken *token = wl_resource_get_user_data (resource); MetaWaylandActivation *activation = token->activation; - MetaDisplay *display = meta_get_display (); + MetaDisplay *display = display_from_activation (activation); uint64_t timestamp; if (token->committed) @@ -164,6 +173,7 @@ token_commit (struct wl_client *client, token->committed = TRUE; token->token = create_startup_token (activation, display); token->sequence = g_object_new (META_TYPE_STARTUP_SEQUENCE, + "display", display, "id", token->token, "application-id", token->app_id, "timestamp", timestamp, @@ -321,7 +331,7 @@ activation_activate (struct wl_client *client, { MetaWaylandActivation *activation = wl_resource_get_user_data (resource); MetaWaylandSurface *surface = wl_resource_get_user_data (surface_resource); - MetaDisplay *display = meta_get_display (); + MetaDisplay *display = display_from_activation (activation); MetaXdgActivationToken *token; MetaStartupSequence *sequence; MetaWindow *window; diff --git a/src/wayland/meta-wayland-gtk-shell.c b/src/wayland/meta-wayland-gtk-shell.c index 5fd1d80cf..b7e891f05 100644 --- a/src/wayland/meta-wayland-gtk-shell.c +++ b/src/wayland/meta-wayland-gtk-shell.c @@ -47,6 +47,8 @@ struct _MetaWaylandGtkShell { GObject parent; + MetaWaylandCompositor *compositor; + GList *shell_resources; uint32_t capabilities; }; @@ -170,7 +172,9 @@ gtk_surface_request_focus (struct wl_client *client, { MetaWaylandGtkSurface *gtk_surface = wl_resource_get_user_data (resource); MetaWaylandSurface *surface = gtk_surface->surface; - MetaDisplay *display = meta_get_display (); + MetaContext *context = + meta_wayland_compositor_get_context (surface->compositor); + MetaDisplay *display = meta_context_get_display (context); MetaStartupSequence *sequence = NULL; MetaWindow *window; @@ -491,10 +495,11 @@ gtk_shell_set_startup_id (struct wl_client *client, struct wl_resource *resource, const char *startup_id) { + MetaWaylandGtkShell *gtk_shell = wl_resource_get_user_data (resource); + MetaContext *context = + meta_wayland_compositor_get_context (gtk_shell->compositor); + MetaDisplay *display = meta_context_get_display (context); MetaStartupSequence *sequence; - MetaDisplay *display; - - display = meta_get_display (); sequence = meta_startup_notification_lookup_sequence (display->startup_notification, startup_id); @@ -548,6 +553,7 @@ gtk_shell_notify_launch (struct wl_client *client, timestamp = meta_display_get_current_time_roundtrip (display); sequence = g_object_new (META_TYPE_STARTUP_SEQUENCE, + "display", display, "id", startup_id, "timestamp", timestamp, NULL); @@ -652,6 +658,7 @@ meta_wayland_gtk_shell_new (MetaWaylandCompositor *compositor) gtk_shell, bind_gtk_shell) == NULL) g_error ("Failed to register a global gtk-shell object"); + gtk_shell->compositor = compositor; gtk_shell->capabilities = calculate_capabilities (); meta_prefs_add_listener (prefs_changed, gtk_shell); diff --git a/src/x11/meta-startup-notification-x11.c b/src/x11/meta-startup-notification-x11.c index f0f1a63ff..27ad8bd0a 100644 --- a/src/x11/meta-startup-notification-x11.c +++ b/src/x11/meta-startup-notification-x11.c @@ -149,12 +149,14 @@ meta_startup_sequence_x11_class_init (MetaStartupSequenceX11Class *klass) } static MetaStartupSequence * -meta_startup_sequence_x11_new (SnStartupSequence *seq) +meta_startup_sequence_x11_new (MetaDisplay *display, + SnStartupSequence *seq) { gint64 timestamp; timestamp = sn_startup_sequence_get_timestamp (seq); return g_object_new (META_TYPE_STARTUP_SEQUENCE_X11, + "display", display, "id", sn_startup_sequence_get_id (seq), "icon-name", sn_startup_sequence_get_icon_name (seq), "application-id", sn_startup_sequence_get_application_id (seq), @@ -193,7 +195,8 @@ meta_startup_notification_sn_event (SnMonitorEvent *event, void *user_data) { MetaX11Display *x11_display = user_data; - MetaStartupNotification *sn = x11_display->display->startup_notification; + MetaDisplay *display = meta_x11_display_get_display (x11_display); + MetaStartupNotification *sn = display->startup_notification; MetaStartupSequence *seq; SnStartupSequence *sequence; @@ -214,7 +217,7 @@ meta_startup_notification_sn_event (SnMonitorEvent *event, sn_startup_sequence_get_id (sequence), wmclass ? wmclass : "(unset)"); - seq = meta_startup_sequence_x11_new (sequence); + seq = meta_startup_sequence_x11_new (display, sequence); meta_startup_notification_add_sequence (sn, seq); g_object_unref (seq); }