Skip to content

Commit 8a8cb84

Browse files
committed
Fix scale + cleanup
1 parent 5742055 commit 8a8cb84

File tree

3 files changed

+43
-123
lines changed

3 files changed

+43
-123
lines changed

daemon/MenuDaemon.vala

-74
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@ namespace Gala {
5151
private Gtk.MenuItem close;
5252
private Gtk.MenuItem screenshot;
5353

54-
// Desktop Menu
55-
private Gtk.Menu? desktop_menu = null;
56-
5754
private WMDBus? wm_proxy = null;
5855

5956
private ulong always_on_top_sid = 0U;
@@ -292,76 +289,5 @@ namespace Gala {
292289
return opened ? Source.REMOVE : Source.CONTINUE;
293290
});
294291
}
295-
296-
public void show_desktop_menu (int x, int y) throws DBusError, IOError {
297-
if (desktop_menu == null) {
298-
var change_wallpaper = new Gtk.MenuItem.with_label (_("Change Wallpaper…"));
299-
change_wallpaper.activate.connect (() => {
300-
try {
301-
AppInfo.launch_default_for_uri ("settings://desktop/appearance/wallpaper", null);
302-
} catch (Error e) {
303-
var message_dialog = new Granite.MessageDialog.with_image_from_icon_name (
304-
"Failed to Open Wallpaper Settings",
305-
"Unable to open System Settings. A handler for the `settings://` URI scheme must be installed.",
306-
"dialog-error",
307-
Gtk.ButtonsType.CLOSE
308-
);
309-
message_dialog.show_error_details (e.message);
310-
message_dialog.run ();
311-
message_dialog.destroy ();
312-
}
313-
});
314-
315-
var display_settings = new Gtk.MenuItem.with_label (_("Display Settings…"));
316-
display_settings.activate.connect (() => {
317-
try {
318-
AppInfo.launch_default_for_uri ("settings://display", null);
319-
} catch (Error e) {
320-
var message_dialog = new Granite.MessageDialog.with_image_from_icon_name (
321-
"Failed to Open Display Settings",
322-
"Unable to open System Settings. A handler for the `settings://` URI scheme must be installed.",
323-
"dialog-warning",
324-
Gtk.ButtonsType.CLOSE
325-
);
326-
message_dialog.show_error_details (e.message);
327-
message_dialog.run ();
328-
message_dialog.destroy ();
329-
}
330-
});
331-
332-
var system_settings = new Gtk.MenuItem.with_label (_("System Settings…"));
333-
system_settings.activate.connect (() => {
334-
try {
335-
AppInfo.launch_default_for_uri ("settings://", null);
336-
} catch (Error e) {
337-
var message_dialog = new Granite.MessageDialog.with_image_from_icon_name (
338-
"Failed to Open System Settings",
339-
"Unable to open System Settings. A handler for the `settings://` URI scheme must be installed.",
340-
"dialog-warning",
341-
Gtk.ButtonsType.CLOSE
342-
);
343-
message_dialog.show_error_details (e.message);
344-
message_dialog.run ();
345-
message_dialog.destroy ();
346-
}
347-
});
348-
349-
desktop_menu = new Gtk.Menu ();
350-
desktop_menu.append (change_wallpaper);
351-
desktop_menu.append (display_settings);
352-
desktop_menu.append (new Gtk.SeparatorMenuItem ());
353-
desktop_menu.append (system_settings);
354-
desktop_menu.show_all ();
355-
}
356-
357-
desktop_menu.popup (null, null, (m, ref px, ref py, out push_in) => {
358-
var scale = m.scale_factor;
359-
px = x / scale;
360-
// Move the menu 1 pixel outside of the pointer or else it closes instantly
361-
// on the mouse up event
362-
py = (y / scale) + 1;
363-
push_in = false;
364-
}, Gdk.BUTTON_SECONDARY, Gdk.CURRENT_TIME);
365-
}
366292
}
367293
}

