[gnome-panel] applet: fix menu location on multi-monitor setup
- From: Sebastian Geiger <segeiger src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel] applet: fix menu location on multi-monitor setup
- Date: Tue, 9 Feb 2016 10:45:41 +0000 (UTC)
commit 87cc051e35087ba2cd19c287a9d4a331634c668f
Author: Timo Kluck <tkluck infty nl>
Date: Wed Oct 9 21:16:20 2013 +0200
applet: fix menu location on multi-monitor setup
The main menu should open upward if the applet is in the bottom half of the monitor,
and downward if the applet is in the upper half of the monitor (similarly for left/right).
Calculating the position based on screen size results in wrong placement on setups where
monitors have different size or rotation. Therefore the menu should open towards the middle
of the monitor not the screen.
https://bugzilla.gnome.org/show_bug.cgi?id=614572
gnome-panel/applet.c | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/gnome-panel/applet.c b/gnome-panel/applet.c
index eaea161..a776fe1 100644
--- a/gnome-panel/applet.c
+++ b/gnome-panel/applet.c
@@ -548,6 +548,8 @@ panel_applet_position_menu (GtkMenu *menu,
int menu_y = 0;
int pointer_x;
int pointer_y;
+ int monitor_num;
+ GdkRectangle monitor_rect;
parent = gtk_widget_get_parent (applet);
@@ -570,6 +572,9 @@ panel_applet_position_menu (GtkMenu *menu,
menu_y += allocation.y;
}
+ monitor_num = gdk_screen_get_monitor_at_point (screen,menu_x,menu_y);
+ gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor_rect);
+
if (PANEL_WIDGET (parent)->orient == GTK_ORIENTATION_HORIZONTAL) {
if (gtk_widget_get_direction (GTK_WIDGET (menu)) != GTK_TEXT_DIR_RTL) {
if (pointer_x < allocation.width &&
@@ -584,9 +589,9 @@ panel_applet_position_menu (GtkMenu *menu,
allocation.width - requisition.width);
}
}
- menu_x = MIN (menu_x, gdk_screen_get_width (screen) - requisition.width);
+ menu_x = MIN (menu_x, monitor_rect.x + monitor_rect.width - requisition.width);
- if (menu_y > gdk_screen_get_height (screen) / 2)
+ if (menu_y > monitor_rect.y + (monitor_rect.height / 2))
menu_y -= requisition.height;
else
menu_y += allocation.height;
@@ -594,9 +599,9 @@ panel_applet_position_menu (GtkMenu *menu,
if (pointer_y < allocation.height &&
requisition.height < pointer_y)
menu_y += MIN (pointer_y, allocation.height - requisition.height);
- menu_y = MIN (menu_y, gdk_screen_get_height (screen) - requisition.height);
+ menu_y = MIN (menu_y, monitor_rect.y +monitor_rect.height - requisition.height);
- if (menu_x > gdk_screen_get_width (screen) / 2)
+ if (menu_x > monitor_rect.x + (monitor_rect.width / 2))
menu_x -= requisition.width;
else
menu_x += allocation.width;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]