erwannc 15/08/01 fix to make popup menus work fully for multidisplay apps.
erwannc 15/08/01 fix to make popup menus work fully for multidisplay apps.
This commit is contained in:
@@ -513,6 +513,7 @@ gtk_menu_popup (GtkMenu *menu,
|
||||
GtkWidget *parent;
|
||||
GdkEvent *current_event;
|
||||
GtkMenuShell *menu_shell;
|
||||
GtkMenuAttachData *attach_data;
|
||||
|
||||
g_return_if_fail (GTK_IS_MENU (menu));
|
||||
|
||||
@@ -523,6 +524,17 @@ gtk_menu_popup (GtkMenu *menu,
|
||||
menu_shell->active = TRUE;
|
||||
menu_shell->button = button;
|
||||
|
||||
attach_data = gtk_object_get_data (GTK_OBJECT (menu), attach_data_key);
|
||||
if (!attach_data)
|
||||
{
|
||||
g_warning ("gtk_menu_popup No GtkMenuAttachData present\n\
|
||||
impossible to determine which screen to display on\n");
|
||||
return;
|
||||
}
|
||||
|
||||
gtk_window_set_screen (GTK_WINDOW (menu->toplevel),
|
||||
gtk_widget_get_screen (attach_data->attach_widget));
|
||||
|
||||
/* If we are popping up the menu from something other than, a button
|
||||
* press then, as a heuristic, we ignore enter events for the menu
|
||||
* until we get a MOTION_NOTIFY.
|
||||
@@ -1000,6 +1012,8 @@ gtk_menu_realize (GtkWidget *widget)
|
||||
|
||||
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
|
||||
|
||||
|
||||
|
||||
attributes.window_type = GDK_WINDOW_CHILD;
|
||||
attributes.x = widget->allocation.x;
|
||||
attributes.y = widget->allocation.y;
|
||||
|
||||
@@ -379,7 +379,7 @@ static char radio_text_bits[] = {
|
||||
|
||||
static struct {
|
||||
char *bits;
|
||||
GdkBitmap *bmap;
|
||||
GList *bmap_screen_list; /* list of GdkBitmap */
|
||||
} indicator_parts[] = {
|
||||
{ check_aa_bits, NULL },
|
||||
{ check_base_bits, NULL },
|
||||
@@ -1774,6 +1774,26 @@ sanitize_size (GdkWindow *window,
|
||||
return set_bg;
|
||||
}
|
||||
|
||||
static GdkBitmap *
|
||||
get_indicator_for_screen (GdkScreen *screen,
|
||||
IndicatorPart part,
|
||||
GdkDrawable *drawable)
|
||||
{
|
||||
GdkBitmap * new_bmap;
|
||||
GList *tmp_list = indicator_parts[part].bmap_screen_list;
|
||||
while (tmp_list)
|
||||
{
|
||||
if (gdk_drawable_get_screen ((GdkBitmap *)tmp_list->data) == screen)
|
||||
return (GdkBitmap *)tmp_list->data;
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
new_bmap = gdk_bitmap_create_from_data (drawable,
|
||||
indicator_parts[part].bits,
|
||||
INDICATOR_PART_SIZE, INDICATOR_PART_SIZE);
|
||||
g_list_append (indicator_parts[part].bmap_screen_list, (gpointer) new_bmap);
|
||||
return new_bmap;
|
||||
}
|
||||
|
||||
static void
|
||||
draw_part (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
@@ -1782,16 +1802,15 @@ draw_part (GdkDrawable *drawable,
|
||||
gint y,
|
||||
IndicatorPart part)
|
||||
{
|
||||
GdkBitmap *indicator_bmap;
|
||||
if (area)
|
||||
gdk_gc_set_clip_rectangle (gc, area);
|
||||
|
||||
if (!indicator_parts[part].bmap)
|
||||
indicator_parts[part].bmap = gdk_bitmap_create_from_data (drawable,
|
||||
indicator_parts[part].bits,
|
||||
INDICATOR_PART_SIZE, INDICATOR_PART_SIZE);
|
||||
indicator_bmap = get_indicator_for_screen (gdk_drawable_get_screen (drawable),
|
||||
part, drawable);
|
||||
|
||||
gdk_gc_set_ts_origin (gc, x, y);
|
||||
gdk_gc_set_stipple (gc, indicator_parts[part].bmap);
|
||||
gdk_gc_set_stipple (gc, indicator_bmap);
|
||||
gdk_gc_set_fill (gc, GDK_STIPPLED);
|
||||
|
||||
gdk_draw_rectangle (drawable, gc, TRUE, x, y, INDICATOR_PART_SIZE, INDICATOR_PART_SIZE);
|
||||
|
||||
@@ -155,7 +155,7 @@ main (int argc, char *argv[])
|
||||
entry = gtk_widget_new (gtk_entry_get_type (),
|
||||
"GtkWidget::visible", TRUE, NULL);
|
||||
entry2 = gtk_widget_new (gtk_entry_get_type (),
|
||||
"screen", scr2, "GtkWidget::visible", TRUE, NULL);
|
||||
"GtkWidget::visible", TRUE, NULL);
|
||||
|
||||
/* for default display */
|
||||
make_selection_dialog (NULL, entry2, entry);
|
||||
|
||||
Reference in New Issue
Block a user