Skip to content

Commit 56c81d1

Browse files
authored
Merge branch 'main' into leolost/introduce-get-animation-duration
2 parents addbc0d + f5cfb7f commit 56c81d1

25 files changed

+213
-222
lines changed

lib/DragDropAction.vala

Lines changed: 39 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -216,40 +216,6 @@ namespace Gala {
216216

217217
return Clutter.EVENT_STOP;
218218

219-
case EventType.BUTTON_RELEASE:
220-
case EventType.TOUCH_END:
221-
if (!is_valid_touch_event (event)) {
222-
return Clutter.EVENT_PROPAGATE;
223-
}
224-
225-
if (!dragging) {
226-
float x, y, ex, ey;
227-
event.get_coords (out ex, out ey);
228-
actor.get_transformed_position (out x, out y);
229-
230-
// release has happened within bounds of actor
231-
if (clicked && x < ex && x + actor.width > ex && y < ey && y + actor.height > ey) {
232-
actor_clicked (event.get_type () == BUTTON_RELEASE ? event.get_button () : Clutter.Button.PRIMARY);
233-
}
234-
235-
if (clicked) {
236-
ungrab_actor ();
237-
clicked = false;
238-
}
239-
240-
return Clutter.EVENT_STOP;
241-
} else if (dragging) {
242-
if (hovered != null) {
243-
finish ();
244-
hovered = null;
245-
} else {
246-
cancel ();
247-
}
248-
249-
return Clutter.EVENT_STOP;
250-
}
251-
break;
252-
253219
default:
254220
break;
255221
}
@@ -298,7 +264,42 @@ namespace Gala {
298264
if (event.get_key_symbol () == Key.Escape) {
299265
cancel ();
300266
}
301-
break;
267+
268+
return Clutter.EVENT_STOP;
269+
270+
case EventType.BUTTON_RELEASE:
271+
case EventType.TOUCH_END:
272+
if (!is_valid_touch_event (event)) {
273+
return Clutter.EVENT_PROPAGATE;
274+
}
275+
276+
if (dragging) {
277+
if (hovered != null) {
278+
finish ();
279+
hovered = null;
280+
} else {
281+
cancel ();
282+
}
283+
284+
return Clutter.EVENT_STOP;
285+
}
286+
287+
float x, y, ex, ey;
288+
event.get_coords (out ex, out ey);
289+
actor.get_transformed_position (out x, out y);
290+
291+
// release has happened within bounds of actor
292+
if (clicked && x < ex && x + actor.width > ex && y < ey && y + actor.height > ey) {
293+
actor_clicked (event.get_type () == BUTTON_RELEASE ? event.get_button () : Clutter.Button.PRIMARY);
294+
}
295+
296+
if (clicked) {
297+
ungrab_actor ();
298+
clicked = false;
299+
}
300+
301+
return Clutter.EVENT_STOP;
302+
302303
case EventType.MOTION:
303304
case EventType.TOUCH_UPDATE:
304305
if (!is_valid_touch_event (event)) {
@@ -338,6 +339,7 @@ namespace Gala {
338339
}
339340
}
340341
return Clutter.EVENT_STOP;
342+
341343
} else if (dragging) {
342344
handle.x -= last_x - x;
343345
handle.y -= last_y - y;
@@ -468,11 +470,11 @@ namespace Gala {
468470
var type = event.get_type ();
469471

470472
return (
473+
Meta.Util.is_wayland_compositor () ||
471474
type != Clutter.EventType.TOUCH_BEGIN &&
472475
type != Clutter.EventType.TOUCH_CANCEL &&
473476
type != Clutter.EventType.TOUCH_END &&
474-
type != Clutter.EventType.TOUCH_UPDATE ||
475-
Meta.Util.is_wayland_compositor ()
477+
type != Clutter.EventType.TOUCH_UPDATE
476478
);
477479
}
478480
}

