MCPcopy Create free account
hub / github.com/GNOME/gnome-shell / _onKeyPressEvent

Method _onKeyPressEvent

js/ui/workspacesView.js:1100–1153  ·  view source on GitHub ↗
(actor, event)

Source from the content-addressed store, hash-verified

1098 }
1099
1100 _onKeyPressEvent(actor, event) {
1101 const {ControlsState} = OverviewControls;
1102 if (this._overviewAdjustment.value !== ControlsState.WINDOW_PICKER)
1103 return Clutter.EVENT_PROPAGATE;
1104
1105 if (!this.reactive)
1106 return Clutter.EVENT_PROPAGATE;
1107
1108 const {workspaceManager} = global;
1109 const vertical = workspaceManager.layout_rows === -1;
1110 const rtl = this.get_text_direction() === Clutter.TextDirection.RTL;
1111
1112 let which;
1113 switch (event.get_key_symbol()) {
1114 case Clutter.KEY_Page_Up:
1115 if (vertical)
1116 which = Meta.MotionDirection.UP;
1117 else if (rtl)
1118 which = Meta.MotionDirection.RIGHT;
1119 else
1120 which = Meta.MotionDirection.LEFT;
1121 break;
1122 case Clutter.KEY_Page_Down:
1123 if (vertical)
1124 which = Meta.MotionDirection.DOWN;
1125 else if (rtl)
1126 which = Meta.MotionDirection.LEFT;
1127 else
1128 which = Meta.MotionDirection.RIGHT;
1129 break;
1130 case Clutter.KEY_Home:
1131 which = 0;
1132 break;
1133 case Clutter.KEY_End:
1134 which = workspaceManager.n_workspaces - 1;
1135 break;
1136 default:
1137 return Clutter.EVENT_PROPAGATE;
1138 }
1139
1140 let ws;
1141 if (which < 0)
1142 // Negative workspace numbers are directions
1143 // with respect to the current workspace
1144 ws = workspaceManager.get_active_workspace().get_neighbor(which);
1145 else
1146 // Otherwise it is a workspace index
1147 ws = workspaceManager.get_workspace_by_index(which);
1148
1149 if (ws)
1150 Main.wm.actionMoveWorkspace(ws);
1151
1152 return Clutter.EVENT_STOP;
1153 }
1154
1155 get _workspacesOnlyOnPrimary() {
1156 return this._settings.get_boolean('workspaces-only-on-primary');

Callers

nothing calls this directly

Calls 1

actionMoveWorkspaceMethod · 0.80

Tested by

no test coverage detected