Avoid to use Gdk constants when Clutter should be used (#1596)

This commit is contained in:
Corentin Noël 2023-04-14 10:24:18 +02:00 committed by GitHub
parent c026ad2fda
commit 10e70a8a49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 132 additions and 124 deletions

View File

@ -187,13 +187,13 @@ namespace Gala {
public override bool handle_event (Event event) { public override bool handle_event (Event event) {
if (!(DragDropActionType.SOURCE in drag_type)) { if (!(DragDropActionType.SOURCE in drag_type)) {
return Gdk.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
} }
switch (event.get_type ()) { switch (event.get_type ()) {
case EventType.BUTTON_PRESS: case EventType.BUTTON_PRESS:
if (grabbed_actor != null) { if (grabbed_actor != null) {
return Gdk.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
} }
grab_actor (actor, event.get_device ()); grab_actor (actor, event.get_device ());
@ -205,7 +205,7 @@ namespace Gala {
last_x = x; last_x = x;
last_y = y; last_y = y;
return Gdk.EVENT_STOP; return Clutter.EVENT_STOP;
case EventType.BUTTON_RELEASE: case EventType.BUTTON_RELEASE:
if (!dragging) { if (!dragging) {
@ -223,7 +223,7 @@ namespace Gala {
clicked = false; clicked = false;
} }
return Gdk.EVENT_STOP; return Clutter.EVENT_STOP;
} else if (dragging) { } else if (dragging) {
if (hovered != null) { if (hovered != null) {
finish (); finish ();
@ -231,7 +231,7 @@ namespace Gala {
cancel (); cancel ();
} }
return Gdk.EVENT_STOP; return Clutter.EVENT_STOP;
} }
break; break;
@ -275,7 +275,7 @@ namespace Gala {
if (grabbed_device != null && if (grabbed_device != null &&
device != grabbed_device && device != grabbed_device &&
device.get_device_type () != InputDeviceType.KEYBOARD_DEVICE) { device.get_device_type () != InputDeviceType.KEYBOARD_DEVICE) {
return Gdk.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
} }
switch (event.get_type ()) { switch (event.get_type ()) {
@ -295,7 +295,7 @@ namespace Gala {
if (handle == null) { if (handle == null) {
ungrab_actor (); ungrab_actor ();
critical ("No handle has been returned by the started signal, aborting drag."); critical ("No handle has been returned by the started signal, aborting drag.");
return Gdk.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
} }
clicked = false; clicked = false;
@ -317,7 +317,7 @@ namespace Gala {
} }
} }
} }
return Gdk.EVENT_STOP; return Clutter.EVENT_STOP;
} else if (dragging) { } else if (dragging) {
handle.x -= last_x - x; handle.x -= last_x - x;
handle.y -= last_y - y; handle.y -= last_y - y;
@ -337,7 +337,7 @@ namespace Gala {
// didn't change, no need to do anything // didn't change, no need to do anything
if (actor == hovered) if (actor == hovered)
return Gdk.EVENT_STOP; return Clutter.EVENT_STOP;
if (action == null) { if (action == null) {
// apparently we left ours if we had one before // apparently we left ours if we had one before
@ -346,7 +346,7 @@ namespace Gala {
hovered = null; hovered = null;
} }
return Gdk.EVENT_STOP; return Clutter.EVENT_STOP;
} }
// signal the previous one that we left it // signal the previous one that we left it
@ -358,7 +358,7 @@ namespace Gala {
hovered = actor; hovered = actor;
emit_crossed (hovered, true); emit_crossed (hovered, true);
return Gdk.EVENT_STOP; return Clutter.EVENT_STOP;
} }
break; break;
@ -366,7 +366,7 @@ namespace Gala {
break; break;
} }
return Gdk.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
} }
/** /**

View File

@ -55,10 +55,6 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
|| window_type == Meta.WindowType.MODAL_DIALOG; || 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) { public PopupWindow (Gala.WindowManager wm, Meta.WindowActor window_actor) {
Object (wm: wm, window_actor: 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.opacity = 255;
resize_button.restore_easing_state (); resize_button.restore_easing_state ();
return Gdk.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
} }
public override bool leave_event (Clutter.CrossingEvent event) { 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.opacity = 0;
resize_button.restore_easing_state (); resize_button.restore_easing_state ();
return Gdk.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
} }
public void set_container_clip (Graphene.Rect? container_clip) { 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) { private bool on_resize_button_press (Clutter.ButtonEvent event) {
if (resizing || event.button != 1) { if (resizing || event.button != 1) {
return Gdk.EVENT_STOP; return Clutter.EVENT_STOP;
} }
resizing = true; 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_width = width;
begin_resize_height = height; begin_resize_height = height;
@ -235,27 +232,25 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
grab = resize_button.get_stage ().grab (resize_button); grab = resize_button.get_stage ().grab (resize_button);
resize_button.event.connect (on_resize_event); resize_button.event.connect (on_resize_event);
return Gdk.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
} }
private bool on_resize_event (Clutter.Event event) { private bool on_resize_event (Clutter.Event event) {
if (!resizing) { if (!resizing) {
return Gdk.EVENT_STOP; return Clutter.EVENT_STOP;
} }
switch (event.get_type ()) { switch (event.get_type ()) {
case Clutter.EventType.MOTION: case Clutter.EventType.MOTION:
unowned var motion_event = (Clutter.MotionEvent) event;
var mods = event.get_state (); var mods = event.get_state ();
if (!(Clutter.ModifierType.BUTTON1_MASK in mods)) { if (!(Clutter.ModifierType.BUTTON1_MASK in mods)) {
stop_resizing (); stop_resizing ();
break; break;
} }
int motion_x, motion_y; float diff_x = motion_event.x - resize_start_x;
get_current_cursor_position (out motion_x, out motion_y); float diff_y = motion_event.y - resize_start_y;
float diff_x = motion_x - resize_start_x;
float diff_y = motion_y - resize_start_y;
width = begin_resize_width + diff_x; width = begin_resize_width + diff_x;
height = begin_resize_height + diff_y; height = begin_resize_height + diff_y;
@ -272,12 +267,12 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
break; break;
case Clutter.EventType.LEAVE: case Clutter.EventType.LEAVE:
case Clutter.EventType.ENTER: case Clutter.EventType.ENTER:
return Gdk.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
default: default:
break; break;
} }
return Gdk.EVENT_STOP; return Clutter.EVENT_STOP;
} }
private void stop_resizing () { private void stop_resizing () {

View File

@ -32,7 +32,7 @@ namespace Gala {
reactive = true; reactive = true;
button_release_event.connect ((event) => { 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); show_background_menu ((int)event.x, (int)event.y);
} }
}); });

View File

@ -35,9 +35,9 @@ namespace Gala {
} }
public class Gesture { public class Gesture {
public Gdk.EventType type; public Clutter.EventType type;
public GestureDirection direction; public GestureDirection direction;
public int fingers; public int fingers;
public Gdk.InputSource performed_on_device_type; public Clutter.InputDeviceType performed_on_device_type;
} }
} }

View File

@ -28,8 +28,8 @@ public class Gala.GestureSettings : Object {
touchpad_settings = new GLib.Settings ("org.gnome.desktop.peripherals.touchpad"); touchpad_settings = new GLib.Settings ("org.gnome.desktop.peripherals.touchpad");
} }
public bool is_natural_scroll_enabled (Gdk.InputSource device_type) { public bool is_natural_scroll_enabled (Clutter.InputDeviceType device_type) {
return (device_type == Gdk.InputSource.TOUCHSCREEN) return (device_type == Clutter.InputDeviceType.TOUCHSCREEN_DEVICE)
? true ? true
: touchpad_settings.get_boolean ("natural-scroll"); : touchpad_settings.get_boolean ("natural-scroll");
} }

View File

@ -65,7 +65,7 @@ public class Gala.ScrollBackend : Object {
// Scroll events apply the natural scroll preferences out of the box // 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 // 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 // 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) { if (natural_scroll) {
x *= -1; x *= -1;
y *= -1; y *= -1;
@ -115,10 +115,10 @@ public class Gala.ScrollBackend : Object {
} }
return new Gesture () { return new Gesture () {
type = Gdk.EventType.SCROLL, type = Clutter.EventType.SCROLL,
direction = direction, direction = direction,
fingers = 2, fingers = 2,
performed_on_device_type = Gdk.InputSource.TOUCHPAD performed_on_device_type = Clutter.InputDeviceType.TOUCHPAD_DEVICE
}; };
} }

View File

@ -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) { 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) { switch (type) {
case GestureType.SWIPE: case GestureType.SWIPE:
event_type = Gdk.EventType.TOUCHPAD_SWIPE; event_type = Clutter.EventType.TOUCHPAD_SWIPE;
break; break;
case GestureType.PINCH: case GestureType.PINCH:
event_type = Gdk.EventType.TOUCHPAD_PINCH; event_type = Clutter.EventType.TOUCHPAD_PINCH;
break; break;
default: default:
return null; return null;
} }
Gdk.InputSource input_source; Clutter.InputDeviceType input_source;
switch (performed_on_device_type) { switch (performed_on_device_type) {
case DeviceType.TOUCHPAD: case DeviceType.TOUCHPAD:
input_source = Gdk.InputSource.TOUCHPAD; input_source = Clutter.InputDeviceType.TOUCHPAD_DEVICE;
break; break;
case DeviceType.TOUCHSCREEN: case DeviceType.TOUCHSCREEN:
input_source = Gdk.InputSource.TOUCHSCREEN; input_source = Clutter.InputDeviceType.TOUCHSCREEN_DEVICE;
break; break;
default: default:
return null; return null;

View File

@ -134,7 +134,7 @@ namespace Gala {
public struct TilableWindow { public struct TilableWindow {
Meta.Rectangle rect; Meta.Rectangle rect;
void *id; unowned WindowClone id;
} }
public static List<TilableWindow?> calculate_grid_placement (Meta.Rectangle area, List<TilableWindow?> windows) { public static List<TilableWindow?> calculate_grid_placement (Meta.Rectangle area, List<TilableWindow?> windows) {

View File

@ -185,7 +185,11 @@ namespace Gala {
} }
yield wait_stage_repaint (); 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 () { private void unconceal_text () {
@ -233,10 +237,13 @@ namespace Gala {
throw new GLib.IOError.CANCELLED ("Operation was cancelled"); throw new GLib.IOError.CANCELLED ("Operation was cancelled");
} }
int x = 0, y = 0; var picker_point = pixel_picker.point;
pixel_picker.get_point (out x, out y); var image = take_screenshot (
(int) GLib.Math.roundf (picker_point.x),
var image = take_screenshot (x, y, 1, 1, false); (int) GLib.Math.roundf (picker_point.y),
1, 1,
false
);
assert (image.get_format () == Cairo.Format.ARGB32); assert (image.get_format () == Cairo.Format.ARGB32);

View File

@ -100,7 +100,7 @@ namespace Gala {
// block propagation of button presses on the close button, otherwise // block propagation of button presses on the close button, otherwise
// the click action on the icon group will act weirdly // 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); add_child (close_button);
@ -116,7 +116,7 @@ namespace Gala {
public override bool enter_event (Clutter.CrossingEvent event) { public override bool enter_event (Clutter.CrossingEvent event) {
toggle_close_button (true); toggle_close_button (true);
return Gdk.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
} }
public override bool leave_event (Clutter.CrossingEvent event) { public override bool leave_event (Clutter.CrossingEvent event) {
@ -124,7 +124,7 @@ namespace Gala {
toggle_close_button (false); toggle_close_button (false);
} }
return Gdk.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
} }
/** /**

View File

@ -246,7 +246,7 @@ namespace Gala {
} }
private void on_multitasking_gesture_detected (Gesture gesture) { 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 == 3 && GestureSettings.get_string ("three-finger-swipe-up") != "multitasking-view") ||
(gesture.fingers == 4 && GestureSettings.get_string ("four-finger-swipe-up") != "multitasking-view") (gesture.fingers == 4 && GestureSettings.get_string ("four-finger-swipe-up") != "multitasking-view")
) { ) {
@ -265,13 +265,13 @@ namespace Gala {
return; 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); (gesture.direction == GestureDirection.LEFT || gesture.direction == GestureDirection.RIGHT);
var fingers = (gesture.fingers == 3 && Gala.GestureSettings.get_string ("three-finger-swipe-horizontal") == "switch-to-workspace") || 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"); (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); var direction = workspace_gesture_tracker.settings.get_natural_scroll_direction (gesture);
switch_workspace_with_gesture (direction); switch_workspace_with_gesture (direction);
} }

View File

@ -20,18 +20,17 @@ namespace Gala {
public signal void closed (); public signal void closed ();
public WindowManager wm { get; construct; } public WindowManager wm { get; construct; }
public bool cancelled { get; private set; } public bool cancelled { get; private set; }
public Graphene.Point point { get; private set; }
private ModalProxy? modal_proxy; private ModalProxy? modal_proxy;
private Gdk.Point point;
public PixelPicker (WindowManager wm) { public PixelPicker (WindowManager wm) {
Object (wm: wm); Object (wm: wm);
} }
construct { construct {
point = { 0, 0 }; point.init (0, 0);
visible = true; visible = true;
reactive = true; reactive = true;
@ -61,8 +60,7 @@ namespace Gala {
return true; return true;
} }
point.x = (int) e.x; point = Graphene.Point () { x = e.x, y = e.y };
point.y = (int) e.y;
close (); close ();
this.hide (); this.hide ();
@ -85,10 +83,5 @@ namespace Gala {
modal_proxy = wm.push_modal (this); modal_proxy = wm.push_modal (this);
} }
public void get_point (out int x, out int y) {
x = point.x;
y = point.y;
}
} }
} }

View File

@ -24,8 +24,8 @@ namespace Gala {
public bool cancelled { get; private set; } public bool cancelled { get; private set; }
private ModalProxy? modal_proxy; private ModalProxy? modal_proxy;
private Gdk.Point start_point; private Graphene.Point start_point;
private Gdk.Point end_point; private Graphene.Point end_point;
private bool dragging = false; private bool dragging = false;
private bool clicked = false; private bool clicked = false;
@ -34,8 +34,8 @@ namespace Gala {
} }
construct { construct {
start_point = { 0, 0 }; start_point.init (0, 0);
end_point = { 0, 0 }; end_point.init (0, 0);
visible = true; visible = true;
reactive = true; reactive = true;
@ -70,8 +70,7 @@ namespace Gala {
clicked = true; clicked = true;
start_point.x = (int) e.x; start_point.init (e.x, e.y);
start_point.y = (int) e.y;
return true; return true;
} }
@ -104,8 +103,7 @@ namespace Gala {
return true; return true;
} }
end_point.x = (int) e.x; end_point.init (e.x, e.y);
end_point.y = (int) e.y;
content.invalidate (); content.invalidate ();
if (!dragging) { if (!dragging) {
@ -130,11 +128,11 @@ namespace Gala {
modal_proxy = wm.push_modal (this); modal_proxy = wm.push_modal (this);
} }
public void get_selection_rectangle (out int x, out int y, out int width, out int height) { public Graphene.Rect get_selection_rectangle () {
x = int.min (start_point.x, end_point.x); return Graphene.Rect () {
y = int.min (start_point.y, end_point.y); origin = start_point,
width = (start_point.x - end_point.x).abs (); size = Graphene.Size.zero ()
height = (start_point.y - end_point.y).abs (); }.expand (end_point);
} }
private bool draw_area (Cairo.Context ctx) { private bool draw_area (Cairo.Context ctx) {
@ -146,14 +144,12 @@ namespace Gala {
ctx.translate (0.5, 0.5); ctx.translate (0.5, 0.5);
int x, y, w, h; var rect = get_selection_rectangle ();
get_selection_rectangle (out x, out y, out w, out h); ctx.rectangle (rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
ctx.rectangle (x, y, w, h);
ctx.set_source_rgba (0.1, 0.1, 0.1, 0.2); ctx.set_source_rgba (0.1, 0.1, 0.1, 0.2);
ctx.fill (); 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_source_rgb (0.7, 0.7, 0.7);
ctx.set_line_width (1.0); ctx.set_line_width (1.0);
ctx.stroke (); ctx.stroke ();

View File

@ -120,7 +120,7 @@ public class Gala.WindowClone : Clutter.Actor {
close_button = Utils.create_close_button (scale_factor); close_button = Utils.create_close_button (scale_factor);
close_button.opacity = 0; close_button.opacity = 0;
// block propagation of button release event to window clone // 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); close_button.add_action (close_button_action);
var window_frame_rect = window.get_frame_rect (); 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) { 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) { public override bool enter_event (Clutter.CrossingEvent event) {
if (drag_action != null && drag_action.dragging) { if (drag_action != null && drag_action.dragging) {
return Gdk.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
} }
close_button.save_easing_state (); 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.opacity = in_slot_animation ? 0 : 255;
window_title.restore_easing_state (); window_title.restore_easing_state ();
return Gdk.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
} }
public override bool leave_event (Clutter.CrossingEvent event) { public override bool leave_event (Clutter.CrossingEvent event) {
@ -469,7 +469,7 @@ public class Gala.WindowClone : Clutter.Actor {
window_title.opacity = 0; window_title.opacity = 0;
window_title.restore_easing_state (); 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) { private void actor_clicked (uint32 button) {
switch (button) { switch (button) {
case Gdk.BUTTON_PRIMARY: case Clutter.Button.PRIMARY:
selected (); selected ();
break; break;
case Gdk.BUTTON_MIDDLE: case Clutter.Button.MIDDLE:
close_window (); close_window ();
break; break;
} }
@ -839,7 +839,7 @@ public class Gala.WindowClone : Clutter.Actor {
private bool draw_background (Cairo.Context cr, int width, int height) { private bool draw_background (Cairo.Context cr, int width, int height) {
if (!visible || opacity == 0) { if (!visible || opacity == 0) {
return Gdk.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
} }
var color = InternalUtils.get_theme_accent_color (); 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.set_source_rgba (color.red, color.green, color.blue, COLOR_OPACITY);
cr.fill (); cr.fill ();
return Gdk.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
} }
public override void allocate (Clutter.ActorBox box) { public override void allocate (Clutter.ActorBox box) {

View File

@ -30,10 +30,10 @@ public class Gala.WindowOverview : Clutter.Actor, ActivatableComponent {
if (event.keyval == Clutter.Key.Escape) { if (event.keyval == Clutter.Key.Escape) {
close (); close ();
return Gdk.EVENT_STOP; return Clutter.EVENT_STOP;
} }
return Gdk.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
} }
public override void key_focus_out () { 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) { public override bool button_release_event (Clutter.ButtonEvent event) {
if (event.button == Gdk.BUTTON_PRIMARY) { if (event.button == Clutter.Button.PRIMARY) {
close (); close ();
} }
return Gdk.EVENT_STOP; return Clutter.EVENT_STOP;
} }
/** /**

View File

@ -433,7 +433,7 @@ namespace Gala {
} }
private bool container_mouse_release (Clutter.ButtonEvent event) { 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); close_switcher (event.time);
} }
@ -455,15 +455,12 @@ namespace Gala {
return false; 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;
} }
} }
} }

View File

@ -519,7 +519,7 @@ namespace Gala {
return; 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); (gesture.direction == GestureDirection.LEFT || gesture.direction == GestureDirection.RIGHT);
var fingers = (gesture.fingers == 3 && GestureSettings.get_string ("three-finger-swipe-horizontal") == "switch-to-workspace") || 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); 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) { private void dim_parent_window (Meta.Window window, bool dim) {
unowned var ancestor = window.find_root_ancestor (); unowned var ancestor = window.find_root_ancestor ();
if (ancestor != null && ancestor != window) { if (ancestor != null && ancestor != window) {

View File

@ -23,7 +23,7 @@ public class Gala.Zoom : Object {
public Zoom (WindowManager wm) { public Zoom (WindowManager wm) {
Object (wm: wm); Object (wm: wm);
var display = wm.get_display (); unowned var display = wm.get_display ();
var schema = new GLib.Settings (Config.SCHEMA + ".keybindings"); var schema = new GLib.Settings (Config.SCHEMA + ".keybindings");
display.add_keybinding ("zoom-in", schema, Meta.KeyBindingFlags.NONE, (Meta.KeyHandlerFunc) zoom_in); display.add_keybinding ("zoom-in", schema, Meta.KeyBindingFlags.NONE, (Meta.KeyHandlerFunc) zoom_in);
@ -39,7 +39,7 @@ public class Gala.Zoom : Object {
return; return;
} }
var display = wm.get_display (); unowned var display = wm.get_display ();
display.remove_keybinding ("zoom-in"); display.remove_keybinding ("zoom-in");
display.remove_keybinding ("zoom-out"); display.remove_keybinding ("zoom-out");
@ -62,7 +62,7 @@ public class Gala.Zoom : Object {
} }
private void on_gesture_detected (Gesture gesture) { 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) (gesture.direction != GestureDirection.IN && gesture.direction != GestureDirection.OUT)
) { ) {
return; return;
@ -99,6 +99,18 @@ public class Gala.Zoom : Object {
gesture_tracker.connect_handlers (null, (owned) on_animation_update, null); 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) { private void zoom (float delta, bool play_sound, bool animate) {
// Nothing to do if zooming out of our bounds is requested // Nothing to do if zooming out of our bounds is requested
if ((current_zoom <= MIN_ZOOM && delta < 0) || (current_zoom >= MAX_ZOOM && delta >= 0)) { if ((current_zoom <= MIN_ZOOM && delta < 0) || (current_zoom >= MAX_ZOOM && delta >= 0)) {
@ -108,21 +120,14 @@ public class Gala.Zoom : Object {
return; return;
} }
var wins = wm.ui_group; unowned var wins = wm.ui_group;
// Add timer to poll current mouse position to reposition window-group // Add timer to poll current mouse position to reposition window-group
// to show requested zoomed area // to show requested zoomed area
if (mouse_poll_timer == 0) { if (mouse_poll_timer == 0) {
float mx, my; wins.pivot_point = compute_new_pivot_point ();
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);
mouse_poll_timer = Timeout.add (MOUSE_POLL_TIME, () => { mouse_poll_timer = Timeout.add (MOUSE_POLL_TIME, () => {
client_pointer.get_position (null, out mx, out my); var new_pivot = compute_new_pivot_point ();
var new_pivot = Graphene.Point ();
new_pivot.init (mx / wins.width, my / wins.height);
if (wins.pivot_point.equal (new_pivot)) { if (wins.pivot_point.equal (new_pivot)) {
return true; return true;
} }

View File

@ -189,3 +189,6 @@ BinLayout.new.*_align default=Clutter.BinAlignment.START
// Possibly keep // Possibly keep
KEY_* skip=false name="KEY_(.+)" type="uint" parent="Clutter.Key" 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"

View File

@ -189,3 +189,6 @@ BinLayout.new.*_align default=Clutter.BinAlignment.START
// Possibly keep // Possibly keep
KEY_* skip=false name="KEY_(.+)" type="uint" parent="Clutter.Key" 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"

View File

@ -2,6 +2,14 @@
[CCode (cprefix = "Clutter", gir_namespace = "Clutter", gir_version = "1.0", lower_case_cprefix = "clutter_")] [CCode (cprefix = "Clutter", gir_namespace = "Clutter", gir_version = "1.0", lower_case_cprefix = "clutter_")]
namespace 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 { namespace Key {
[CCode (cheader_filename = "clutter/clutter.h", cname = "CLUTTER_KEY_0")] [CCode (cheader_filename = "clutter/clutter.h", cname = "CLUTTER_KEY_0")]
public const uint @0; public const uint @0;
@ -8334,6 +8342,12 @@ namespace Clutter {
[CCode (cheader_filename = "clutter/clutter.h", cname = "CLUTTER_CURRENT_TIME")] [CCode (cheader_filename = "clutter/clutter.h", cname = "CLUTTER_CURRENT_TIME")]
[Version (since = "0.4")] [Version (since = "0.4")]
public const int CURRENT_TIME; 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")] [CCode (cheader_filename = "clutter/clutter.h", cname = "CLUTTER_FLAVOUR")]
[Version (deprecated = true, deprecated_since = "1.10", since = "0.4")] [Version (deprecated = true, deprecated_since = "1.10", since = "0.4")]
public const string FLAVOUR; public const string FLAVOUR;