diff --git a/notes.org b/notes.org index 355ceac9..d628f7e6 100644 --- a/notes.org +++ b/notes.org @@ -294,3 +294,5 @@ To turn on off without disrupting flow too much use ~GLib.setenv("CLUTTER_SHOW_F ** Focus and active workspace It's not possible the have a focused window which doesn't belong to the active workspace ~global.display.focus_window.workspace === workspaceManger.get_active_workspace()~ +* Clutter animation + ~time: 0~ does not result in an instant animation. A default duration seems to be selected instead. diff --git a/tiling.js b/tiling.js index 8616d85c..7a893b5c 100644 --- a/tiling.js +++ b/tiling.js @@ -2706,16 +2706,7 @@ function grabBegin(metaWindow, type) { case Meta.GrabOp.MOVING: inGrab = new Extension.imports.grab.MoveGrab(metaWindow, type); - let d; - if (Clutter.DeviceManager) { - let dm = Clutter.DeviceManager.get_default(); - d = dm.get_core_device(Clutter.InputDeviceType.KEYBOARD_DEVICE); - } else { - let backend = Clutter.get_default_backend() - let seat = backend.get_default_seat() - d = seat.get_keyboard() - } - if (d.get_modifier_state() & Clutter.ModifierType.CONTROL_MASK) { + if (utils.getModiferState() & Clutter.ModifierType.CONTROL_MASK) { inGrab.begin(); inGrab.beginDnD(); } else if (inGrab.initialSpace && inGrab.initialSpace.indexOf(metaWindow) > -1) { diff --git a/utils.js b/utils.js index bda0eac2..39d80225 100644 --- a/utils.js +++ b/utils.js @@ -80,6 +80,16 @@ function ppEnumValue(value, genum) { } } +function ppModiferState(state) { + let mods = []; + for (let [mod, mask] of Object.entries(imports.gi.Clutter.ModifierType)) { + if (mask & state) { + mods.push(mod); + } + } + return mods.join(", ") +} + /** * Look up the function by name at call time. This makes it convenient to * redefine the function without re-registering all signal handler, keybindings, @@ -264,6 +274,29 @@ function warpPointer(x, y) { } } +/** + * Return current modifiers state (or'ed Clutter.ModifierType.*) + * NB: Only on wayland. (Returns 0 on X11) + * + * Note: It's possible to get the modifier state through Gdk on X11, but move + * grabs is not triggered when ctrl is held down, making it useless for our purpose atm. + */ +function getModiferState() { + if (!Meta.is_wayland_compositor()) + return 0; + + let keyboard; + if (Clutter.DeviceManager) { + let dm = Clutter.DeviceManager.get_default(); + keyboard = dm.get_core_device(Clutter.InputDeviceType.KEYBOARD_DEVICE); + } else { + let backend = Clutter.get_default_backend(); + let seat = backend.get_default_seat(); + keyboard = seat.get_keyboard(); + } + return keyboard.get_modifier_state(); +} + function monitorOfPoint(x, y) { // get_monitor_index_for_rect "helpfully" returns the primary monitor index for out of bounds rects.. const Main = imports.ui.main;