plugins/pip/Main.vala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public class Gala.Plugins.PIP.Plugin : Gala.Plugin {
9292
var rect = Graphene.Rect.alloc ();
9393
rect.init (point_x, point_y, width, height);
9494

95-
var popup_window = new PopupWindow (wm, active);
95+
var popup_window = new PopupWindow (wm.get_display (), active);
9696
popup_window.set_container_clip (rect);
9797
popup_window.show.connect (on_popup_window_show);
9898
popup_window.hide.connect (on_popup_window_hide);
@@ -114,7 +114,7 @@ public class Gala.Plugins.PIP.Plugin : Gala.Plugin {
114114
private void select_window_at (int x, int y) {
115115
var selected = get_window_actor_at (x, y);
116116
if (selected != null) {
117-
var popup_window = new PopupWindow (wm, selected);
117+
var popup_window = new PopupWindow (wm.get_display (), selected);
118118
popup_window.show.connect (on_popup_window_show);
119119
popup_window.hide.connect (on_popup_window_hide);
120120
add_window (popup_window);

plugins/pip/PopupWindow.vala

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
1616

1717
public signal void closed ();
1818

19-
public Gala.WindowManager wm { get; construct; }
19+
public Meta.Display display { get; construct; }
2020
public Meta.WindowActor window_actor { get; construct; }
2121

2222
private Clutter.Clone clone; // clone itself
@@ -52,12 +52,11 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
5252
|| window_type == Meta.WindowType.MODAL_DIALOG;
5353
}
5454

55-
public PopupWindow (Gala.WindowManager wm, Meta.WindowActor window_actor) {
56-
Object (wm: wm, window_actor: window_actor);
55+
public PopupWindow (Meta.Display display, Meta.WindowActor window_actor) {
56+
Object (display: display, window_actor: window_actor);
5757
}
5858

5959
construct {
60-
unowned var display = wm.get_display ();
6160
var scale = display.get_monitor_scale (display.get_current_monitor ());
6261

6362
button_size = Gala.Utils.scale_to_int (36, scale);
@@ -133,7 +132,7 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
133132
window.unmanaged.connect (on_close_click_clicked);
134133
window.notify["appears-focused"].connect (update_window_focus);
135134

136-
unowned var workspace_manager = wm.get_display ().get_workspace_manager ();
135+
unowned var workspace_manager = display.get_workspace_manager ();
137136
workspace_manager.active_workspace_changed.connect (update_window_focus);
138137
}
139138

@@ -215,15 +214,15 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
215214
}
216215

217216
private Clutter.Actor on_move_begin () {
218-
wm.get_display ().set_cursor (Meta.Cursor.DND_IN_DRAG);
217+
display.set_cursor (Meta.Cursor.DND_IN_DRAG);
219218

220219
return this;
221220
}
222221

223222
private void on_move_end () {
224223
reactive = true;
225224
update_screen_position ();
226-
wm.get_display ().set_cursor (Meta.Cursor.DEFAULT);
225+
display.set_cursor (Meta.Cursor.DEFAULT);
227226
}
228227

229228
#if HAS_MUTTER45
@@ -245,7 +244,7 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
245244
grab = resize_button.get_stage ().grab (resize_button);
246245
resize_button.event.connect (on_resize_event);
247246

248-
wm.get_display ().set_cursor (Meta.Cursor.SE_RESIZE);
247+
display.set_cursor (Meta.Cursor.SE_RESIZE);
249248

250249
return Clutter.EVENT_PROPAGATE;
251250
}
@@ -306,7 +305,7 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
306305

307306
update_screen_position ();
308307

309-
wm.get_display ().set_cursor (Meta.Cursor.DEFAULT);
308+
display.set_cursor (Meta.Cursor.DEFAULT);
310309
}
311310

312311
private void on_allocation_changed () {
@@ -329,14 +328,14 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
329328
}
330329

331330
private void update_window_focus () {
332-
unowned Meta.Window focus_window = wm.get_display ().get_focus_window ();
331+
unowned Meta.Window focus_window = display.get_focus_window ();
333332
if ((focus_window != null && !get_window_is_normal (focus_window))
334333
|| (previous_focus != null && !get_window_is_normal (previous_focus))) {
335334
previous_focus = focus_window;
336335
return;
337336
}
338337

339-
unowned var workspace_manager = wm.get_display ().get_workspace_manager ();
338+
unowned var workspace_manager = display.get_workspace_manager ();
340339
unowned var active_workspace = workspace_manager.get_active_workspace ();
341340
unowned var window = window_actor.get_meta_window ();
342341

@@ -520,7 +519,6 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
520519
}
521520

522521
private bool coord_is_in_other_monitor (float coord, Clutter.Orientation axis) {
523-
var display = wm.get_display ();
524522
int n_monitors = display.get_n_monitors ();
525523

526524
if (n_monitors == 1) {
@@ -553,7 +551,6 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
553551
#else
554552
private void get_current_monitor_rect (out Meta.Rectangle rect) {
555553
#endif
556-
var display = wm.get_display ();
557554
rect = display.get_monitor_geometry (display.get_current_monitor ());
558555
}
559556

po/zh_TW.po

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgstr ""
88
"Project-Id-Version: \n"
99
"Report-Msgid-Bugs-To: https://github.com/elementary/gala/issues\n"
1010
"POT-Creation-Date: 2024-10-15 19:33+0000\n"
11-
"PO-Revision-Date: 2024-09-19 10:09+0000\n"
11+
"PO-Revision-Date: 2024-11-06 11:20+0000\n"
1212
"Last-Translator: Kisaragi Hiu <[email protected]>\n"
1313
"Language-Team: Chinese (Traditional) <https://l10n.elementary.io/projects/"
1414
"desktop/gala/zh_Hant/>\n"
@@ -151,11 +151,11 @@ msgstr "修正多工作業檢視中手勢可能會停止運作的問題"
151151

152152
#: data/gala.metainfo.xml.in:109
153153
msgid "Improve dynamic workspaces behaviour with multiple monitors"
154-
msgstr "改善多螢幕時的動態工作空間行為"
154+
msgstr "改善多螢幕時的動態工作區行為"
155155

156156
#: data/gala.metainfo.xml.in:131
157157
msgid "Improve handling of move-to-workspace shortcut"
158-
msgstr "改善移動到工作空間快捷鍵的處理"
158+
msgstr "改善「移動到工作區」快捷鍵的處理"
159159

160160
#: data/gala-multitaskingview.desktop.in:4
161161
#: data/gala-multitaskingview.desktop.in:6

src/Background/BackgroundContainer.vala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ namespace Gala {
2020
public signal void changed ();
2121
public signal void show_background_menu (int x, int y);
2222

23-
public WindowManager wm { get; construct; }
23+
public Meta.Display display { get; construct; }
2424

25-
public BackgroundContainer (WindowManager wm) {
26-
Object (wm: wm);
25+
public BackgroundContainer (Meta.Display display) {
26+
Object (display: display);
2727
}
2828

2929
construct {
30-
unowned var monitor_manager = wm.get_display ().get_context ().get_backend ().get_monitor_manager ();
30+
unowned var monitor_manager = display.get_context ().get_backend ().get_monitor_manager ();
3131
monitor_manager.monitors_changed.connect (update);
3232

3333
reactive = true;
@@ -44,7 +44,7 @@ namespace Gala {
4444
}
4545

4646
~BackgroundContainer () {
47-
unowned var monitor_manager = wm.get_display ().get_context ().get_backend ().get_monitor_manager ();
47+
unowned var monitor_manager = display.get_context ().get_backend ().get_monitor_manager ();
4848
monitor_manager.monitors_changed.disconnect (update);
4949
}
5050

@@ -59,8 +59,8 @@ namespace Gala {
5959

6060
destroy_all_children ();
6161

62-
for (var i = 0; i < wm.get_display ().get_n_monitors (); i++) {
63-
var background = new BackgroundManager (wm, i);
62+
for (var i = 0; i < display.get_n_monitors (); i++) {
63+
var background = new BackgroundManager (display, i);
6464

6565
add_child (background);
6666

src/Background/BackgroundManager.vala

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class Gala.BackgroundManager : Meta.BackgroundGroup, Gala.BackgroundManag
1010

1111
public signal void changed ();
1212

13-
public WindowManager wm { get; construct; }
13+
public Meta.Display display { get; construct; }
1414
public int monitor_index { get; construct; }
1515
public bool control_position { get; construct; }
1616
public bool rounded_corners { get; construct; }
@@ -24,12 +24,12 @@ public class Gala.BackgroundManager : Meta.BackgroundGroup, Gala.BackgroundManag
2424
private Meta.BackgroundActor? background_actor;
2525
private Meta.BackgroundActor? new_background_actor = null;
2626

27-
public BackgroundManager (WindowManager wm, int monitor_index, bool control_position = true, bool rounded_corners = true) {
28-
Object (wm: wm, monitor_index: monitor_index, control_position: control_position, rounded_corners: rounded_corners);
27+
public BackgroundManager (Meta.Display display, int monitor_index, bool control_position = true, bool rounded_corners = true) {
28+
Object (display: display, monitor_index: monitor_index, control_position: control_position, rounded_corners: rounded_corners);
2929
}
3030

3131
construct {
32-
background_source = BackgroundCache.get_default ().get_background_source (wm.get_display ());
32+
background_source = BackgroundCache.get_default ().get_background_source (display);
3333
update_background_actor (false);
3434

3535
destroy.connect (on_destroy);
@@ -93,7 +93,7 @@ public class Gala.BackgroundManager : Meta.BackgroundGroup, Gala.BackgroundManag
9393

9494
if (background.is_loaded) {
9595
if (rounded_corners) {
96-
new_content.rounded_clip_radius = Utils.scale_to_int (6, wm.get_display ().get_monitor_scale (monitor_index));
96+
new_content.rounded_clip_radius = Utils.scale_to_int (6, display.get_monitor_scale (monitor_index));
9797
}
9898

9999
swap_background_actor (animate);
@@ -106,7 +106,7 @@ public class Gala.BackgroundManager : Meta.BackgroundGroup, Gala.BackgroundManag
106106
background.set_data<ulong> ("background-loaded-handler", 0);
107107

108108
if (rounded_corners) {
109-
new_content.rounded_clip_radius = Utils.scale_to_int (6, wm.get_display ().get_monitor_scale (monitor_index));
109+
new_content.rounded_clip_radius = Utils.scale_to_int (6, display.get_monitor_scale (monitor_index));
110110
}
111111

112112
swap_background_actor (animate);
@@ -121,8 +121,6 @@ public class Gala.BackgroundManager : Meta.BackgroundGroup, Gala.BackgroundManag
121121
}
122122

123123
private Meta.BackgroundActor create_background_actor () {
124-
unowned var display = wm.get_display ();
125-
126124
var background = background_source.get_background (monitor_index);
127125
var background_actor = new Meta.BackgroundActor (display, monitor_index);
128126

src/DBus.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public class Gala.DBus {
3333
Bus.own_name (BusType.SESSION, "org.gnome.Shell", BusNameOwnerFlags.NONE,
3434
(connection) => {
3535
try {
36-
connection.register_object ("/org/gnome/Shell", DBusAccelerator.init (wm));
36+
connection.register_object ("/org/gnome/Shell", DBusAccelerator.init (wm.get_display ()));
3737
connection.register_object ("/org/gnome/Shell/Screenshot", ScreenshotManager.init (wm));
3838
} catch (Error e) { warning (e.message); }
3939
},

src/DBusAccelerator.vala

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,22 +75,23 @@ namespace Gala {
7575
private static DBusAccelerator? instance;
7676

7777
[DBus (visible = false)]
78-
public static unowned DBusAccelerator init (WindowManager wm) {
79-
if (instance == null)
80-
instance = new DBusAccelerator (wm);
78+
public static unowned DBusAccelerator init (Meta.Display display) {
79+
if (instance == null) {
80+
instance = new DBusAccelerator (display);
81+
}
8182

8283
return instance;
8384
}
8485

8586
public signal void accelerator_activated (uint action, GLib.HashTable<string, Variant> parameters);
8687

87-
private WindowManager wm;
88+
private Meta.Display display;
8889
private GLib.HashTable<unowned string, GrabbedAccelerator> grabbed_accelerators;
8990

90-
private DBusAccelerator (WindowManager _wm) {
91-
wm = _wm;
91+
private DBusAccelerator (Meta.Display _display) {
92+
display = _display;
9293
grabbed_accelerators = new HashTable<unowned string, GrabbedAccelerator> (str_hash, str_equal);
93-
wm.get_display ().accelerator_activated.connect (on_accelerator_activated);
94+
display.accelerator_activated.connect (on_accelerator_activated);
9495
}
9596

9697
private void on_accelerator_activated (uint action, Clutter.InputDevice device, uint timestamp) {
@@ -115,7 +116,7 @@ namespace Gala {
115116
return found_accel.action;
116117
}
117118

118-
uint action = wm.get_display ().grab_accelerator (accelerator, grab_flags);
119+
uint action = display.grab_accelerator (accelerator, grab_flags);
119120
if (action != Meta.KeyBindingFlags.NONE) {
120121
var accel = new GrabbedAccelerator ();
121122
accel.action = action;
@@ -141,7 +142,7 @@ namespace Gala {
141142
public bool ungrab_accelerator (uint action) throws GLib.DBusError, GLib.IOError {
142143
foreach (unowned GrabbedAccelerator accel in grabbed_accelerators.get_values ()) {
143144
if (accel.action == action) {
144-
bool ret = wm.get_display ().ungrab_accelerator (action);
145+
bool ret = display.ungrab_accelerator (action);
145146
grabbed_accelerators.remove (accel.name);
146147
return ret;
147148
}

0 commit comments

Comments
 (0)