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:

committed by
Matthias Clasen

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>
|
Wed Nov 12 21:00:10 2003 Matthias Clasen <maclas@gmx.de>
|
||||||
|
|
||||||
* gtk/gtkinputdialog.c (gtk_input_dialog_init): Clarify the
|
* 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>
|
Wed Nov 12 21:00:10 2003 Matthias Clasen <maclas@gmx.de>
|
||||||
|
|
||||||
* gtk/gtkinputdialog.c (gtk_input_dialog_init): Clarify the
|
* 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>
|
Wed Nov 12 21:00:10 2003 Matthias Clasen <maclas@gmx.de>
|
||||||
|
|
||||||
* gtk/gtkinputdialog.c (gtk_input_dialog_init): Clarify the
|
* 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>
|
Wed Nov 12 21:00:10 2003 Matthias Clasen <maclas@gmx.de>
|
||||||
|
|
||||||
* gtk/gtkinputdialog.c (gtk_input_dialog_init): Clarify the
|
* 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>
|
Wed Nov 12 21:00:10 2003 Matthias Clasen <maclas@gmx.de>
|
||||||
|
|
||||||
* gtk/gtkinputdialog.c (gtk_input_dialog_init): Clarify the
|
* 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>
|
Fri Oct 24 13:15:32 2003 Soeren Sandmann <sandmann@daimi.au.dk>
|
||||||
|
|
||||||
* gtk/tmpl/gtktoolbar.sgml, gtk/tmpl/gtkseparatortoolitem.sgml:
|
* gtk/tmpl/gtktoolbar.sgml, gtk/tmpl/gtkseparatortoolitem.sgml:
|
||||||
|
@ -1865,6 +1865,7 @@ gtk_menu_detach
|
|||||||
gtk_menu_get_attach_widget
|
gtk_menu_get_attach_widget
|
||||||
GtkMenuPositionFunc
|
GtkMenuPositionFunc
|
||||||
GtkMenuDetachFunc
|
GtkMenuDetachFunc
|
||||||
|
gtk_menu_set_monitor
|
||||||
<SUBSECTION Standard>
|
<SUBSECTION Standard>
|
||||||
GTK_MENU
|
GTK_MENU
|
||||||
GTK_IS_MENU
|
GTK_IS_MENU
|
||||||
|
@ -84,6 +84,8 @@ struct _GtkMenuPrivate
|
|||||||
|
|
||||||
guint *heights;
|
guint *heights;
|
||||||
gint heights_length;
|
gint heights_length;
|
||||||
|
|
||||||
|
gint monitor_num;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
@ -3064,7 +3066,6 @@ gtk_menu_position (GtkMenu *menu)
|
|||||||
GdkScreen *screen;
|
GdkScreen *screen;
|
||||||
GdkScreen *pointer_screen;
|
GdkScreen *pointer_screen;
|
||||||
GdkRectangle monitor;
|
GdkRectangle monitor;
|
||||||
gint monitor_num;
|
|
||||||
|
|
||||||
g_return_if_fail (GTK_IS_MENU (menu));
|
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);
|
y = MAX (0, (gdk_screen_get_height (screen) - requisition.height) / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
monitor_num = gdk_screen_get_monitor_at_point (screen, x, y);
|
private = gtk_menu_get_private (menu);
|
||||||
gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
|
private->monitor_num = gdk_screen_get_monitor_at_point (screen, x, y);
|
||||||
|
|
||||||
push_in = FALSE;
|
push_in = FALSE;
|
||||||
|
|
||||||
if (menu->position_func)
|
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
|
else
|
||||||
{
|
{
|
||||||
gint space_left, space_right, space_above, space_below;
|
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
|
* Positioning in the vertical direction is similar: first try below
|
||||||
* mouse cursor, then above.
|
* mouse cursor, then above.
|
||||||
*/
|
*/
|
||||||
|
gdk_screen_get_monitor_geometry (screen, private->monitor_num, &monitor);
|
||||||
|
|
||||||
space_left = x - monitor.x;
|
space_left = x - monitor.x;
|
||||||
space_right = monitor.x + monitor.width - x - 1;
|
space_right = monitor.x + monitor.width - x - 1;
|
||||||
space_above = y - monitor.y;
|
space_above = y - monitor.y;
|
||||||
@ -3239,7 +3245,6 @@ gtk_menu_position (GtkMenu *menu)
|
|||||||
|
|
||||||
if (GTK_MENU_SHELL (menu)->active)
|
if (GTK_MENU_SHELL (menu)->active)
|
||||||
{
|
{
|
||||||
private = gtk_menu_get_private (menu);
|
|
||||||
private->have_position = TRUE;
|
private->have_position = TRUE;
|
||||||
private->x = x;
|
private->x = x;
|
||||||
private->y = y;
|
private->y = y;
|
||||||
@ -3957,3 +3962,32 @@ gtk_menu_real_move_scroll (GtkMenu *menu,
|
|||||||
break;
|
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 top_attach,
|
||||||
guint bottom_attach);
|
guint bottom_attach);
|
||||||
|
|
||||||
|
void gtk_menu_set_monitor (GtkMenu *menu,
|
||||||
|
gint monitor_num);
|
||||||
|
|
||||||
#ifndef GTK_DISABLE_DEPRECATED
|
#ifndef GTK_DISABLE_DEPRECATED
|
||||||
#define gtk_menu_append(menu,child) gtk_menu_shell_append ((GtkMenuShell *)(menu),(child))
|
#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));
|
*x = CLAMP (tx, monitor.x, MAX (monitor.x, monitor.x + monitor.width - twidth));
|
||||||
*y = ty;
|
*y = ty;
|
||||||
|
|
||||||
|
gtk_menu_set_monitor (menu, monitor_num);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user