diff --git a/js/ui/dnd.js b/js/ui/dnd.js index 77710f5aa..3250620c3 100644 --- a/js/ui/dnd.js +++ b/js/ui/dnd.js @@ -365,7 +365,8 @@ class _Draggable extends Signals.EventEmitter { device = event.get_device(); if (device === undefined) { - let seat = Clutter.get_default_backend().get_default_seat(); + const backend = this.actor.get_context().get_backend(); + const seat = backend.get_default_seat(); device = seat.get_pointer(); } } diff --git a/js/ui/magnifier.js b/js/ui/magnifier.js index cc1c35f97..017451cc3 100644 --- a/js/ui/magnifier.js +++ b/js/ui/magnifier.js @@ -107,6 +107,8 @@ export class Magnifier extends Signals.EventEmitter { this._cursorRoot = new Clutter.Actor(); this._cursorRoot.add_child(this._mouseSprite); + const backend = this._cursorRoot.get_context().get_backend(); + this._seat = backend.get_default_seat(); // Create the first ZoomRegion and initialize it according to the // magnification settings. @@ -130,10 +132,8 @@ export class Magnifier extends Signals.EventEmitter { * Show the system mouse pointer. */ showSystemCursor() { - const seat = Clutter.get_default_backend().get_default_seat(); - if (this._cursorUnfocusInhibited) { - seat.uninhibit_unfocus(); + this._seat.uninhibit_unfocus(); this._cursorUnfocusInhibited = false; } @@ -150,10 +150,8 @@ export class Magnifier extends Signals.EventEmitter { * Hide the system mouse pointer. */ hideSystemCursor() { - const seat = Clutter.get_default_backend().get_default_seat(); - if (!this._cursorUnfocusInhibited) { - seat.inhibit_unfocus(); + this._seat.inhibit_unfocus(); this._cursorUnfocusInhibited = true; } diff --git a/js/ui/padOsd.js b/js/ui/padOsd.js index ac72bc7ec..11e4cf690 100644 --- a/js/ui/padOsd.js +++ b/js/ui/padOsd.js @@ -640,7 +640,8 @@ export const PadOsd = GObject.registerClass({ this._editionMode = editionMode; this._padChooser = null; - let seat = Clutter.get_default_backend().get_default_seat(); + const backend = this.get_context().get_backend(); + const seat = backend.get_default_seat(); seat.connectObject( 'device-added', (_seat, device) => { if (device.get_device_type() === Clutter.InputDeviceType.PAD_DEVICE && diff --git a/js/ui/shellEntry.js b/js/ui/shellEntry.js index 6cb875b90..a69bffa5f 100644 --- a/js/ui/shellEntry.js +++ b/js/ui/shellEntry.js @@ -176,7 +176,8 @@ class CapsLockWarning extends St.Label { this.clutter_text.ellipsize = Pango.EllipsizeMode.NONE; this.clutter_text.line_wrap = true; - let seat = Clutter.get_default_backend().get_default_seat(); + const backend = this.get_context().get_backend(); + const seat = backend.get_default_seat(); this._keymap = seat.get_keymap(); this.connect('notify::mapped', () => { diff --git a/js/ui/status/dwellClick.js b/js/ui/status/dwellClick.js index 79d8e39dd..99c964c24 100644 --- a/js/ui/status/dwellClick.js +++ b/js/ui/status/dwellClick.js @@ -48,7 +48,8 @@ class DwellClickIndicator extends PanelMenu.Button { this._a11ySettings.connect(`changed::${KEY_DWELL_CLICK_ENABLED}`, this._syncMenuVisibility.bind(this)); this._a11ySettings.connect(`changed::${KEY_DWELL_MODE}`, this._syncMenuVisibility.bind(this)); - this._seat = Clutter.get_default_backend().get_default_seat(); + const backend = this.get_context().get_backend(); + this._seat = backend.get_default_seat(); this._seat.connect('ptr-a11y-dwell-click-type-changed', this._updateClickType.bind(this)); this._addDwellAction(DWELL_CLICK_MODES.primary); diff --git a/js/ui/unlockDialog.js b/js/ui/unlockDialog.js index e0437ae5c..f0c8c4df6 100644 --- a/js/ui/unlockDialog.js +++ b/js/ui/unlockDialog.js @@ -347,7 +347,8 @@ class UnlockDialogClock extends St.BoxLayout { this._wallClock = new GnomeDesktop.WallClock({time_only: true}); this._wallClock.connect('notify::clock', this._updateClock.bind(this)); - this._seat = Clutter.get_default_backend().get_default_seat(); + const backend = this.get_context().get_backend(); + this._seat = backend.get_default_seat(); this._seat.connectObject('notify::touch-mode', this._updateHint.bind(this), this); diff --git a/src/shell-invert-lightness-effect.c b/src/shell-invert-lightness-effect.c index ac6081e36..dcc73241b 100644 --- a/src/shell-invert-lightness-effect.c +++ b/src/shell-invert-lightness-effect.c @@ -39,6 +39,8 @@ #include +#include "shell-global.h" + struct _ShellInvertLightnessEffect { ClutterOffscreenEffect parent_instance; @@ -114,8 +116,7 @@ shell_invert_lightness_effect_init (ShellInvertLightnessEffect *self) if (G_UNLIKELY (klass->base_pipeline == NULL)) { CoglSnippet *snippet; - CoglContext *ctx = - clutter_backend_get_cogl_context (clutter_get_default_backend ()); + CoglContext *ctx = clutter_backend_get_cogl_context (clutter_get_default_backend ()); klass->base_pipeline = cogl_pipeline_new (ctx); diff --git a/src/shell-screenshot.c b/src/shell-screenshot.c index f744dd004..c592a4d7c 100644 --- a/src/shell-screenshot.c +++ b/src/shell-screenshot.c @@ -516,8 +516,7 @@ grab_screenshot_content (ShellScreenshot *screenshot, // Copy the texture to prevent it from changing shortly after. width = cogl_texture_get_width (cursor_texture); height = cogl_texture_get_height (cursor_texture); - - ctx = clutter_backend_get_cogl_context (clutter_get_default_backend ()); + ctx = cogl_texture_get_context (cursor_texture); texture = cogl_texture_2d_new_with_size (ctx, width, height); offscreen = cogl_offscreen_new_with_texture (texture); @@ -1266,7 +1265,7 @@ shell_screenshot_composite_to_stream (CoglTexture *texture, height = cogl_texture_get_height (texture); } - ctx = clutter_backend_get_cogl_context (clutter_get_default_backend ()); + ctx = cogl_texture_get_context (texture); sub_texture = cogl_sub_texture_new (ctx, texture, x, y, width, height); surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, diff --git a/src/st/st-drawing-area.c b/src/st/st-drawing-area.c index d947af7ca..197d33e86 100644 --- a/src/st/st-drawing-area.c +++ b/src/st/st-drawing-area.c @@ -203,9 +203,10 @@ st_drawing_area_emit_repaint (StDrawingArea *area) if (priv->buffer == NULL) { - CoglContext *ctx; + ClutterContext *context = clutter_actor_get_context (CLUTTER_ACTOR (area)); + ClutterBackend *backend = clutter_context_get_backend (context); + CoglContext *ctx= clutter_backend_get_cogl_context (backend); - ctx = clutter_backend_get_cogl_context (clutter_get_default_backend ()); priv->buffer = cogl_bitmap_new_with_size (ctx, real_width, real_height, diff --git a/src/st/st-private.c b/src/st/st-private.c index 7e4257d7e..4df1a4504 100644 --- a/src/st/st-private.c +++ b/src/st/st-private.c @@ -223,8 +223,7 @@ _st_create_texture_pipeline (CoglTexture *src_texture) pipeline ancestry instead of resorting to the shader cache. */ if (G_UNLIKELY (texture_pipeline_template == NULL)) { - CoglContext *ctx = - clutter_backend_get_cogl_context (clutter_get_default_backend ()); + CoglContext *ctx = cogl_texture_get_context (src_texture); texture_pipeline_template = cogl_pipeline_new (ctx); cogl_pipeline_set_layer_null_texture (texture_pipeline_template, 0); @@ -384,12 +383,11 @@ _st_create_shadow_pipeline (StShadow *shadow_spec, CoglTexture *src_texture, float resource_scale) { - ClutterBackend *backend = clutter_get_default_backend (); - CoglContext *ctx = clutter_backend_get_cogl_context (backend); g_autoptr (ClutterPaintNode) texture_node = NULL; g_autoptr (ClutterPaintNode) blur_node = NULL; g_autoptr (CoglOffscreen) offscreen = NULL; g_autoptr (GError) error = NULL; + CoglContext *cogl_context; ClutterPaintContext *nested_paint_context; ClutterColorState *color_state; CoglFramebuffer *fb; @@ -413,10 +411,11 @@ _st_create_shadow_pipeline (StShadow *shadow_spec, src_width = cogl_texture_get_width (src_texture); src_height = cogl_texture_get_height (src_texture); + cogl_context = cogl_texture_get_context (src_texture); dst_width = src_width + 2 * sampling_radius; dst_height = src_height + 2 * sampling_radius; - texture = cogl_texture_2d_new_with_size (ctx, dst_width, dst_height); + texture = cogl_texture_2d_new_with_size (cogl_context, dst_width, dst_height); if (!texture) return NULL; @@ -440,7 +439,7 @@ _st_create_shadow_pipeline (StShadow *shadow_spec, }); /* Texture */ - texture_pipeline = cogl_context_get_named_pipeline (ctx, + texture_pipeline = cogl_context_get_named_pipeline (cogl_context, &texture_pipeline_key); if (G_UNLIKELY (texture_pipeline == NULL)) @@ -452,11 +451,11 @@ _st_create_shadow_pipeline (StShadow *shadow_spec, "if (cogl_color_out.a > 0.0)\n" " cogl_color_out.a = 1.0;"); - texture_pipeline = cogl_pipeline_new (ctx); + texture_pipeline = cogl_pipeline_new (cogl_context); cogl_pipeline_add_snippet (texture_pipeline, snippet); g_object_unref (snippet); - cogl_context_set_named_pipeline (ctx, + cogl_context_set_named_pipeline (cogl_context, &texture_pipeline_key, texture_pipeline); } @@ -488,7 +487,7 @@ _st_create_shadow_pipeline (StShadow *shadow_spec, if (G_UNLIKELY (shadow_pipeline_template == NULL)) { - shadow_pipeline_template = cogl_pipeline_new (ctx); + shadow_pipeline_template = cogl_pipeline_new (cogl_context); /* We set up the pipeline to blend the shadow texture with the combine * constant, but defer setting the latter until painting, so that we can @@ -552,13 +551,17 @@ _st_create_shadow_pipeline_from_actor (StShadow *shadow_spec, g_autoptr(CoglTexture) buffer = NULL; CoglOffscreen *offscreen; CoglFramebuffer *fb; - CoglContext *ctx; + ClutterBackend *backend; + ClutterContext *context; + CoglContext *cogl_context; CoglColor clear_color; GError *catch_error = NULL; float x, y; - ctx = clutter_backend_get_cogl_context (clutter_get_default_backend ()); - buffer = cogl_texture_2d_new_with_size (ctx, width, height); + context = clutter_actor_get_context (actor); + backend = clutter_context_get_backend (context); + cogl_context = clutter_backend_get_cogl_context (backend); + buffer = cogl_texture_2d_new_with_size (cogl_context, width, height); if (buffer == NULL) return NULL; diff --git a/src/st/st-widget.c b/src/st/st-widget.c index 812c16f4e..1f793c295 100644 --- a/src/st/st-widget.c +++ b/src/st/st-widget.c @@ -1832,17 +1832,21 @@ st_widget_set_hover (StWidget *widget, void st_widget_sync_hover (StWidget *widget) { + ClutterContext *context; + ClutterBackend *backend; ClutterInputDevice *pointer; ClutterActor *stage; ClutterActor *pointer_actor; ClutterSeat *seat; - seat = clutter_backend_get_default_seat (clutter_get_default_backend ()); - pointer = clutter_seat_get_pointer (seat); stage = clutter_actor_get_stage (CLUTTER_ACTOR (widget)); if (!stage) return; + context = clutter_actor_get_context (CLUTTER_ACTOR (widget)); + backend = clutter_context_get_backend (context); + seat = clutter_backend_get_default_seat (backend); + pointer = clutter_seat_get_pointer (seat); pointer_actor = clutter_stage_get_device_actor (CLUTTER_STAGE (stage), pointer, NULL); if (pointer_actor && clutter_actor_get_reactive (CLUTTER_ACTOR (widget))) st_widget_set_hover (widget, clutter_actor_contains (CLUTTER_ACTOR (widget), pointer_actor));