Skip to content

Commit 927ea58

Browse files
committed
global.screen: Remove remaining usage in js code, add deprecation
warnings. The MetaScreen went away in 5.4 (wayland rebase), with its methods mainly taken up by the MetaDisplay and MetaWorkspaceManager classes. For backward compatibility with xlets, CinnamonScreen was added, and has continued to be used heavily. Add deprecation notes to documentation, and runtime warnings when any screen methods are used.
1 parent c2d13be commit 927ea58

5 files changed

Lines changed: 146 additions & 8 deletions

File tree

files/usr/share/cinnamon/applets/[email protected]/applet.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,20 +195,20 @@ class CinnamonBarApplet extends Applet.Applet {
195195
if (etime > (this._last_scroll_time + SCROLL_DELAY) ||
196196
edir !== this._last_scroll_direction) {
197197

198-
let index = global.screen.get_active_workspace_index();
198+
let index = global.workspace_manager.get_active_workspace_index();
199199

200200
let workspaceCycle = this.muffinSettings.get_boolean('workspace-cycle')
201201

202202
if ((edir == Clutter.ScrollDirection.UP) == (this.scroll_behavior == 'normal')) {
203203
index--;
204-
if (index < 0) index = workspaceCycle ? global.screen.n_workspaces - 1 : 0;
204+
if (index < 0) index = workspaceCycle ? global.workspace_manager.n_workspaces - 1 : 0;
205205
} else {
206206
index++;
207-
if (index == global.screen.n_workspaces) index = workspaceCycle ? 0 : index - 1;
207+
if (index == global.workspace_manager.n_workspaces) index = workspaceCycle ? 0 : index - 1;
208208
}
209209

210-
if (global.screen.get_workspace_by_index(index) != null) {
211-
global.screen.get_workspace_by_index(index).activate(global.get_current_time());
210+
if (global.workspace_manager.get_workspace_by_index(index) != null) {
211+
global.workspace_manager.get_workspace_by_index(index).activate(global.get_current_time());
212212
}
213213

214214
this._last_scroll_direction = edir;

js/ui/appSwitcher/appSwitcher.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function getWindowsForBinding(binding) {
6868
let showCurrentMonitorOnly = global.settings.get_boolean("alttab-switcher-show-current-monitor");
6969

7070
if (showCurrentMonitorOnly) {
71-
windows = windows.filter(w => w.get_monitor() === global.screen.get_current_monitor())
71+
windows = windows.filter(w => w.get_monitor() === global.display.get_current_monitor())
7272
}
7373

7474
switch (binding.get_name()) {

js/ui/applet.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1142,7 +1142,7 @@ var PopupResizeHandler = class PopupResizeHandler {
11421142

11431143
_collect_work_area_edges() {
11441144
const monitor = Main.layoutManager.findMonitorForActor(this.actor);
1145-
const ws = global.screen.get_active_workspace();
1145+
const ws = global.workspace_manager.get_active_workspace();
11461146
const area = ws.get_work_area_for_monitor(monitor.index);
11471147

11481148
this._edges.top = area.y;

js/ui/layout.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,32 @@ LayoutManager.prototype = {
655655
*/
656656
isTrackingChrome: function(actor) {
657657
return this._chrome._findActor(actor) != -1;
658+
},
659+
660+
/**
661+
* getWindowAtPointer:
662+
*
663+
* Gets the MetaWindow under the mouse pointer. Only considers windows
664+
* that are not completely obscured by other windows.
665+
*
666+
* Returns (Meta.Window): the MetaWindow under the pointer, or null if none found
667+
*/
668+
getWindowAtPointer: function() {
669+
let [pointerX, pointerY] = global.get_pointer();
670+
let workspace = global.workspace_manager.get_active_workspace();
671+
let windows = workspace.list_unobscured_windows();
672+
673+
for (let i = windows.length - 1; i >= 0; i--) {
674+
let window = windows[i];
675+
let rect = window.get_frame_rect();
676+
677+
if (pointerX >= rect.x && pointerX < rect.x + rect.width &&
678+
pointerY >= rect.y && pointerY < rect.y + rect.height) {
679+
return window;
680+
}
681+
}
682+
683+
return null;
658684
}
659685
};
660686
Signals.addSignalMethods(LayoutManager.prototype);

0 commit comments

Comments
 (0)