js: Mass move to Clutter.Event getter methods in Clutter.Actor vfuncs

These traditionally got the various ClutterEvent subtype structs as their
argument, so it was not allowed to use ClutterEvent generic getter methods
in these vfuncs. These methods used direct access to struct fields instead.

This got spoiled with the move to make ClutterEvent opaque types, since
these are no longer public structs so GNOME Shell most silently failed to
fetch the expected values from event fields. But since they are not
ClutterEvents either, the getters could not be used on them.

Mutter is changing so that these vmethods all contain an alias to the
one and only Clutter.Event type, thus lifting those barriers, and making
it possible to use the ClutterEvent methods in these vfuncs.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2950
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2872>
This commit is contained in:
Carlos Garnacho 2023-08-08 18:14:04 +02:00
parent 5e36a06835
commit 8423ba44fe
15 changed files with 114 additions and 107 deletions

View File

@ -133,10 +133,10 @@ export const AuthPrompt = GObject.registerClass({
this._userVerifier = null; this._userVerifier = null;
} }
vfunc_key_press_event(keyPressEvent) { vfunc_key_press_event(event) {
if (keyPressEvent.keyval == Clutter.KEY_Escape) if (event.get_key_symbol() === Clutter.KEY_Escape)
this.cancel(); this.cancel();
return super.vfunc_key_press_event(keyPressEvent); return super.vfunc_key_press_event(event);
} }
_initInputRow() { _initInputRow() {

View File

@ -2805,7 +2805,7 @@ export const AppFolderDialog = GObject.registerClass({
this._zoomAndFadeIn(); this._zoomAndFadeIn();
} }
vfunc_key_press_event(keyEvent) { vfunc_key_press_event(event) {
if (global.stage.get_key_focus() != this) if (global.stage.get_key_focus() != this)
return Clutter.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
@ -2828,7 +2828,7 @@ export const AppFolderDialog = GObject.registerClass({
// languages // languages
let direction; let direction;
let isLtr = Clutter.get_default_text_direction() == Clutter.TextDirection.LTR; let isLtr = Clutter.get_default_text_direction() == Clutter.TextDirection.LTR;
switch (keyEvent.keyval) { switch (event.get_key_symbol()) {
case Clutter.KEY_Down: case Clutter.KEY_Down:
direction = St.DirectionType.TAB_FORWARD; direction = St.DirectionType.TAB_FORWARD;
break; break;
@ -3078,28 +3078,29 @@ export const AppIcon = GObject.registerClass({
GLib.Source.set_name_by_id(this._menuTimeoutId, '[gnome-shell] this.popupMenu'); GLib.Source.set_name_by_id(this._menuTimeoutId, '[gnome-shell] this.popupMenu');
} }
vfunc_leave_event(crossingEvent) { vfunc_leave_event(event) {
const ret = super.vfunc_leave_event(crossingEvent); const ret = super.vfunc_leave_event(event);
this.fake_release(); this.fake_release();
this._removeMenuTimeout(); this._removeMenuTimeout();
return ret; return ret;
} }
vfunc_button_press_event(buttonEvent) { vfunc_button_press_event(event) {
const ret = super.vfunc_button_press_event(buttonEvent); const ret = super.vfunc_button_press_event(event);
if (buttonEvent.button == 1) { const button = event.get_button();
if (button === 1) {
this._setPopupTimeout(); this._setPopupTimeout();
} else if (buttonEvent.button == 3) { } else if (button === 3) {
this.popupMenu(); this.popupMenu();
return Clutter.EVENT_STOP; return Clutter.EVENT_STOP;
} }
return ret; return ret;
} }
vfunc_touch_event(touchEvent) { vfunc_touch_event(event) {
const ret = super.vfunc_touch_event(touchEvent); const ret = super.vfunc_touch_event(event);
if (touchEvent.type == Clutter.EventType.TOUCH_BEGIN) if (event.type() === Clutter.EventType.TOUCH_BEGIN)
this._setPopupTimeout(); this._setPopupTimeout();
return ret; return ret;

View File

@ -82,8 +82,8 @@ const CandidateArea = GObject.registerClass({
this._cursorPosition = 0; this._cursorPosition = 0;
} }
vfunc_scroll_event(scrollEvent) { vfunc_scroll_event(event) {
switch (scrollEvent.direction) { switch (event.get_scroll_direction()) {
case Clutter.ScrollDirection.UP: case Clutter.ScrollDirection.UP:
this.emit('cursor-up'); this.emit('cursor-up');
break; break;

View File

@ -1291,8 +1291,8 @@ class HotCorner extends Clutter.Actor {
return Clutter.EVENT_STOP; return Clutter.EVENT_STOP;
} }
vfunc_leave_event(crossingEvent) { vfunc_leave_event(event) {
if (crossingEvent.related != this._corner) if (event.get_related() !== this._corner)
this._entered = false; this._entered = false;
return Clutter.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
} }

View File

@ -502,13 +502,13 @@ class ObjInspector extends St.ScrollView {
this._obj = null; this._obj = null;
} }
vfunc_key_press_event(keyPressEvent) { vfunc_key_press_event(event) {
const symbol = keyPressEvent.keyval; const symbol = event.get_key_symbol();
if (symbol === Clutter.KEY_Escape) { if (symbol === Clutter.KEY_Escape) {
this.close(); this.close();
return Clutter.EVENT_STOP; return Clutter.EVENT_STOP;
} }
return super.vfunc_key_press_event(keyPressEvent); return super.vfunc_key_press_event(event);
} }
_onInsert() { _onInsert() {
@ -1604,20 +1604,20 @@ class LookingGlass extends St.BoxLayout {
} }
// Handle key events which are relevant for all tabs of the LookingGlass // Handle key events which are relevant for all tabs of the LookingGlass
vfunc_key_press_event(keyPressEvent) { vfunc_key_press_event(event) {
let symbol = keyPressEvent.keyval; let symbol = event.get_key_symbol();
if (symbol == Clutter.KEY_Escape) { if (symbol == Clutter.KEY_Escape) {
this.close(); this.close();
return Clutter.EVENT_STOP; return Clutter.EVENT_STOP;
} }
// Ctrl+PgUp and Ctrl+PgDown switches tabs in the notebook view // Ctrl+PgUp and Ctrl+PgDown switches tabs in the notebook view
if (keyPressEvent.modifier_state & Clutter.ModifierType.CONTROL_MASK) { if (event.get_state() & Clutter.ModifierType.CONTROL_MASK) {
if (symbol == Clutter.KEY_Page_Up) if (symbol == Clutter.KEY_Page_Up)
this._notebook.prevTab(); this._notebook.prevTab();
else if (symbol == Clutter.KEY_Page_Down) else if (symbol == Clutter.KEY_Page_Down)
this._notebook.nextTab(); this._notebook.nextTab();
} }
return super.vfunc_key_press_event(keyPressEvent); return super.vfunc_key_press_event(event);
} }
open() { open() {

View File

@ -69,7 +69,7 @@ class URLHighlighter extends St.Label {
this.setMarkup(text, allowMarkup); this.setMarkup(text, allowMarkup);
} }
vfunc_button_press_event(buttonEvent) { vfunc_button_press_event(event) {
// Don't try to URL highlight when invisible. // Don't try to URL highlight when invisible.
// The MessageTray doesn't actually hide us, so // The MessageTray doesn't actually hide us, so
// we need to check for paint opacities as well. // we need to check for paint opacities as well.
@ -79,14 +79,14 @@ class URLHighlighter extends St.Label {
// Keep Notification from seeing this and taking // Keep Notification from seeing this and taking
// a pointer grab, which would block our button-release-event // a pointer grab, which would block our button-release-event
// handler, if an URL is clicked // handler, if an URL is clicked
return this._findUrlAtPos(buttonEvent) != -1; return this._findUrlAtPos(event) !== -1;
} }
vfunc_button_release_event(buttonEvent) { vfunc_button_release_event(event) {
if (!this.visible || this.get_paint_opacity() == 0) if (!this.visible || this.get_paint_opacity() == 0)
return Clutter.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
let urlId = this._findUrlAtPos(buttonEvent); const urlId = this._findUrlAtPos(event);
if (urlId != -1) { if (urlId != -1) {
let url = this._urls[urlId].url; let url = this._urls[urlId].url;
if (!url.includes(':')) if (!url.includes(':'))
@ -99,11 +99,11 @@ class URLHighlighter extends St.Label {
return Clutter.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
} }
vfunc_motion_event(motionEvent) { vfunc_motion_event(event) {
if (!this.visible || this.get_paint_opacity() == 0) if (!this.visible || this.get_paint_opacity() == 0)
return Clutter.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
let urlId = this._findUrlAtPos(motionEvent); const urlId = this._findUrlAtPos(event);
if (urlId != -1 && !this._cursorChanged) { if (urlId != -1 && !this._cursorChanged) {
global.display.set_cursor(Meta.Cursor.POINTING_HAND); global.display.set_cursor(Meta.Cursor.POINTING_HAND);
this._cursorChanged = true; this._cursorChanged = true;
@ -114,7 +114,7 @@ class URLHighlighter extends St.Label {
return Clutter.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
} }
vfunc_leave_event(crossingEvent) { vfunc_leave_event(event) {
if (!this.visible || this.get_paint_opacity() == 0) if (!this.visible || this.get_paint_opacity() == 0)
return Clutter.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
@ -122,7 +122,7 @@ class URLHighlighter extends St.Label {
this._cursorChanged = false; this._cursorChanged = false;
global.display.set_cursor(Meta.Cursor.DEFAULT); global.display.set_cursor(Meta.Cursor.DEFAULT);
} }
return super.vfunc_leave_event(crossingEvent); return super.vfunc_leave_event(event);
} }
setMarkup(text, allowMarkup) { setMarkup(text, allowMarkup) {
@ -151,7 +151,7 @@ class URLHighlighter extends St.Label {
} }
_findUrlAtPos(event) { _findUrlAtPos(event) {
let { x, y } = event; let [x, y] = event.get_coords();
[, x, y] = this.transform_stage_point(x, y); [, x, y] = this.transform_stage_point(x, y);
let findPos = -1; let findPos = -1;
for (let i = 0; i < this.clutter_text.text.length; i++) { for (let i = 0; i < this.clutter_text.text.length; i++) {
@ -541,8 +541,8 @@ export const Message = GObject.registerClass({
_onDestroy() { _onDestroy() {
} }
vfunc_key_press_event(keyEvent) { vfunc_key_press_event(event) {
let keysym = keyEvent.keyval; let keysym = event.get_key_symbol();
if (keysym == Clutter.KEY_Delete || if (keysym == Clutter.KEY_Delete ||
keysym == Clutter.KEY_KP_Delete) { keysym == Clutter.KEY_KP_Delete) {
@ -551,7 +551,7 @@ export const Message = GObject.registerClass({
return Clutter.EVENT_STOP; return Clutter.EVENT_STOP;
} }
} }
return super.vfunc_key_press_event(keyEvent); return super.vfunc_key_press_event(event);
} }
}); });

View File

@ -310,8 +310,8 @@ class ActivitiesButton extends PanelMenu.Button {
return Clutter.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
} }
vfunc_key_release_event(keyEvent) { vfunc_key_release_event(event) {
let symbol = keyEvent.keyval; let symbol = event.get_key_symbol();
if (symbol == Clutter.KEY_Return || symbol == Clutter.KEY_space) { if (symbol == Clutter.KEY_Return || symbol == Clutter.KEY_space) {
if (Main.overview.shouldToggleByCornerOrButton()) { if (Main.overview.shouldToggleByCornerOrButton()) {
Main.overview.toggle(); Main.overview.toggle();
@ -609,14 +609,14 @@ class Panel extends St.Widget {
return this._tryDragWindow(event); return this._tryDragWindow(event);
} }
vfunc_key_press_event(keyEvent) { vfunc_key_press_event(event) {
let symbol = keyEvent.keyval; let symbol = event.get_key_symbol();
if (symbol == Clutter.KEY_Escape) { if (symbol == Clutter.KEY_Escape) {
global.display.focus_default_window(keyEvent.time); global.display.focus_default_window(event.get_time());
return Clutter.EVENT_STOP; return Clutter.EVENT_STOP;
} }
return super.vfunc_key_press_event(keyEvent); return super.vfunc_key_press_event(event);
} }
_toggleMenu(indicator) { _toggleMenu(indicator) {

View File

@ -142,14 +142,14 @@ export const PopupBaseMenuItem = GObject.registerClass({
this._parent = parent; this._parent = parent;
} }
vfunc_key_press_event(keyEvent) { vfunc_key_press_event(event) {
if (global.focus_manager.navigate_from_event(Clutter.get_current_event())) if (global.focus_manager.navigate_from_event(Clutter.get_current_event()))
return Clutter.EVENT_STOP; return Clutter.EVENT_STOP;
if (!this._activatable) if (!this._activatable)
return super.vfunc_key_press_event(keyEvent); return super.vfunc_key_press_event(event);
let state = keyEvent.modifier_state; let state = event.get_state();
// if user has a modifier down (except capslock and numlock) // if user has a modifier down (except capslock and numlock)
// then don't handle the key press here // then don't handle the key press here
@ -160,7 +160,7 @@ export const PopupBaseMenuItem = GObject.registerClass({
if (state) if (state)
return Clutter.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
let symbol = keyEvent.keyval; let symbol = event.get_key_symbol();
if (symbol == Clutter.KEY_space || symbol == Clutter.KEY_Return) { if (symbol == Clutter.KEY_space || symbol == Clutter.KEY_Return) {
this.activate(Clutter.get_current_event()); this.activate(Clutter.get_current_event());
return Clutter.EVENT_STOP; return Clutter.EVENT_STOP;
@ -1244,8 +1244,8 @@ class PopupSubMenuMenuItem extends PopupBaseMenuItem {
return this.menu.isOpen; return this.menu.isOpen;
} }
vfunc_key_press_event(keyPressEvent) { vfunc_key_press_event(event) {
let symbol = keyPressEvent.keyval; let symbol = event.get_key_symbol();
if (symbol == Clutter.KEY_Right) { if (symbol == Clutter.KEY_Right) {
this._setOpenState(true); this._setOpenState(true);
@ -1256,7 +1256,7 @@ class PopupSubMenuMenuItem extends PopupBaseMenuItem {
return Clutter.EVENT_STOP; return Clutter.EVENT_STOP;
} }
return super.vfunc_key_press_event(keyPressEvent); return super.vfunc_key_press_event(event);
} }
activate(_event) { activate(_event) {

View File

@ -123,7 +123,7 @@ class RunDialog extends ModalDialog.ModalDialog {
} }
vfunc_key_release_event(event) { vfunc_key_release_event(event) {
if (event.keyval === Clutter.KEY_Escape) { if (event.get_key_symbol() === Clutter.KEY_Escape) {
this.close(); this.close();
return Clutter.EVENT_STOP; return Clutter.EVENT_STOP;
} }

View File

@ -430,19 +430,20 @@ const UIAreaSelector = GObject.registerClass({
if (this._dragButton) if (this._dragButton)
return Clutter.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
const cursor = this._computeCursorType(event.x, event.y); const [x, y] = event.get_coords();
const cursor = this._computeCursorType(x, y);
// Clicking outside of the selection, or using the right mouse button, // Clicking outside of the selection, or using the right mouse button,
// or with Ctrl results in dragging a new selection from scratch. // or with Ctrl results in dragging a new selection from scratch.
if (cursor === Meta.Cursor.CROSSHAIR || if (cursor === Meta.Cursor.CROSSHAIR ||
button === Clutter.BUTTON_SECONDARY || button === Clutter.BUTTON_SECONDARY ||
(event.modifier_state & Clutter.ModifierType.CONTROL_MASK)) { (event.get_state() & Clutter.ModifierType.CONTROL_MASK)) {
this._dragButton = button; this._dragButton = button;
this._dragCursor = Meta.Cursor.CROSSHAIR; this._dragCursor = Meta.Cursor.CROSSHAIR;
global.display.set_cursor(Meta.Cursor.CROSSHAIR); global.display.set_cursor(Meta.Cursor.CROSSHAIR);
[this._startX, this._startY] = [event.x, event.y]; [this._startX, this._startY] = event.get_coords();
this._lastX = this._startX = Math.floor(this._startX); this._lastX = this._startX = Math.floor(this._startX);
this._lastY = this._startY = Math.floor(this._startY); this._lastY = this._startY = Math.floor(this._startY);
@ -452,8 +453,7 @@ const UIAreaSelector = GObject.registerClass({
this._dragButton = button; this._dragButton = button;
this._dragCursor = cursor; this._dragCursor = cursor;
this._dragStartX = event.x; [this._dragStartX, this._dragStartY] = event.get_coords();
this._dragStartY = event.y;
const [leftX, topY, width, height] = this.getGeometry(); const [leftX, topY, width, height] = this.getGeometry();
const rightX = leftX + width - 1; const rightX = leftX + width - 1;
@ -517,14 +517,16 @@ const UIAreaSelector = GObject.registerClass({
// We might have finished creating a new selection, so we need to // We might have finished creating a new selection, so we need to
// update the cursor. // update the cursor.
this._updateCursor(event.x, event.y); const [x, y] = event.get_coords();
this._updateCursor(x, y);
return Clutter.EVENT_STOP; return Clutter.EVENT_STOP;
} }
_onMotion(event, sequence) { _onMotion(event, sequence) {
if (!this._dragButton) { if (!this._dragButton) {
this._updateCursor(event.x, event.y); const [x, y] = event.get_coords();
this._updateCursor(x, y);
return Clutter.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
} }
@ -532,12 +534,13 @@ const UIAreaSelector = GObject.registerClass({
return Clutter.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
if (this._dragCursor === Meta.Cursor.CROSSHAIR) { if (this._dragCursor === Meta.Cursor.CROSSHAIR) {
[this._lastX, this._lastY] = [event.x, event.y]; [this._lastX, this._lastY] = event.get_coords();
this._lastX = Math.floor(this._lastX); this._lastX = Math.floor(this._lastX);
this._lastY = Math.floor(this._lastY); this._lastY = Math.floor(this._lastY);
} else { } else {
let dx = Math.round(event.x - this._dragStartX); const [x, y] = event.get_coords();
let dy = Math.round(event.y - this._dragStartY); let dx = Math.round(x - this._dragStartX);
let dy = Math.round(y - this._dragStartY);
if (this._dragCursor === Meta.Cursor.MOVE_OR_RESIZE_WINDOW) { if (this._dragCursor === Meta.Cursor.MOVE_OR_RESIZE_WINDOW) {
const [,, selectionWidth, selectionHeight] = this.getGeometry(); const [,, selectionWidth, selectionHeight] = this.getGeometry();
@ -658,17 +661,19 @@ const UIAreaSelector = GObject.registerClass({
} }
vfunc_button_press_event(event) { vfunc_button_press_event(event) {
if (event.button === Clutter.BUTTON_PRIMARY || const button = event.get_button();
event.button === Clutter.BUTTON_SECONDARY) if (button === Clutter.BUTTON_PRIMARY ||
return this._onPress(event, event.button, null); button === Clutter.BUTTON_SECONDARY)
return this._onPress(event, button, null);
return Clutter.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
} }
vfunc_button_release_event(event) { vfunc_button_release_event(event) {
if (event.button === Clutter.BUTTON_PRIMARY || const button = event.get_button();
event.button === Clutter.BUTTON_SECONDARY) if (button === Clutter.BUTTON_PRIMARY ||
return this._onRelease(event, event.button, null); button === Clutter.BUTTON_SECONDARY)
return this._onRelease(event, button, null);
return Clutter.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
} }
@ -678,12 +683,13 @@ const UIAreaSelector = GObject.registerClass({
} }
vfunc_touch_event(event) { vfunc_touch_event(event) {
if (event.type === Clutter.EventType.TOUCH_BEGIN) const eventType = event.type();
return this._onPress(event, 'touch', event.sequence); if (eventType === Clutter.EventType.TOUCH_BEGIN)
else if (event.type === Clutter.EventType.TOUCH_END) return this._onPress(event, 'touch', event.get_event_sequence());
return this._onRelease(event, 'touch', event.sequence); else if (eventType === Clutter.EventType.TOUCH_END)
else if (event.type === Clutter.EventType.TOUCH_UPDATE) return this._onRelease(event, 'touch', event.get_event_sequence());
return this._onMotion(event, event.sequence); else if (eventType === Clutter.EventType.TOUCH_UPDATE)
return this._onMotion(event, event.get_event_sequence());
return Clutter.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
} }
@ -1999,9 +2005,9 @@ export const ScreenshotUI = GObject.registerClass({
} }
vfunc_key_press_event(event) { vfunc_key_press_event(event) {
const symbol = event.keyval; const symbol = event.get_key_symbol();
if (symbol === Clutter.KEY_Return || symbol === Clutter.KEY_space || if (symbol === Clutter.KEY_Return || symbol === Clutter.KEY_space ||
((event.modifier_state & Clutter.ModifierType.CONTROL_MASK) && ((event.get_state() & Clutter.ModifierType.CONTROL_MASK) &&
(symbol === Clutter.KEY_c || symbol === Clutter.KEY_C))) { (symbol === Clutter.KEY_c || symbol === Clutter.KEY_C))) {
this._onCaptureButtonClicked(); this._onCaptureButtonClicked();
return Clutter.EVENT_STOP; return Clutter.EVENT_STOP;
@ -2656,11 +2662,11 @@ class SelectArea extends St.Widget {
}); });
} }
vfunc_motion_event(motionEvent) { vfunc_motion_event(event) {
if (this._startX == -1 || this._startY == -1 || this._result) if (this._startX == -1 || this._startY == -1 || this._result)
return Clutter.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
[this._lastX, this._lastY] = [motionEvent.x, motionEvent.y]; [this._lastX, this._lastY] = event.get_coords();
this._lastX = Math.floor(this._lastX); this._lastX = Math.floor(this._lastX);
this._lastY = Math.floor(this._lastY); this._lastY = Math.floor(this._lastY);
let geometry = this._getGeometry(); let geometry = this._getGeometry();
@ -2672,11 +2678,11 @@ class SelectArea extends St.Widget {
return Clutter.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
} }
vfunc_button_press_event(buttonEvent) { vfunc_button_press_event(event) {
if (this._result) if (this._result)
return Clutter.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
[this._startX, this._startY] = [buttonEvent.x, buttonEvent.y]; [this._startX, this._startY] = event.get_coords();
this._startX = Math.floor(this._startX); this._startX = Math.floor(this._startX);
this._startY = Math.floor(this._startY); this._startY = Math.floor(this._startY);
this._rubberband.set_position(this._startX, this._startY); this._rubberband.set_position(this._startX, this._startY);
@ -2913,8 +2919,8 @@ class PickPixel extends St.Widget {
this._previewCursor.show(); this._previewCursor.show();
} }
vfunc_motion_event(motionEvent) { vfunc_motion_event(event) {
const { x, y } = motionEvent; const [x, y] = event.get_coords();
this._pickColor(x, y); this._pickColor(x, y);
return Clutter.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
} }

View File

@ -238,7 +238,7 @@ const ShellMountQuestionDialog = GObject.registerClass({
} }
vfunc_key_release_event(event) { vfunc_key_release_event(event) {
if (event.keyval === Clutter.KEY_Escape) { if (event.get_key_symbol() === Clutter.KEY_Escape) {
this.emit('response', -1); this.emit('response', -1);
return Clutter.EVENT_STOP; return Clutter.EVENT_STOP;
} }
@ -491,7 +491,7 @@ const ShellProcessesDialog = GObject.registerClass({
} }
vfunc_key_release_event(event) { vfunc_key_release_event(event) {
if (event.keyval === Clutter.KEY_Escape) { if (event.get_key_symbol() === Clutter.KEY_Escape) {
this.emit('response', -1); this.emit('response', -1);
return Clutter.EVENT_STOP; return Clutter.EVENT_STOP;
} }

View File

@ -177,14 +177,14 @@ export const Slider = GObject.registerClass({
return Clutter.EVENT_STOP; return Clutter.EVENT_STOP;
} }
vfunc_key_press_event(keyPressEvent) { vfunc_key_press_event(event) {
let key = keyPressEvent.keyval; let key = event.get_key_symbol();
if (key == Clutter.KEY_Right || key == Clutter.KEY_Left) { if (key == Clutter.KEY_Right || key == Clutter.KEY_Left) {
let delta = key == Clutter.KEY_Right ? 0.1 : -0.1; let delta = key == Clutter.KEY_Right ? 0.1 : -0.1;
this.value = Math.max(0, Math.min(this._value + delta, this._maxValue)); this.value = Math.max(0, Math.min(this._value + delta, this._maxValue));
return Clutter.EVENT_STOP; return Clutter.EVENT_STOP;
} }
return super.vfunc_key_press_event(keyPressEvent); return super.vfunc_key_press_event(event);
} }
_moveHandle(absX, _absY) { _moveHandle(absX, _absY) {

View File

@ -183,10 +183,10 @@ export const SwitcherPopup = GObject.registerClass({
throw new GObject.NotImplementedError(`_keyPressHandler in ${this.constructor.name}`); throw new GObject.NotImplementedError(`_keyPressHandler in ${this.constructor.name}`);
} }
vfunc_key_press_event(keyEvent) { vfunc_key_press_event(event) {
let keysym = keyEvent.keyval; let keysym = event.get_key_symbol();
let action = global.display.get_keybinding_action( let action = global.display.get_keybinding_action(
keyEvent.hardware_keycode, keyEvent.modifier_state); event.get_key_code(), event.get_state());
this._disableHover(); this._disableHover();
@ -206,18 +206,18 @@ export const SwitcherPopup = GObject.registerClass({
keysym === Clutter.KEY_Return || keysym === Clutter.KEY_Return ||
keysym === Clutter.KEY_KP_Enter || keysym === Clutter.KEY_KP_Enter ||
keysym === Clutter.KEY_ISO_Enter) keysym === Clutter.KEY_ISO_Enter)
this._finish(keyEvent.time); this._finish(event.get_time());
return Clutter.EVENT_STOP; return Clutter.EVENT_STOP;
} }
vfunc_key_release_event(keyEvent) { vfunc_key_release_event(event) {
if (this._modifierMask) { if (this._modifierMask) {
let [x_, y_, mods] = global.get_pointer(); let [x_, y_, mods] = global.get_pointer();
let state = mods & this._modifierMask; let state = mods & this._modifierMask;
if (state == 0) if (state == 0)
this._finish(keyEvent.time); this._finish(event.get_time());
} else { } else {
this._resetNoModsTimeout(); this._resetNoModsTimeout();
} }
@ -238,10 +238,10 @@ export const SwitcherPopup = GObject.registerClass({
this._select(this._next()); this._select(this._next());
} }
vfunc_scroll_event(scrollEvent) { vfunc_scroll_event(event) {
this._disableHover(); this._disableHover();
this._scrollHandler(scrollEvent.direction); this._scrollHandler(event.get_scroll_direction());
return Clutter.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
} }

View File

@ -607,19 +607,19 @@ export const UnlockDialog = GObject.registerClass({
this.connect('destroy', this._onDestroy.bind(this)); this.connect('destroy', this._onDestroy.bind(this));
} }
vfunc_key_press_event(keyEvent) { vfunc_key_press_event(event) {
if (this._activePage === this._promptBox || if (this._activePage === this._promptBox ||
(this._promptBox && this._promptBox.visible)) (this._promptBox && this._promptBox.visible))
return Clutter.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
const { keyval } = keyEvent; const keyval = event.get_key_symbol();
if (keyval === Clutter.KEY_Shift_L || if (keyval === Clutter.KEY_Shift_L ||
keyval === Clutter.KEY_Shift_R || keyval === Clutter.KEY_Shift_R ||
keyval === Clutter.KEY_Shift_Lock || keyval === Clutter.KEY_Shift_Lock ||
keyval === Clutter.KEY_Caps_Lock) keyval === Clutter.KEY_Caps_Lock)
return Clutter.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
let unichar = keyEvent.unicode_value; let unichar = event.get_key_unicode();
this._showPrompt(); this._showPrompt();

View File

@ -557,18 +557,18 @@ export const WindowPreview = GObject.registerClass({
this.emit('selected', global.get_current_time()); this.emit('selected', global.get_current_time());
} }
vfunc_enter_event(crossingEvent) { vfunc_enter_event(event) {
this.showOverlay(true); this.showOverlay(true);
return super.vfunc_enter_event(crossingEvent); return super.vfunc_enter_event(event);
} }
vfunc_leave_event(crossingEvent) { vfunc_leave_event(event) {
if (this._destroyed) if (this._destroyed)
return super.vfunc_leave_event(crossingEvent); return super.vfunc_leave_event(event);
if ((crossingEvent.flags & Clutter.EventFlags.FLAG_GRAB_NOTIFY) !== 0 && if ((event.get_flags() & Clutter.EventFlags.FLAG_GRAB_NOTIFY) !== 0 &&
global.stage.get_grab_actor() === this._closeButton) global.stage.get_grab_actor() === this._closeButton)
return super.vfunc_leave_event(crossingEvent); return super.vfunc_leave_event(event);
if (this._idleHideOverlayId > 0) if (this._idleHideOverlayId > 0)
GLib.source_remove(this._idleHideOverlayId); GLib.source_remove(this._idleHideOverlayId);
@ -589,7 +589,7 @@ export const WindowPreview = GObject.registerClass({
GLib.Source.set_name_by_id(this._idleHideOverlayId, '[gnome-shell] this._idleHideOverlayId'); GLib.Source.set_name_by_id(this._idleHideOverlayId, '[gnome-shell] this._idleHideOverlayId');
return super.vfunc_leave_event(crossingEvent); return super.vfunc_leave_event(event);
} }
vfunc_key_focus_in() { vfunc_key_focus_in() {
@ -604,15 +604,15 @@ export const WindowPreview = GObject.registerClass({
this.hideOverlay(true); this.hideOverlay(true);
} }
vfunc_key_press_event(keyEvent) { vfunc_key_press_event(event) {
let symbol = keyEvent.keyval; let symbol = event.get_key_symbol();
let isEnter = symbol == Clutter.KEY_Return || symbol == Clutter.KEY_KP_Enter; let isEnter = symbol == Clutter.KEY_Return || symbol == Clutter.KEY_KP_Enter;
if (isEnter) { if (isEnter) {
this._activate(); this._activate();
return true; return true;
} }
return super.vfunc_key_press_event(keyEvent); return super.vfunc_key_press_event(event);
} }
_restack() { _restack() {