mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-05 16:20:10 +00:00
Changes to improve menu positioning on Xinerama (#108328):
Wed Nov 12 21:40:10 2003 Matthias Clasen <maclas@gmx.de> Changes to improve menu positioning on Xinerama (#108328): * gtk/gtkmenu.c (struct _GtkMenuPrivate): Add a menu_num field to store the monitor on which the menu is to be positioned. * gtk/gtkmenu.[hc] (gtk_menu_position): Store the monitor number in the GtkMenuPrivate struct and fetch the monitor geometry after calling the position_func, in case it has been changed. * gtk/gtkmenu.c (gtk_menu_set_monitor): New function to be used in GtkMenuPositionFunc implementations for setting the monitor_num field in GtkMenuPrivate. * gtk/gtkmenuitem.c (gtk_menu_item_position_menu): Call gtk_menu_set_monitor.
This commit is contained in:
parent
f3c0fd5991
commit
e71bcc8487
18
ChangeLog
18
ChangeLog
@ -1,3 +1,21 @@
|
||||
Wed Nov 12 21:40:10 2003 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
Changes to improve menu positioning on Xinerama (#108328):
|
||||
|
||||
* gtk/gtkmenu.c (struct _GtkMenuPrivate): Add a menu_num field
|
||||
to store the monitor on which the menu is to be positioned.
|
||||
|
||||
* gtk/gtkmenu.[hc] (gtk_menu_position): Store the monitor number
|
||||
in the GtkMenuPrivate struct and fetch the monitor geometry after
|
||||
calling the position_func, in case it has been changed.
|
||||
|
||||
* gtk/gtkmenu.c (gtk_menu_set_monitor): New function
|
||||
to be used in GtkMenuPositionFunc implementations for setting
|
||||
the monitor_num field in GtkMenuPrivate.
|
||||
|
||||
* gtk/gtkmenuitem.c (gtk_menu_item_position_menu): Call
|
||||
gtk_menu_set_monitor.
|
||||
|
||||
Wed Nov 12 21:00:10 2003 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
* gtk/gtkinputdialog.c (gtk_input_dialog_init): Clarify the
|
||||
|
@ -1,3 +1,21 @@
|
||||
Wed Nov 12 21:40:10 2003 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
Changes to improve menu positioning on Xinerama (#108328):
|
||||
|
||||
* gtk/gtkmenu.c (struct _GtkMenuPrivate): Add a menu_num field
|
||||
to store the monitor on which the menu is to be positioned.
|
||||
|
||||
* gtk/gtkmenu.[hc] (gtk_menu_position): Store the monitor number
|
||||
in the GtkMenuPrivate struct and fetch the monitor geometry after
|
||||
calling the position_func, in case it has been changed.
|
||||
|
||||
* gtk/gtkmenu.c (gtk_menu_set_monitor): New function
|
||||
to be used in GtkMenuPositionFunc implementations for setting
|
||||
the monitor_num field in GtkMenuPrivate.
|
||||
|
||||
* gtk/gtkmenuitem.c (gtk_menu_item_position_menu): Call
|
||||
gtk_menu_set_monitor.
|
||||
|
||||
Wed Nov 12 21:00:10 2003 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
* gtk/gtkinputdialog.c (gtk_input_dialog_init): Clarify the
|
||||
|
@ -1,3 +1,21 @@
|
||||
Wed Nov 12 21:40:10 2003 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
Changes to improve menu positioning on Xinerama (#108328):
|
||||
|
||||
* gtk/gtkmenu.c (struct _GtkMenuPrivate): Add a menu_num field
|
||||
to store the monitor on which the menu is to be positioned.
|
||||
|
||||
* gtk/gtkmenu.[hc] (gtk_menu_position): Store the monitor number
|
||||
in the GtkMenuPrivate struct and fetch the monitor geometry after
|
||||
calling the position_func, in case it has been changed.
|
||||
|
||||
* gtk/gtkmenu.c (gtk_menu_set_monitor): New function
|
||||
to be used in GtkMenuPositionFunc implementations for setting
|
||||
the monitor_num field in GtkMenuPrivate.
|
||||
|
||||
* gtk/gtkmenuitem.c (gtk_menu_item_position_menu): Call
|
||||
gtk_menu_set_monitor.
|
||||
|
||||
Wed Nov 12 21:00:10 2003 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
* gtk/gtkinputdialog.c (gtk_input_dialog_init): Clarify the
|
||||
|
@ -1,3 +1,21 @@
|
||||
Wed Nov 12 21:40:10 2003 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
Changes to improve menu positioning on Xinerama (#108328):
|
||||
|
||||
* gtk/gtkmenu.c (struct _GtkMenuPrivate): Add a menu_num field
|
||||
to store the monitor on which the menu is to be positioned.
|
||||
|
||||
* gtk/gtkmenu.[hc] (gtk_menu_position): Store the monitor number
|
||||
in the GtkMenuPrivate struct and fetch the monitor geometry after
|
||||
calling the position_func, in case it has been changed.
|
||||
|
||||
* gtk/gtkmenu.c (gtk_menu_set_monitor): New function
|
||||
to be used in GtkMenuPositionFunc implementations for setting
|
||||
the monitor_num field in GtkMenuPrivate.
|
||||
|
||||
* gtk/gtkmenuitem.c (gtk_menu_item_position_menu): Call
|
||||
gtk_menu_set_monitor.
|
||||
|
||||
Wed Nov 12 21:00:10 2003 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
* gtk/gtkinputdialog.c (gtk_input_dialog_init): Clarify the
|
||||
|
@ -1,3 +1,21 @@
|
||||
Wed Nov 12 21:40:10 2003 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
Changes to improve menu positioning on Xinerama (#108328):
|
||||
|
||||
* gtk/gtkmenu.c (struct _GtkMenuPrivate): Add a menu_num field
|
||||
to store the monitor on which the menu is to be positioned.
|
||||
|
||||
* gtk/gtkmenu.[hc] (gtk_menu_position): Store the monitor number
|
||||
in the GtkMenuPrivate struct and fetch the monitor geometry after
|
||||
calling the position_func, in case it has been changed.
|
||||
|
||||
* gtk/gtkmenu.c (gtk_menu_set_monitor): New function
|
||||
to be used in GtkMenuPositionFunc implementations for setting
|
||||
the monitor_num field in GtkMenuPrivate.
|
||||
|
||||
* gtk/gtkmenuitem.c (gtk_menu_item_position_menu): Call
|
||||
gtk_menu_set_monitor.
|
||||
|
||||
Wed Nov 12 21:00:10 2003 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
* gtk/gtkinputdialog.c (gtk_input_dialog_init): Clarify the
|
||||
|
@ -1,3 +1,7 @@
|
||||
Wed Nov 12 21:52:35 2003 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
* gtk/gtk-sections.txt: Add gtk_menu_set_monitor.
|
||||
|
||||
Fri Oct 24 13:15:32 2003 Soeren Sandmann <sandmann@daimi.au.dk>
|
||||
|
||||
* gtk/tmpl/gtktoolbar.sgml, gtk/tmpl/gtkseparatortoolitem.sgml:
|
||||
|
@ -1865,6 +1865,7 @@ gtk_menu_detach
|
||||
gtk_menu_get_attach_widget
|
||||
GtkMenuPositionFunc
|
||||
GtkMenuDetachFunc
|
||||
gtk_menu_set_monitor
|
||||
<SUBSECTION Standard>
|
||||
GTK_MENU
|
||||
GTK_IS_MENU
|
||||
|
@ -84,6 +84,8 @@ struct _GtkMenuPrivate
|
||||
|
||||
guint *heights;
|
||||
gint heights_length;
|
||||
|
||||
gint monitor_num;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
@ -3064,7 +3066,6 @@ gtk_menu_position (GtkMenu *menu)
|
||||
GdkScreen *screen;
|
||||
GdkScreen *pointer_screen;
|
||||
GdkRectangle monitor;
|
||||
gint monitor_num;
|
||||
|
||||
g_return_if_fail (GTK_IS_MENU (menu));
|
||||
|
||||
@ -3092,13 +3093,16 @@ gtk_menu_position (GtkMenu *menu)
|
||||
y = MAX (0, (gdk_screen_get_height (screen) - requisition.height) / 2);
|
||||
}
|
||||
|
||||
monitor_num = gdk_screen_get_monitor_at_point (screen, x, y);
|
||||
gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
|
||||
private = gtk_menu_get_private (menu);
|
||||
private->monitor_num = gdk_screen_get_monitor_at_point (screen, x, y);
|
||||
|
||||
push_in = FALSE;
|
||||
|
||||
if (menu->position_func)
|
||||
(* menu->position_func) (menu, &x, &y, &push_in, menu->position_func_data);
|
||||
{
|
||||
(* menu->position_func) (menu, &x, &y, &push_in, menu->position_func_data);
|
||||
gdk_screen_get_monitor_geometry (screen, private->monitor_num, &monitor);
|
||||
}
|
||||
else
|
||||
{
|
||||
gint space_left, space_right, space_above, space_below;
|
||||
@ -3126,6 +3130,8 @@ gtk_menu_position (GtkMenu *menu)
|
||||
* Positioning in the vertical direction is similar: first try below
|
||||
* mouse cursor, then above.
|
||||
*/
|
||||
gdk_screen_get_monitor_geometry (screen, private->monitor_num, &monitor);
|
||||
|
||||
space_left = x - monitor.x;
|
||||
space_right = monitor.x + monitor.width - x - 1;
|
||||
space_above = y - monitor.y;
|
||||
@ -3239,7 +3245,6 @@ gtk_menu_position (GtkMenu *menu)
|
||||
|
||||
if (GTK_MENU_SHELL (menu)->active)
|
||||
{
|
||||
private = gtk_menu_get_private (menu);
|
||||
private->have_position = TRUE;
|
||||
private->x = x;
|
||||
private->y = y;
|
||||
@ -3957,3 +3962,32 @@ gtk_menu_real_move_scroll (GtkMenu *menu,
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gtk_menu_set_monitor:
|
||||
* @menu: a #GtkMenu
|
||||
* @monitor_num: the number of the monitor on which the menu should
|
||||
* be popped up
|
||||
*
|
||||
* Informs GTK+ on which monitor a menu should be popped up.
|
||||
* See gdk_screen_get_monitor_geometry().
|
||||
*
|
||||
* This function should be called from a #GtkMenuPositionFunc if the
|
||||
* menu should not appear on the same monitor as the pointer. This
|
||||
* information can't be reliably inferred from the coordinates returned
|
||||
* by a #GtkMenuPositionFunc, since, for very long menus, these coordinates
|
||||
* may extend beyond the monitor boundaries or even the screen boundaries.
|
||||
*
|
||||
* Since: 2.4
|
||||
**/
|
||||
void gtk_menu_set_monitor (GtkMenu *menu,
|
||||
gint monitor_num)
|
||||
{
|
||||
GtkMenuPrivate *priv;
|
||||
g_return_if_fail (GTK_IS_MENU (menu));
|
||||
|
||||
priv = gtk_menu_get_private (menu);
|
||||
|
||||
priv->monitor_num = monitor_num;
|
||||
}
|
||||
|
@ -196,6 +196,8 @@ void gtk_menu_attach (GtkMenu *menu,
|
||||
guint top_attach,
|
||||
guint bottom_attach);
|
||||
|
||||
void gtk_menu_set_monitor (GtkMenu *menu,
|
||||
gint monitor_num);
|
||||
|
||||
#ifndef GTK_DISABLE_DEPRECATED
|
||||
#define gtk_menu_append(menu,child) gtk_menu_shell_append ((GtkMenuShell *)(menu),(child))
|
||||
|
@ -1108,6 +1108,8 @@ gtk_menu_item_position_menu (GtkMenu *menu,
|
||||
*/
|
||||
*x = CLAMP (tx, monitor.x, MAX (monitor.x, monitor.x + monitor.width - twidth));
|
||||
*y = ty;
|
||||
|
||||
gtk_menu_set_monitor (menu, monitor_num);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user