Skip to content

Commit a64cefd

Browse files
committed
main.js: In _stageEventHandler, ignore modifier-only key-release
events that occur as part of a keybinding invocation, but allow bare press/releases to propagate. The RunDialog has a key-release-event handler to close the dialog if Super is pressed while it's open. If I have super+/ (for example) bound to the on-screen-keyboard and invoke it, the keyboard appears, but the dialog gets dismissed immediately after I release Super from that invocation. Also, fix the broken dbus handler (broken by 0993e5b).
1 parent de330fe commit a64cefd

2 files changed

Lines changed: 36 additions & 17 deletions

File tree

js/ui/cinnamonDBus.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ var CinnamonDBus = class {
338338
}
339339

340340
ToggleKeyboard() {
341-
Main.screensaverController.toggleKeyboard();
341+
Main.toggleKeyboard();
342342
}
343343

344344
GetMonitors() {

js/ui/main.js

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,6 +1304,11 @@ function _shouldFilterKeybinding(entry) {
13041304
*/
13051305
let _modifierOnlyAction = 0;
13061306

1307+
// Tracks whether a non-modifier key has been pressed since the most recent
1308+
// modifier-key press while in a modal state. Used to tell a bare modifier tap
1309+
// apart from a modifier used as part of a shortcut.
1310+
let _nonModifierPressedSinceModifier = false;
1311+
13071312
function _isModifierKeyval(symbol) {
13081313
return symbol === Clutter.KEY_Super_L || symbol === Clutter.KEY_Super_R ||
13091314
symbol === Clutter.KEY_Control_L || symbol === Clutter.KEY_Control_R ||
@@ -1313,68 +1318,81 @@ function _isModifierKeyval(symbol) {
13131318

13141319
function _stageEventHandler(actor, event) {
13151320
if (modalCount == 0)
1316-
return false;
1321+
return Clutter.EVENT_PROPAGATE;
13171322

13181323
let eventType = event.type();
13191324

13201325
if (eventType !== Clutter.EventType.KEY_PRESS &&
13211326
eventType !== Clutter.EventType.KEY_RELEASE) {
13221327
if (!popup_rendering_actor || eventType !== Clutter.EventType.BUTTON_RELEASE)
1323-
return false;
1324-
return (event.get_source() && popup_rendering_actor.contains(event.get_source()));
1328+
return Clutter.EVENT_PROPAGATE;
1329+
return (event.get_source() && popup_rendering_actor.contains(event.get_source()))
1330+
? Clutter.EVENT_STOP : Clutter.EVENT_PROPAGATE;
13251331
}
13261332

13271333
if (event.get_source() instanceof Clutter.Text &&
13281334
(event.get_flags() & Clutter.EventFlags.INPUT_METHOD)) {
1329-
return false;
1335+
return Clutter.EVENT_PROPAGATE;
13301336
}
13311337

13321338
let keyCode = event.get_key_code();
13331339
let modifierState = Cinnamon.get_event_state(event);
13341340

13351341
if (eventType === Clutter.EventType.KEY_PRESS) {
13361342
if (_isModifierKeyval(event.get_key_symbol())) {
1343+
_nonModifierPressedSinceModifier = false;
13371344
let action = global.display.get_keybinding_action(keyCode, modifierState);
13381345
if (action > 0) {
13391346
let entry = keybindingManager.getBindingById(action);
13401347
if (!_shouldFilterKeybinding(entry)) {
13411348
_modifierOnlyAction = action;
1342-
return true;
1349+
return Clutter.EVENT_STOP;
13431350
}
13441351
}
1345-
return false;
1352+
return Clutter.EVENT_PROPAGATE;
13461353
}
13471354

13481355
_modifierOnlyAction = 0;
1356+
_nonModifierPressedSinceModifier = true;
13491357

13501358
// During modal, muffin's process_iso_next_group doesn't run, handle xkb 'grp'
13511359
// here.
13521360
if (event.get_key_symbol() === Clutter.KEY_ISO_Next_Group) {
13531361
getInputSourceManager()._modifiersSwitcher(false);
1354-
return true;
1362+
return Clutter.EVENT_STOP;
13551363
}
13561364

13571365
let action = global.display.get_keybinding_action(keyCode, modifierState);
13581366
if (action > 0) {
13591367
let entry = keybindingManager.getBindingById(action);
13601368
if (!_shouldFilterKeybinding(entry)) {
13611369
keybindingManager.invoke_keybinding_action_by_id(action);
1362-
return true;
1370+
return Clutter.EVENT_STOP;
13631371
}
13641372
}
13651373

1366-
return false;
1374+
return Clutter.EVENT_PROPAGATE;
13671375
}
13681376

1369-
// Release event - activate the single-key modifier keybinding if one was stored.
1370-
if (_isModifierKeyval(event.get_key_symbol()) && _modifierOnlyAction > 0) {
1371-
let action = _modifierOnlyAction;
1372-
_modifierOnlyAction = 0;
1373-
keybindingManager.invoke_keybinding_action_by_id(action);
1374-
return true;
1377+
// Release event
1378+
if (_isModifierKeyval(event.get_key_symbol())) {
1379+
// Activate the single-key modifier keybinding if one was stored.
1380+
if (_modifierOnlyAction > 0) {
1381+
let action = _modifierOnlyAction;
1382+
_modifierOnlyAction = 0;
1383+
keybindingManager.invoke_keybinding_action_by_id(action);
1384+
return Clutter.EVENT_STOP;
1385+
}
1386+
1387+
// If the modifier was used as part of a shortcut (a non-modifier key was
1388+
// pressed while it was held), consume its release so it isn't mistaken for
1389+
// a bare tap. A clean tap falls through to consumers like the run dialog's
1390+
// key-release-event handler.
1391+
if (_nonModifierPressedSinceModifier)
1392+
return Clutter.EVENT_STOP;
13751393
}
13761394

1377-
return false;
1395+
return Clutter.EVENT_PROPAGATE;
13781396
}
13791397

13801398
function _findModal(actor) {
@@ -1387,6 +1405,7 @@ function _findModal(actor) {
13871405

13881406
function _completeModalSetup(actor, mode, onDismiss) {
13891407
_modifierOnlyAction = 0;
1408+
_nonModifierPressedSinceModifier = false;
13901409

13911410
if (modalCount == 0)
13921411
Meta.disable_unredirect_for_display(global.display);

0 commit comments

Comments
 (0)