src/Widgets/Menu/Menu.vala

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public class Gala.Menu : Clutter.Actor {
9292

9393
container.margin_top = container.margin_bottom = InternalUtils.scale_to_int (6, scale_factor);
9494

95-
foreach (var child in get_children ()) {
95+
foreach (var child in container.get_children ()) {
9696
if (child is MenuItem) {
9797
((MenuItem) child).scale (scale_factor);
9898
continue;

src/WindowManager.vala

+42-48
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ namespace Gala {
2222
[DBus (name = "org.pantheon.gala.daemon")]
2323
public interface Daemon: GLib.Object {
2424
public abstract async void show_window_menu (WindowFlags flags, int x, int y) throws Error;
25-
public abstract async void show_desktop_menu (int x, int y) throws Error;
2625
}
2726

2827
public class WindowManagerGala : Meta.Plugin, WindowManager {
@@ -982,53 +981,48 @@ namespace Gala {
982981
public override void show_window_menu (Meta.Window window, Meta.WindowMenuType menu, int x, int y) {
983982
switch (menu) {
984983
case Meta.WindowMenuType.WM:
985-
warning ("CREATE MENU");
986-
var window_menu = new BackgroundMenu (this);
987-
ui_group.add_child (window_menu);
988-
window_menu.set_position (x, y);
989-
window_menu.open_menu ();
990-
// if (daemon_proxy == null || window.get_window_type () == Meta.WindowType.NOTIFICATION) {
991-
// return;
992-
// }
993-
994-
// WindowFlags flags = WindowFlags.NONE;
995-
// if (window.can_minimize ())
996-
// flags |= WindowFlags.CAN_HIDE;
997-
998-
// if (window.can_maximize ())
999-
// flags |= WindowFlags.CAN_MAXIMIZE;
1000-
1001-
// var maximize_flags = window.get_maximized ();
1002-
// if (maximize_flags > 0) {
1003-
// flags |= WindowFlags.IS_MAXIMIZED;
1004-
1005-
// if (Meta.MaximizeFlags.VERTICAL in maximize_flags && !(Meta.MaximizeFlags.HORIZONTAL in maximize_flags)) {
1006-
// flags |= WindowFlags.IS_TILED;
1007-
// }
1008-
// }
1009-
1010-
// if (window.allows_move ())
1011-
// flags |= WindowFlags.ALLOWS_MOVE;
1012-
1013-
// if (window.allows_resize ())
1014-
// flags |= WindowFlags.ALLOWS_RESIZE;
1015-
1016-
// if (window.is_above ())
1017-
// flags |= WindowFlags.ALWAYS_ON_TOP;
1018-
1019-
// if (window.on_all_workspaces)
1020-
// flags |= WindowFlags.ON_ALL_WORKSPACES;
1021-
1022-
// if (window.can_close ())
1023-
// flags |= WindowFlags.CAN_CLOSE;
1024-
1025-
// daemon_proxy.show_window_menu.begin (flags, x, y, (obj, res) => {
1026-
// try {
1027-
// ((Daemon) obj).show_window_menu.end (res);
1028-
// } catch (Error e) {
1029-
// message ("Error invoking MenuManager: %s", e.message);
1030-
// }
1031-
// });
984+
if (daemon_proxy == null || window.get_window_type () == Meta.WindowType.NOTIFICATION) {
985+
return;
986+
}
987+
988+
WindowFlags flags = WindowFlags.NONE;
989+
if (window.can_minimize ())
990+
flags |= WindowFlags.CAN_HIDE;
991+
992+
if (window.can_maximize ())
993+
flags |= WindowFlags.CAN_MAXIMIZE;
994+
995+
var maximize_flags = window.get_maximized ();
996+
if (maximize_flags > 0) {
997+
flags |= WindowFlags.IS_MAXIMIZED;
998+
999+
if (Meta.MaximizeFlags.VERTICAL in maximize_flags && !(Meta.MaximizeFlags.HORIZONTAL in maximize_flags)) {
1000+
flags |= WindowFlags.IS_TILED;
1001+
}
1002+
}
1003+
1004+
if (window.allows_move ())
1005+
flags |= WindowFlags.ALLOWS_MOVE;
1006+
1007+
if (window.allows_resize ())
1008+
flags |= WindowFlags.ALLOWS_RESIZE;
1009+
1010+
if (window.is_above ())
1011+
flags |= WindowFlags.ALWAYS_ON_TOP;
1012+
1013+
if (window.on_all_workspaces)
1014+
flags |= WindowFlags.ON_ALL_WORKSPACES;
1015+
1016+
if (window.can_close ())
1017+
flags |= WindowFlags.CAN_CLOSE;
1018+
1019+
daemon_proxy.show_window_menu.begin (flags, x, y, (obj, res) => {
1020+
try {
1021+
((Daemon) obj).show_window_menu.end (res);
1022+
} catch (Error e) {
1023+
message ("Error invoking MenuManager: %s", e.message);
1024+
}
1025+
});
10321026
break;
10331027
case Meta.WindowMenuType.APP:
10341028
// FIXME we don't have any sort of app menus

0 commit comments

Comments
 (0)