diff --git a/lib/DragDropAction.vala b/lib/DragDropAction.vala index 502af08c2..408dac0f2 100644 --- a/lib/DragDropAction.vala +++ b/lib/DragDropAction.vala @@ -187,13 +187,13 @@ namespace Gala { public override bool handle_event (Event event) { if (!(DragDropActionType.SOURCE in drag_type)) { - return Gdk.EVENT_PROPAGATE; + return Clutter.EVENT_PROPAGATE; } switch (event.get_type ()) { case EventType.BUTTON_PRESS: if (grabbed_actor != null) { - return Gdk.EVENT_PROPAGATE; + return Clutter.EVENT_PROPAGATE; } grab_actor (actor, event.get_device ()); @@ -205,7 +205,7 @@ namespace Gala { last_x = x; last_y = y; - return Gdk.EVENT_STOP; + return Clutter.EVENT_STOP; case EventType.BUTTON_RELEASE: if (!dragging) { @@ -223,7 +223,7 @@ namespace Gala { clicked = false; } - return Gdk.EVENT_STOP; + return Clutter.EVENT_STOP; } else if (dragging) { if (hovered != null) { finish (); @@ -231,7 +231,7 @@ namespace Gala { cancel (); } - return Gdk.EVENT_STOP; + return Clutter.EVENT_STOP; } break; @@ -275,7 +275,7 @@ namespace Gala { if (grabbed_device != null && device != grabbed_device && device.get_device_type () != InputDeviceType.KEYBOARD_DEVICE) { - return Gdk.EVENT_PROPAGATE; + return Clutter.EVENT_PROPAGATE; } switch (event.get_type ()) { @@ -295,7 +295,7 @@ namespace Gala { if (handle == null) { ungrab_actor (); critical ("No handle has been returned by the started signal, aborting drag."); - return Gdk.EVENT_PROPAGATE; + return Clutter.EVENT_PROPAGATE; } clicked = false; @@ -317,7 +317,7 @@ namespace Gala { } } } - return Gdk.EVENT_STOP; + return Clutter.EVENT_STOP; } else if (dragging) { handle.x -= last_x - x; handle.y -= last_y - y; @@ -337,7 +337,7 @@ namespace Gala { // didn't change, no need to do anything if (actor == hovered) - return Gdk.EVENT_STOP; + return Clutter.EVENT_STOP; if (action == null) { // apparently we left ours if we had one before @@ -346,7 +346,7 @@ namespace Gala { hovered = null; } - return Gdk.EVENT_STOP; + return Clutter.EVENT_STOP; } // signal the previous one that we left it @@ -358,7 +358,7 @@ namespace Gala { hovered = actor; emit_crossed (hovered, true); - return Gdk.EVENT_STOP; + return Clutter.EVENT_STOP; } break; @@ -366,7 +366,7 @@ namespace Gala { break; } - return Gdk.EVENT_PROPAGATE; + return Clutter.EVENT_PROPAGATE; } /** diff --git a/plugins/pip/PopupWindow.vala b/plugins/pip/PopupWindow.vala index 2a9c48c7f..5a21043ee 100644 --- a/plugins/pip/PopupWindow.vala +++ b/plugins/pip/PopupWindow.vala @@ -55,10 +55,6 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor { || window_type == Meta.WindowType.MODAL_DIALOG; } - private static void get_current_cursor_position (out int x, out int y) { - Gdk.Display.get_default ().get_default_seat ().get_pointer ().get_position (null, out x, out y); - } - public PopupWindow (Gala.WindowManager wm, Meta.WindowActor window_actor) { Object (wm: wm, window_actor: window_actor); } @@ -185,7 +181,7 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor { resize_button.opacity = 255; resize_button.restore_easing_state (); - return Gdk.EVENT_PROPAGATE; + return Clutter.EVENT_PROPAGATE; } public override bool leave_event (Clutter.CrossingEvent event) { @@ -201,7 +197,7 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor { resize_button.opacity = 0; resize_button.restore_easing_state (); - return Gdk.EVENT_PROPAGATE; + return Clutter.EVENT_PROPAGATE; } public void set_container_clip (Graphene.Rect? container_clip) { @@ -222,12 +218,13 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor { private bool on_resize_button_press (Clutter.ButtonEvent event) { if (resizing || event.button != 1) { - return Gdk.EVENT_STOP; + return Clutter.EVENT_STOP; } resizing = true; - get_current_cursor_position (out resize_start_x, out resize_start_y); + resize_start_x = event.x; + resize_start_y = event.y; begin_resize_width = width; begin_resize_height = height; @@ -235,27 +232,25 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor { grab = resize_button.get_stage ().grab (resize_button); resize_button.event.connect (on_resize_event); - return Gdk.EVENT_PROPAGATE; + return Clutter.EVENT_PROPAGATE; } private bool on_resize_event (Clutter.Event event) { if (!resizing) { - return Gdk.EVENT_STOP; + return Clutter.EVENT_STOP; } switch (event.get_type ()) { case Clutter.EventType.MOTION: + unowned var motion_event = (Clutter.MotionEvent) event; var mods = event.get_state (); if (!(Clutter.ModifierType.BUTTON1_MASK in mods)) { stop_resizing (); break; } - int motion_x, motion_y; - get_current_cursor_position (out motion_x, out motion_y); - - float diff_x = motion_x - resize_start_x; - float diff_y = motion_y - resize_start_y; + float diff_x = motion_event.x - resize_start_x; + float diff_y = motion_event.y - resize_start_y; width = begin_resize_width + diff_x; height = begin_resize_height + diff_y; @@ -272,12 +267,12 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor { break; case Clutter.EventType.LEAVE: case Clutter.EventType.ENTER: - return Gdk.EVENT_PROPAGATE; + return Clutter.EVENT_PROPAGATE; default: break; } - return Gdk.EVENT_STOP; + return Clutter.EVENT_STOP; } private void stop_resizing () { diff --git a/src/Background/BackgroundContainer.vala b/src/Background/BackgroundContainer.vala index 65bfd9691..e6f45c008 100644 --- a/src/Background/BackgroundContainer.vala +++ b/src/Background/BackgroundContainer.vala @@ -32,7 +32,7 @@ namespace Gala { reactive = true; button_release_event.connect ((event) => { - if (event.button == Gdk.BUTTON_SECONDARY) { + if (event.button == Clutter.Button.SECONDARY) { show_background_menu ((int)event.x, (int)event.y); } }); diff --git a/src/Gestures/Gesture.vala b/src/Gestures/Gesture.vala index 719172015..9bccedaf7 100644 --- a/src/Gestures/Gesture.vala +++ b/src/Gestures/Gesture.vala @@ -35,9 +35,9 @@ namespace Gala { } public class Gesture { - public Gdk.EventType type; + public Clutter.EventType type; public GestureDirection direction; public int fingers; - public Gdk.InputSource performed_on_device_type; + public Clutter.InputDeviceType performed_on_device_type; } } diff --git a/src/Gestures/GestureSettings.vala b/src/Gestures/GestureSettings.vala index c7a913f9e..894bc0f10 100644 --- a/src/Gestures/GestureSettings.vala +++ b/src/Gestures/GestureSettings.vala @@ -28,8 +28,8 @@ public class Gala.GestureSettings : Object { touchpad_settings = new GLib.Settings ("org.gnome.desktop.peripherals.touchpad"); } - public bool is_natural_scroll_enabled (Gdk.InputSource device_type) { - return (device_type == Gdk.InputSource.TOUCHSCREEN) + public bool is_natural_scroll_enabled (Clutter.InputDeviceType device_type) { + return (device_type == Clutter.InputDeviceType.TOUCHSCREEN_DEVICE) ? true : touchpad_settings.get_boolean ("natural-scroll"); } diff --git a/src/Gestures/ScrollBackend.vala b/src/Gestures/ScrollBackend.vala index dedb2dea2..43cb9e50d 100644 --- a/src/Gestures/ScrollBackend.vala +++ b/src/Gestures/ScrollBackend.vala @@ -65,7 +65,7 @@ public class Gala.ScrollBackend : Object { // Scroll events apply the natural scroll preferences out of the box // Standardize them so the direction matches the physical direction of the gesture and the // GestureTracker user can decide if it wants to follow natural scroll settings or not - bool natural_scroll = settings.is_natural_scroll_enabled (Gdk.InputSource.TOUCHPAD); + bool natural_scroll = settings.is_natural_scroll_enabled (Clutter.InputDeviceType.TOUCHPAD_DEVICE); if (natural_scroll) { x *= -1; y *= -1; @@ -115,10 +115,10 @@ public class Gala.ScrollBackend : Object { } return new Gesture () { - type = Gdk.EventType.SCROLL, + type = Clutter.EventType.SCROLL, direction = direction, fingers = 2, - performed_on_device_type = Gdk.InputSource.TOUCHPAD + performed_on_device_type = Clutter.InputDeviceType.TOUCHPAD_DEVICE }; } diff --git a/src/Gestures/ToucheggBackend.vala b/src/Gestures/ToucheggBackend.vala index cc60b655e..aa4156425 100644 --- a/src/Gestures/ToucheggBackend.vala +++ b/src/Gestures/ToucheggBackend.vala @@ -225,25 +225,25 @@ public class Gala.ToucheggBackend : Object { } private static Gesture? make_gesture (GestureType type, GestureDirection direction, int fingers, DeviceType performed_on_device_type) { - Gdk.EventType event_type; + Clutter.EventType event_type; switch (type) { case GestureType.SWIPE: - event_type = Gdk.EventType.TOUCHPAD_SWIPE; + event_type = Clutter.EventType.TOUCHPAD_SWIPE; break; case GestureType.PINCH: - event_type = Gdk.EventType.TOUCHPAD_PINCH; + event_type = Clutter.EventType.TOUCHPAD_PINCH; break; default: return null; } - Gdk.InputSource input_source; + Clutter.InputDeviceType input_source; switch (performed_on_device_type) { case DeviceType.TOUCHPAD: - input_source = Gdk.InputSource.TOUCHPAD; + input_source = Clutter.InputDeviceType.TOUCHPAD_DEVICE; break; case DeviceType.TOUCHSCREEN: - input_source = Gdk.InputSource.TOUCHSCREEN; + input_source = Clutter.InputDeviceType.TOUCHSCREEN_DEVICE; break; default: return null; diff --git a/src/InternalUtils.vala b/src/InternalUtils.vala index 65ef33b96..2b75902fd 100644 --- a/src/InternalUtils.vala +++ b/src/InternalUtils.vala @@ -134,7 +134,7 @@ namespace Gala { public struct TilableWindow { Meta.Rectangle rect; - void *id; + unowned WindowClone id; } public static List calculate_grid_placement (Meta.Rectangle area, List windows) { diff --git a/src/ScreenshotManager.vala b/src/ScreenshotManager.vala index 61ad1e34a..395c562ed 100644 --- a/src/ScreenshotManager.vala +++ b/src/ScreenshotManager.vala @@ -185,7 +185,11 @@ namespace Gala { } yield wait_stage_repaint (); - selection_area.get_selection_rectangle (out x, out y, out width, out height); + var rect = selection_area.get_selection_rectangle (); + x = (int) GLib.Math.roundf (rect.origin.x); + y = (int) GLib.Math.roundf (rect.origin.y); + width = (int) GLib.Math.roundf (rect.size.width); + height = (int) GLib.Math.roundf (rect.size.height); } private void unconceal_text () { @@ -233,10 +237,13 @@ namespace Gala { throw new GLib.IOError.CANCELLED ("Operation was cancelled"); } - int x = 0, y = 0; - pixel_picker.get_point (out x, out y); - - var image = take_screenshot (x, y, 1, 1, false); + var picker_point = pixel_picker.point; + var image = take_screenshot ( + (int) GLib.Math.roundf (picker_point.x), + (int) GLib.Math.roundf (picker_point.y), + 1, 1, + false + ); assert (image.get_format () == Cairo.Format.ARGB32); diff --git a/src/Widgets/IconGroup.vala b/src/Widgets/IconGroup.vala index 40a48a436..d22d40dab 100644 --- a/src/Widgets/IconGroup.vala +++ b/src/Widgets/IconGroup.vala @@ -100,7 +100,7 @@ namespace Gala { // block propagation of button presses on the close button, otherwise // the click action on the icon group will act weirdly - close_button.button_release_event.connect (() => { return Gdk.EVENT_STOP; }); + close_button.button_release_event.connect (() => { return Clutter.EVENT_STOP; }); add_child (close_button); @@ -116,7 +116,7 @@ namespace Gala { public override bool enter_event (Clutter.CrossingEvent event) { toggle_close_button (true); - return Gdk.EVENT_PROPAGATE; + return Clutter.EVENT_PROPAGATE; } public override bool leave_event (Clutter.CrossingEvent event) { @@ -124,7 +124,7 @@ namespace Gala { toggle_close_button (false); } - return Gdk.EVENT_PROPAGATE; + return Clutter.EVENT_PROPAGATE; } /** diff --git a/src/Widgets/MultitaskingView.vala b/src/Widgets/MultitaskingView.vala index 7243d75be..c217b020c 100644 --- a/src/Widgets/MultitaskingView.vala +++ b/src/Widgets/MultitaskingView.vala @@ -246,7 +246,7 @@ namespace Gala { } private void on_multitasking_gesture_detected (Gesture gesture) { - if (gesture.type != Gdk.EventType.TOUCHPAD_SWIPE || + if (gesture.type != Clutter.EventType.TOUCHPAD_SWIPE || (gesture.fingers == 3 && GestureSettings.get_string ("three-finger-swipe-up") != "multitasking-view") || (gesture.fingers == 4 && GestureSettings.get_string ("four-finger-swipe-up") != "multitasking-view") ) { @@ -265,13 +265,13 @@ namespace Gala { return; } - var can_handle_swipe = gesture.type == Gdk.EventType.TOUCHPAD_SWIPE && + var can_handle_swipe = gesture.type == Clutter.EventType.TOUCHPAD_SWIPE && (gesture.direction == GestureDirection.LEFT || gesture.direction == GestureDirection.RIGHT); var fingers = (gesture.fingers == 3 && Gala.GestureSettings.get_string ("three-finger-swipe-horizontal") == "switch-to-workspace") || (gesture.fingers == 4 && Gala.GestureSettings.get_string ("four-finger-swipe-horizontal") == "switch-to-workspace"); - if (gesture.type == Gdk.EventType.SCROLL || (can_handle_swipe && fingers)) { + if (gesture.type == Clutter.EventType.SCROLL || (can_handle_swipe && fingers)) { var direction = workspace_gesture_tracker.settings.get_natural_scroll_direction (gesture); switch_workspace_with_gesture (direction); } diff --git a/src/Widgets/PixelPicker.vala b/src/Widgets/PixelPicker.vala index 649ee7661..7818b9b97 100644 --- a/src/Widgets/PixelPicker.vala +++ b/src/Widgets/PixelPicker.vala @@ -20,18 +20,17 @@ namespace Gala { public signal void closed (); public WindowManager wm { get; construct; } - public bool cancelled { get; private set; } + public Graphene.Point point { get; private set; } private ModalProxy? modal_proxy; - private Gdk.Point point; public PixelPicker (WindowManager wm) { Object (wm: wm); } construct { - point = { 0, 0 }; + point.init (0, 0); visible = true; reactive = true; @@ -61,8 +60,7 @@ namespace Gala { return true; } - point.x = (int) e.x; - point.y = (int) e.y; + point = Graphene.Point () { x = e.x, y = e.y }; close (); this.hide (); @@ -85,10 +83,5 @@ namespace Gala { modal_proxy = wm.push_modal (this); } - - public void get_point (out int x, out int y) { - x = point.x; - y = point.y; - } } } diff --git a/src/Widgets/SelectionArea.vala b/src/Widgets/SelectionArea.vala index f776c4b73..1b0daa2f1 100644 --- a/src/Widgets/SelectionArea.vala +++ b/src/Widgets/SelectionArea.vala @@ -24,8 +24,8 @@ namespace Gala { public bool cancelled { get; private set; } private ModalProxy? modal_proxy; - private Gdk.Point start_point; - private Gdk.Point end_point; + private Graphene.Point start_point; + private Graphene.Point end_point; private bool dragging = false; private bool clicked = false; @@ -34,8 +34,8 @@ namespace Gala { } construct { - start_point = { 0, 0 }; - end_point = { 0, 0 }; + start_point.init (0, 0); + end_point.init (0, 0); visible = true; reactive = true; @@ -70,8 +70,7 @@ namespace Gala { clicked = true; - start_point.x = (int) e.x; - start_point.y = (int) e.y; + start_point.init (e.x, e.y); return true; } @@ -104,8 +103,7 @@ namespace Gala { return true; } - end_point.x = (int) e.x; - end_point.y = (int) e.y; + end_point.init (e.x, e.y); content.invalidate (); if (!dragging) { @@ -130,11 +128,11 @@ namespace Gala { modal_proxy = wm.push_modal (this); } - public void get_selection_rectangle (out int x, out int y, out int width, out int height) { - x = int.min (start_point.x, end_point.x); - y = int.min (start_point.y, end_point.y); - width = (start_point.x - end_point.x).abs (); - height = (start_point.y - end_point.y).abs (); + public Graphene.Rect get_selection_rectangle () { + return Graphene.Rect () { + origin = start_point, + size = Graphene.Size.zero () + }.expand (end_point); } private bool draw_area (Cairo.Context ctx) { @@ -146,14 +144,12 @@ namespace Gala { ctx.translate (0.5, 0.5); - int x, y, w, h; - get_selection_rectangle (out x, out y, out w, out h); - - ctx.rectangle (x, y, w, h); + var rect = get_selection_rectangle (); + ctx.rectangle (rect.origin.x, rect.origin.y, rect.size.width, rect.size.height); ctx.set_source_rgba (0.1, 0.1, 0.1, 0.2); ctx.fill (); - ctx.rectangle (x, y, w, h); + ctx.rectangle (rect.origin.x, rect.origin.y, rect.size.width, rect.size.height); ctx.set_source_rgb (0.7, 0.7, 0.7); ctx.set_line_width (1.0); ctx.stroke (); diff --git a/src/Widgets/WindowClone.vala b/src/Widgets/WindowClone.vala index 5359787f3..b1944eab9 100644 --- a/src/Widgets/WindowClone.vala +++ b/src/Widgets/WindowClone.vala @@ -120,7 +120,7 @@ public class Gala.WindowClone : Clutter.Actor { close_button = Utils.create_close_button (scale_factor); close_button.opacity = 0; // block propagation of button release event to window clone - close_button.button_release_event.connect (() => { return Gdk.EVENT_STOP; }); + close_button.button_release_event.connect (() => { return Clutter.EVENT_STOP; }); close_button.add_action (close_button_action); var window_frame_rect = window.get_frame_rect (); @@ -433,12 +433,12 @@ public class Gala.WindowClone : Clutter.Actor { } public override bool button_press_event (Clutter.ButtonEvent event) { - return Gdk.EVENT_STOP; + return Clutter.EVENT_STOP; } public override bool enter_event (Clutter.CrossingEvent event) { if (drag_action != null && drag_action.dragging) { - return Gdk.EVENT_PROPAGATE; + return Clutter.EVENT_PROPAGATE; } close_button.save_easing_state (); @@ -453,7 +453,7 @@ public class Gala.WindowClone : Clutter.Actor { window_title.opacity = in_slot_animation ? 0 : 255; window_title.restore_easing_state (); - return Gdk.EVENT_PROPAGATE; + return Clutter.EVENT_PROPAGATE; } public override bool leave_event (Clutter.CrossingEvent event) { @@ -469,7 +469,7 @@ public class Gala.WindowClone : Clutter.Actor { window_title.opacity = 0; window_title.restore_easing_state (); - return Gdk.EVENT_PROPAGATE; + return Clutter.EVENT_PROPAGATE; } /** @@ -560,10 +560,10 @@ public class Gala.WindowClone : Clutter.Actor { private void actor_clicked (uint32 button) { switch (button) { - case Gdk.BUTTON_PRIMARY: + case Clutter.Button.PRIMARY: selected (); break; - case Gdk.BUTTON_MIDDLE: + case Clutter.Button.MIDDLE: close_window (); break; } @@ -839,7 +839,7 @@ public class Gala.WindowClone : Clutter.Actor { private bool draw_background (Cairo.Context cr, int width, int height) { if (!visible || opacity == 0) { - return Gdk.EVENT_PROPAGATE; + return Clutter.EVENT_PROPAGATE; } var color = InternalUtils.get_theme_accent_color (); @@ -853,7 +853,7 @@ public class Gala.WindowClone : Clutter.Actor { cr.set_source_rgba (color.red, color.green, color.blue, COLOR_OPACITY); cr.fill (); - return Gdk.EVENT_PROPAGATE; + return Clutter.EVENT_PROPAGATE; } public override void allocate (Clutter.ActorBox box) { diff --git a/src/Widgets/WindowOverview.vala b/src/Widgets/WindowOverview.vala index d7e2fc5c6..e951ebb8b 100644 --- a/src/Widgets/WindowOverview.vala +++ b/src/Widgets/WindowOverview.vala @@ -30,10 +30,10 @@ public class Gala.WindowOverview : Clutter.Actor, ActivatableComponent { if (event.keyval == Clutter.Key.Escape) { close (); - return Gdk.EVENT_STOP; + return Clutter.EVENT_STOP; } - return Gdk.EVENT_PROPAGATE; + return Clutter.EVENT_PROPAGATE; } public override void key_focus_out () { @@ -43,11 +43,11 @@ public class Gala.WindowOverview : Clutter.Actor, ActivatableComponent { } public override bool button_release_event (Clutter.ButtonEvent event) { - if (event.button == Gdk.BUTTON_PRIMARY) { + if (event.button == Clutter.Button.PRIMARY) { close (); } - return Gdk.EVENT_STOP; + return Clutter.EVENT_STOP; } /** diff --git a/src/Widgets/WindowSwitcher/WindowSwitcher.vala b/src/Widgets/WindowSwitcher/WindowSwitcher.vala index ea8ff3220..bb975588f 100644 --- a/src/Widgets/WindowSwitcher/WindowSwitcher.vala +++ b/src/Widgets/WindowSwitcher/WindowSwitcher.vala @@ -433,7 +433,7 @@ namespace Gala { } private bool container_mouse_release (Clutter.ButtonEvent event) { - if (opened && event.button == Gdk.BUTTON_PRIMARY) { + if (opened && event.button == Clutter.Button.PRIMARY) { close_switcher (event.time); } @@ -455,15 +455,12 @@ namespace Gala { return false; } - private Gdk.ModifierType get_current_modifiers () { - Gdk.ModifierType modifiers; - double[] axes = {}; - Gdk.Display.get_default () - .get_device_manager () - .get_client_pointer () - .get_state (Gdk.get_default_root_window (), axes, out modifiers); - return modifiers; + private inline Clutter.ModifierType get_current_modifiers () { + Clutter.ModifierType modifiers; + wm.get_display ().get_cursor_tracker ().get_pointer (null, out modifiers); + + return modifiers & Clutter.ModifierType.MODIFIER_MASK; } } } diff --git a/src/WindowManager.vala b/src/WindowManager.vala index 233ae7263..eefc9a564 100644 --- a/src/WindowManager.vala +++ b/src/WindowManager.vala @@ -519,7 +519,7 @@ namespace Gala { return; } - var can_handle_swipe = gesture.type == Gdk.EventType.TOUCHPAD_SWIPE && + var can_handle_swipe = gesture.type == Clutter.EventType.TOUCHPAD_SWIPE && (gesture.direction == GestureDirection.LEFT || gesture.direction == GestureDirection.RIGHT); var fingers = (gesture.fingers == 3 && GestureSettings.get_string ("three-finger-swipe-horizontal") == "switch-to-workspace") || @@ -806,11 +806,6 @@ namespace Gala { return (proxy in modal_stack); } - public void get_current_cursor_position (out int x, out int y) { - Gdk.Display.get_default ().get_default_seat ().get_pointer ().get_position (null, - out x, out y); - } - private void dim_parent_window (Meta.Window window, bool dim) { unowned var ancestor = window.find_root_ancestor (); if (ancestor != null && ancestor != window) { diff --git a/src/Zoom.vala b/src/Zoom.vala index 1364f716c..5739d5533 100644 --- a/src/Zoom.vala +++ b/src/Zoom.vala @@ -23,7 +23,7 @@ public class Gala.Zoom : Object { public Zoom (WindowManager wm) { Object (wm: wm); - var display = wm.get_display (); + unowned var display = wm.get_display (); var schema = new GLib.Settings (Config.SCHEMA + ".keybindings"); display.add_keybinding ("zoom-in", schema, Meta.KeyBindingFlags.NONE, (Meta.KeyHandlerFunc) zoom_in); @@ -39,7 +39,7 @@ public class Gala.Zoom : Object { return; } - var display = wm.get_display (); + unowned var display = wm.get_display (); display.remove_keybinding ("zoom-in"); display.remove_keybinding ("zoom-out"); @@ -62,7 +62,7 @@ public class Gala.Zoom : Object { } private void on_gesture_detected (Gesture gesture) { - if (gesture.type != Gdk.EventType.TOUCHPAD_PINCH || + if (gesture.type != Clutter.EventType.TOUCHPAD_PINCH || (gesture.direction != GestureDirection.IN && gesture.direction != GestureDirection.OUT) ) { return; @@ -99,6 +99,18 @@ public class Gala.Zoom : Object { gesture_tracker.connect_handlers (null, (owned) on_animation_update, null); } + private inline Graphene.Point compute_new_pivot_point () { + unowned var wins = wm.ui_group; + Graphene.Point coords; + wm.get_display ().get_cursor_tracker ().get_pointer (out coords, null); + var new_pivot = Graphene.Point () { + x = coords.x / wins.width, + y = coords.y / wins.height + }; + + return new_pivot; + } + private void zoom (float delta, bool play_sound, bool animate) { // Nothing to do if zooming out of our bounds is requested if ((current_zoom <= MIN_ZOOM && delta < 0) || (current_zoom >= MAX_ZOOM && delta >= 0)) { @@ -108,21 +120,14 @@ public class Gala.Zoom : Object { return; } - var wins = wm.ui_group; - + unowned var wins = wm.ui_group; // Add timer to poll current mouse position to reposition window-group // to show requested zoomed area if (mouse_poll_timer == 0) { - float mx, my; - var client_pointer = Gdk.Display.get_default ().get_default_seat ().get_pointer (); - client_pointer.get_position (null, out mx, out my); - wins.set_pivot_point (mx / wins.width, my / wins.height); + wins.pivot_point = compute_new_pivot_point (); mouse_poll_timer = Timeout.add (MOUSE_POLL_TIME, () => { - client_pointer.get_position (null, out mx, out my); - var new_pivot = Graphene.Point (); - - new_pivot.init (mx / wins.width, my / wins.height); + var new_pivot = compute_new_pivot_point (); if (wins.pivot_point.equal (new_pivot)) { return true; } diff --git a/vapi/Clutter-10.metadata b/vapi/Clutter-10.metadata index 516fc6fbb..dde029270 100644 --- a/vapi/Clutter-10.metadata +++ b/vapi/Clutter-10.metadata @@ -189,3 +189,6 @@ BinLayout.new.*_align default=Clutter.BinAlignment.START // Possibly keep KEY_* skip=false name="KEY_(.+)" type="uint" parent="Clutter.Key" +BUTTON_* skip=false name="BUTTON_(.+)" type="uint32" parent="Clutter.Button" +EVENT_STOP skip=false type="bool" +EVENT_PROPAGATE skip=false type="bool" diff --git a/vapi/Clutter-11.metadata b/vapi/Clutter-11.metadata index f53957872..8195fee1a 100644 --- a/vapi/Clutter-11.metadata +++ b/vapi/Clutter-11.metadata @@ -189,3 +189,6 @@ BinLayout.new.*_align default=Clutter.BinAlignment.START // Possibly keep KEY_* skip=false name="KEY_(.+)" type="uint" parent="Clutter.Key" +BUTTON_* skip=false name="BUTTON_(.+)" type="uint32" parent="Clutter.Button" +EVENT_STOP skip=false type="bool" +EVENT_PROPAGATE skip=false type="bool" diff --git a/vapi/mutter-clutter.vapi b/vapi/mutter-clutter.vapi index 6091b8745..e4fb04915 100644 --- a/vapi/mutter-clutter.vapi +++ b/vapi/mutter-clutter.vapi @@ -2,6 +2,14 @@ [CCode (cprefix = "Clutter", gir_namespace = "Clutter", gir_version = "1.0", lower_case_cprefix = "clutter_")] namespace Clutter { + namespace Button { + [CCode (cheader_filename = "clutter/clutter.h", cname = "CLUTTER_BUTTON_MIDDLE")] + public const uint32 MIDDLE; + [CCode (cheader_filename = "clutter/clutter.h", cname = "CLUTTER_BUTTON_PRIMARY")] + public const uint32 PRIMARY; + [CCode (cheader_filename = "clutter/clutter.h", cname = "CLUTTER_BUTTON_SECONDARY")] + public const uint32 SECONDARY; + } namespace Key { [CCode (cheader_filename = "clutter/clutter.h", cname = "CLUTTER_KEY_0")] public const uint @0; @@ -8334,6 +8342,12 @@ namespace Clutter { [CCode (cheader_filename = "clutter/clutter.h", cname = "CLUTTER_CURRENT_TIME")] [Version (since = "0.4")] public const int CURRENT_TIME; + [CCode (cheader_filename = "clutter/clutter.h", cname = "CLUTTER_EVENT_PROPAGATE")] + [Version (since = "1.10")] + public const bool EVENT_PROPAGATE; + [CCode (cheader_filename = "clutter/clutter.h", cname = "CLUTTER_EVENT_STOP")] + [Version (since = "1.10")] + public const bool EVENT_STOP; [CCode (cheader_filename = "clutter/clutter.h", cname = "CLUTTER_FLAVOUR")] [Version (deprecated = true, deprecated_since = "1.10", since = "0.4")] public const string FLAVOUR;