mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-05 16:20:10 +00:00
Improve positioning of keyboard-activated menus with Xinerama.
Tue Jul 6 02:00:28 2004 Matthias Clasen <maclas@gmx.de> * gtk/gtkfilechooserdefault.c (popup_position_func): * gtk/gtkentry.c (popup_position_func): * gtk/gtktextview.c (popup_position_func): Improve positioning of keyboard-activated menus with Xinerama.
This commit is contained in:
parent
f7048ba1e1
commit
ed4707d505
@ -1,3 +1,10 @@
|
||||
Tue Jul 6 02:00:28 2004 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
* gtk/gtkfilechooserdefault.c (popup_position_func):
|
||||
* gtk/gtkentry.c (popup_position_func):
|
||||
* gtk/gtktextview.c (popup_position_func): Improve positioning
|
||||
of keyboard-activated menus with Xinerama.
|
||||
|
||||
Tue Jul 6 00:29:03 2004 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
* gtk/gtkuimanager.c (do_updates):
|
||||
|
@ -1,3 +1,10 @@
|
||||
Tue Jul 6 02:00:28 2004 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
* gtk/gtkfilechooserdefault.c (popup_position_func):
|
||||
* gtk/gtkentry.c (popup_position_func):
|
||||
* gtk/gtktextview.c (popup_position_func): Improve positioning
|
||||
of keyboard-activated menus with Xinerama.
|
||||
|
||||
Tue Jul 6 00:29:03 2004 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
* gtk/gtkuimanager.c (do_updates):
|
||||
|
@ -1,3 +1,10 @@
|
||||
Tue Jul 6 02:00:28 2004 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
* gtk/gtkfilechooserdefault.c (popup_position_func):
|
||||
* gtk/gtkentry.c (popup_position_func):
|
||||
* gtk/gtktextview.c (popup_position_func): Improve positioning
|
||||
of keyboard-activated menus with Xinerama.
|
||||
|
||||
Tue Jul 6 00:29:03 2004 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
* gtk/gtkuimanager.c (do_updates):
|
||||
|
@ -1,3 +1,10 @@
|
||||
Tue Jul 6 02:00:28 2004 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
* gtk/gtkfilechooserdefault.c (popup_position_func):
|
||||
* gtk/gtkentry.c (popup_position_func):
|
||||
* gtk/gtktextview.c (popup_position_func): Improve positioning
|
||||
of keyboard-activated menus with Xinerama.
|
||||
|
||||
Tue Jul 6 00:29:03 2004 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
* gtk/gtkuimanager.c (do_updates):
|
||||
|
@ -4150,18 +4150,26 @@ popup_position_func (GtkMenu *menu,
|
||||
GtkWidget *widget = GTK_WIDGET (entry);
|
||||
GdkScreen *screen = gtk_widget_get_screen (widget);
|
||||
GtkRequisition req;
|
||||
gint monitor_num;
|
||||
GdkRectangle monitor;
|
||||
|
||||
g_return_if_fail (GTK_WIDGET_REALIZED (entry));
|
||||
|
||||
gdk_window_get_origin (widget->window, x, y);
|
||||
|
||||
gdk_window_get_origin (widget->window, x, y);
|
||||
|
||||
gtk_widget_size_request (entry->popup_menu, &req);
|
||||
|
||||
*x += widget->allocation.width / 2;
|
||||
*y += widget->allocation.height;
|
||||
|
||||
*x = CLAMP (*x, 0, MAX (0, gdk_screen_get_width (screen) - req.width));
|
||||
*y = CLAMP (*y, 0, MAX (0, gdk_screen_get_height (screen) - req.height));
|
||||
monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y);
|
||||
gtk_menu_set_monitor (menu, monitor_num);
|
||||
gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
|
||||
|
||||
*x = CLAMP (*x, monitor.x, monitor.x + MAX (0, monitor.width - req.width));
|
||||
*y = CLAMP (*y, monitor.y, monitor.y + MAX (0, monitor.height - req.height));
|
||||
|
||||
*push_in = FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
@ -2713,28 +2713,57 @@ file_list_build_popup_menu (GtkFileChooserDefault *impl)
|
||||
G_CALLBACK (show_hidden_toggled_cb), impl);
|
||||
}
|
||||
|
||||
static void
|
||||
popup_position_func (GtkMenu *menu,
|
||||
gint *x,
|
||||
gint *y,
|
||||
gboolean *push_in,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkWidget *widget = GTK_WIDGET (user_data);
|
||||
GdkScreen *screen = gtk_widget_get_screen (widget);
|
||||
GtkRequisition req;
|
||||
gint monitor_num;
|
||||
GdkRectangle monitor;
|
||||
|
||||
g_return_if_fail (GTK_WIDGET_REALIZED (widget));
|
||||
|
||||
gdk_window_get_origin (widget->window, x, y);
|
||||
|
||||
gtk_widget_size_request (GTK_WIDGET (menu), &req);
|
||||
|
||||
*x += (widget->allocation.width - req.width) / 2;
|
||||
*y += (widget->allocation.height - req.height) / 2;
|
||||
|
||||
monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y);
|
||||
gtk_menu_set_monitor (menu, monitor_num);
|
||||
gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
|
||||
|
||||
*x = CLAMP (*x, monitor.x, monitor.x + MAX (0, monitor.width - req.width));
|
||||
*y = CLAMP (*y, monitor.y, monitor.y + MAX (0, monitor.height - req.height));
|
||||
|
||||
*push_in = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
file_list_popup_menu (GtkFileChooserDefault *impl,
|
||||
GdkEventButton *event)
|
||||
{
|
||||
int button;
|
||||
guint32 timestamp;
|
||||
|
||||
file_list_build_popup_menu (impl);
|
||||
if (event)
|
||||
{
|
||||
button = event->button;
|
||||
timestamp = event->time;
|
||||
}
|
||||
gtk_menu_popup (GTK_MENU (impl->browse_files_popup_menu),
|
||||
NULL, NULL, NULL, NULL,
|
||||
event->button, event->time);
|
||||
else
|
||||
{
|
||||
button = 0;
|
||||
timestamp = GDK_CURRENT_TIME;
|
||||
gtk_menu_popup (GTK_MENU (impl->browse_files_popup_menu),
|
||||
NULL, NULL,
|
||||
popup_position_func, impl->browse_files_tree_view,
|
||||
0, GDK_CURRENT_TIME);
|
||||
gtk_menu_shell_select_first (GTK_MENU_SHELL (impl->browse_files_popup_menu),
|
||||
FALSE);
|
||||
}
|
||||
|
||||
file_list_build_popup_menu (impl);
|
||||
gtk_menu_popup (GTK_MENU (impl->browse_files_popup_menu),
|
||||
NULL, NULL, NULL, NULL,
|
||||
button, timestamp);
|
||||
}
|
||||
|
||||
/* Callback used for the GtkWidget::popup-menu signal of the file list */
|
||||
|
@ -6790,7 +6790,9 @@ popup_position_func (GtkMenu *menu,
|
||||
GtkTextIter iter;
|
||||
GtkRequisition req;
|
||||
GdkScreen *screen;
|
||||
|
||||
gint monitor_num;
|
||||
GdkRectangle monitor;
|
||||
|
||||
text_view = GTK_TEXT_VIEW (user_data);
|
||||
widget = GTK_WIDGET (text_view);
|
||||
|
||||
@ -6832,13 +6834,19 @@ popup_position_func (GtkMenu *menu,
|
||||
*x = root_x + (widget->allocation.width / 2 - req.width / 2);
|
||||
*y = root_y + (widget->allocation.height / 2 - req.height / 2);
|
||||
}
|
||||
|
||||
|
||||
/* Ensure sanity */
|
||||
*x = CLAMP (*x, root_x, (root_x + widget->allocation.width));
|
||||
*y = CLAMP (*y, root_y, (root_y + widget->allocation.height));
|
||||
|
||||
*x = CLAMP (*x, 0, MAX (0, gdk_screen_get_width (screen) - req.width));
|
||||
*y = CLAMP (*y, 0, MAX (0, gdk_screen_get_height (screen) - req.height));
|
||||
monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y);
|
||||
gtk_menu_set_monitor (menu, monitor_num);
|
||||
gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
|
||||
|
||||
*x = CLAMP (*x, monitor.x, monitor.x + MAX (0, monitor.width - req.width));
|
||||
*y = CLAMP (*y, monitor.y, monitor.y + MAX (0, monitor.height - req.height));
|
||||
|
||||
*push_in = FALSE;
|
||||
}
|
||||
|
||||
typedef struct
|
||||
|
Loading…
Reference in New Issue
Block a user