mirror of
https://github.com/elementary/gala.git
synced 2024-08-16 18:40:27 +03:00
Fix scale + cleanup
This commit is contained in:
parent
5742055d4b
commit
8a8cb84fdb
@ -51,9 +51,6 @@ namespace Gala {
|
|||||||
private Gtk.MenuItem close;
|
private Gtk.MenuItem close;
|
||||||
private Gtk.MenuItem screenshot;
|
private Gtk.MenuItem screenshot;
|
||||||
|
|
||||||
// Desktop Menu
|
|
||||||
private Gtk.Menu? desktop_menu = null;
|
|
||||||
|
|
||||||
private WMDBus? wm_proxy = null;
|
private WMDBus? wm_proxy = null;
|
||||||
|
|
||||||
private ulong always_on_top_sid = 0U;
|
private ulong always_on_top_sid = 0U;
|
||||||
@ -292,76 +289,5 @@ namespace Gala {
|
|||||||
return opened ? Source.REMOVE : Source.CONTINUE;
|
return opened ? Source.REMOVE : Source.CONTINUE;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void show_desktop_menu (int x, int y) throws DBusError, IOError {
|
|
||||||
if (desktop_menu == null) {
|
|
||||||
var change_wallpaper = new Gtk.MenuItem.with_label (_("Change Wallpaper…"));
|
|
||||||
change_wallpaper.activate.connect (() => {
|
|
||||||
try {
|
|
||||||
AppInfo.launch_default_for_uri ("settings://desktop/appearance/wallpaper", null);
|
|
||||||
} catch (Error e) {
|
|
||||||
var message_dialog = new Granite.MessageDialog.with_image_from_icon_name (
|
|
||||||
"Failed to Open Wallpaper Settings",
|
|
||||||
"Unable to open System Settings. A handler for the `settings://` URI scheme must be installed.",
|
|
||||||
"dialog-error",
|
|
||||||
Gtk.ButtonsType.CLOSE
|
|
||||||
);
|
|
||||||
message_dialog.show_error_details (e.message);
|
|
||||||
message_dialog.run ();
|
|
||||||
message_dialog.destroy ();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
var display_settings = new Gtk.MenuItem.with_label (_("Display Settings…"));
|
|
||||||
display_settings.activate.connect (() => {
|
|
||||||
try {
|
|
||||||
AppInfo.launch_default_for_uri ("settings://display", null);
|
|
||||||
} catch (Error e) {
|
|
||||||
var message_dialog = new Granite.MessageDialog.with_image_from_icon_name (
|
|
||||||
"Failed to Open Display Settings",
|
|
||||||
"Unable to open System Settings. A handler for the `settings://` URI scheme must be installed.",
|
|
||||||
"dialog-warning",
|
|
||||||
Gtk.ButtonsType.CLOSE
|
|
||||||
);
|
|
||||||
message_dialog.show_error_details (e.message);
|
|
||||||
message_dialog.run ();
|
|
||||||
message_dialog.destroy ();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
var system_settings = new Gtk.MenuItem.with_label (_("System Settings…"));
|
|
||||||
system_settings.activate.connect (() => {
|
|
||||||
try {
|
|
||||||
AppInfo.launch_default_for_uri ("settings://", null);
|
|
||||||
} catch (Error e) {
|
|
||||||
var message_dialog = new Granite.MessageDialog.with_image_from_icon_name (
|
|
||||||
"Failed to Open System Settings",
|
|
||||||
"Unable to open System Settings. A handler for the `settings://` URI scheme must be installed.",
|
|
||||||
"dialog-warning",
|
|
||||||
Gtk.ButtonsType.CLOSE
|
|
||||||
);
|
|
||||||
message_dialog.show_error_details (e.message);
|
|
||||||
message_dialog.run ();
|
|
||||||
message_dialog.destroy ();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
desktop_menu = new Gtk.Menu ();
|
|
||||||
desktop_menu.append (change_wallpaper);
|
|
||||||
desktop_menu.append (display_settings);
|
|
||||||
desktop_menu.append (new Gtk.SeparatorMenuItem ());
|
|
||||||
desktop_menu.append (system_settings);
|
|
||||||
desktop_menu.show_all ();
|
|
||||||
}
|
|
||||||
|
|
||||||
desktop_menu.popup (null, null, (m, ref px, ref py, out push_in) => {
|
|
||||||
var scale = m.scale_factor;
|
|
||||||
px = x / scale;
|
|
||||||
// Move the menu 1 pixel outside of the pointer or else it closes instantly
|
|
||||||
// on the mouse up event
|
|
||||||
py = (y / scale) + 1;
|
|
||||||
push_in = false;
|
|
||||||
}, Gdk.BUTTON_SECONDARY, Gdk.CURRENT_TIME);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ public class Gala.Menu : Clutter.Actor {
|
|||||||
|
|
||||||
container.margin_top = container.margin_bottom = InternalUtils.scale_to_int (6, scale_factor);
|
container.margin_top = container.margin_bottom = InternalUtils.scale_to_int (6, scale_factor);
|
||||||
|
|
||||||
foreach (var child in get_children ()) {
|
foreach (var child in container.get_children ()) {
|
||||||
if (child is MenuItem) {
|
if (child is MenuItem) {
|
||||||
((MenuItem) child).scale (scale_factor);
|
((MenuItem) child).scale (scale_factor);
|
||||||
continue;
|
continue;
|
||||||
|
@ -22,7 +22,6 @@ namespace Gala {
|
|||||||
[DBus (name = "org.pantheon.gala.daemon")]
|
[DBus (name = "org.pantheon.gala.daemon")]
|
||||||
public interface Daemon: GLib.Object {
|
public interface Daemon: GLib.Object {
|
||||||
public abstract async void show_window_menu (WindowFlags flags, int x, int y) throws Error;
|
public abstract async void show_window_menu (WindowFlags flags, int x, int y) throws Error;
|
||||||
public abstract async void show_desktop_menu (int x, int y) throws Error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class WindowManagerGala : Meta.Plugin, WindowManager {
|
public class WindowManagerGala : Meta.Plugin, WindowManager {
|
||||||
@ -982,53 +981,48 @@ namespace Gala {
|
|||||||
public override void show_window_menu (Meta.Window window, Meta.WindowMenuType menu, int x, int y) {
|
public override void show_window_menu (Meta.Window window, Meta.WindowMenuType menu, int x, int y) {
|
||||||
switch (menu) {
|
switch (menu) {
|
||||||
case Meta.WindowMenuType.WM:
|
case Meta.WindowMenuType.WM:
|
||||||
warning ("CREATE MENU");
|
if (daemon_proxy == null || window.get_window_type () == Meta.WindowType.NOTIFICATION) {
|
||||||
var window_menu = new BackgroundMenu (this);
|
return;
|
||||||
ui_group.add_child (window_menu);
|
}
|
||||||
window_menu.set_position (x, y);
|
|
||||||
window_menu.open_menu ();
|
|
||||||
// if (daemon_proxy == null || window.get_window_type () == Meta.WindowType.NOTIFICATION) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// WindowFlags flags = WindowFlags.NONE;
|
WindowFlags flags = WindowFlags.NONE;
|
||||||
// if (window.can_minimize ())
|
if (window.can_minimize ())
|
||||||
// flags |= WindowFlags.CAN_HIDE;
|
flags |= WindowFlags.CAN_HIDE;
|
||||||
|
|
||||||
// if (window.can_maximize ())
|
if (window.can_maximize ())
|
||||||
// flags |= WindowFlags.CAN_MAXIMIZE;
|
flags |= WindowFlags.CAN_MAXIMIZE;
|
||||||
|
|
||||||
// var maximize_flags = window.get_maximized ();
|
var maximize_flags = window.get_maximized ();
|
||||||
// if (maximize_flags > 0) {
|
if (maximize_flags > 0) {
|
||||||
// flags |= WindowFlags.IS_MAXIMIZED;
|
flags |= WindowFlags.IS_MAXIMIZED;
|
||||||
|
|
||||||
// if (Meta.MaximizeFlags.VERTICAL in maximize_flags && !(Meta.MaximizeFlags.HORIZONTAL in maximize_flags)) {
|
if (Meta.MaximizeFlags.VERTICAL in maximize_flags && !(Meta.MaximizeFlags.HORIZONTAL in maximize_flags)) {
|
||||||
// flags |= WindowFlags.IS_TILED;
|
flags |= WindowFlags.IS_TILED;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// if (window.allows_move ())
|
if (window.allows_move ())
|
||||||
// flags |= WindowFlags.ALLOWS_MOVE;
|
flags |= WindowFlags.ALLOWS_MOVE;
|
||||||
|
|
||||||
// if (window.allows_resize ())
|
if (window.allows_resize ())
|
||||||
// flags |= WindowFlags.ALLOWS_RESIZE;
|
flags |= WindowFlags.ALLOWS_RESIZE;
|
||||||
|
|
||||||
// if (window.is_above ())
|
if (window.is_above ())
|
||||||
// flags |= WindowFlags.ALWAYS_ON_TOP;
|
flags |= WindowFlags.ALWAYS_ON_TOP;
|
||||||
|
|
||||||
// if (window.on_all_workspaces)
|
if (window.on_all_workspaces)
|
||||||
// flags |= WindowFlags.ON_ALL_WORKSPACES;
|
flags |= WindowFlags.ON_ALL_WORKSPACES;
|
||||||
|
|
||||||
// if (window.can_close ())
|
if (window.can_close ())
|
||||||
// flags |= WindowFlags.CAN_CLOSE;
|
flags |= WindowFlags.CAN_CLOSE;
|
||||||
|
|
||||||
// daemon_proxy.show_window_menu.begin (flags, x, y, (obj, res) => {
|
daemon_proxy.show_window_menu.begin (flags, x, y, (obj, res) => {
|
||||||
// try {
|
try {
|
||||||
// ((Daemon) obj).show_window_menu.end (res);
|
((Daemon) obj).show_window_menu.end (res);
|
||||||
// } catch (Error e) {
|
} catch (Error e) {
|
||||||
// message ("Error invoking MenuManager: %s", e.message);
|
message ("Error invoking MenuManager: %s", e.message);
|
||||||
// }
|
}
|
||||||
// });
|
});
|
||||||
break;
|
break;
|
||||||
case Meta.WindowMenuType.APP:
|
case Meta.WindowMenuType.APP:
|
||||||
// FIXME we don't have any sort of app menus
|
// FIXME we don't have any sort of app menus
|
||||||
|
Loading…
Reference in New Issue
Block a user