API: gdk: Add gdk_window_new_temp()

Your one stop shop for all those nasty hidden input-only windows.
This commit is contained in:
Benjamin Otte 2016-11-07 01:03:17 +01:00
parent 24d0baec38
commit 3b93773add
7 changed files with 41 additions and 79 deletions

View File

@ -1290,28 +1290,13 @@ static void
create_moveresize_window (MoveResizeData *mv_resize,
guint32 timestamp)
{
GdkWindowAttr attributes;
gint attributes_mask;
GdkGrabStatus status;
GdkSeat *seat;
GdkDevice *pointer;
g_assert (mv_resize->moveresize_emulation_window == NULL);
attributes.x = -100;
attributes.y = -100;
attributes.width = 10;
attributes.height = 10;
attributes.window_type = GDK_WINDOW_TEMP;
attributes.wclass = GDK_INPUT_ONLY;
attributes.event_mask = 0;
attributes_mask = GDK_WA_X | GDK_WA_Y;
mv_resize->moveresize_emulation_window =
gdk_window_new (gdk_screen_get_root_window (gdk_display_get_default_screen (mv_resize->display)),
&attributes,
attributes_mask);
mv_resize->moveresize_emulation_window = gdk_window_new_temp (mv_resize->display);
gdk_window_show (mv_resize->moveresize_emulation_window);

View File

@ -1365,6 +1365,40 @@ gdk_window_new_popup (GdkDisplay *display,
&attr,
GDK_WA_X | GDK_WA_Y);
}
/**
* gdk_window_new_temp: (constructor)
* @display: the display to create the window on
*
* Creates a new toplevel temporary window. The window will be
* situated off-screen and not handle output.
*
* You most likely do not want to use this function.
*
* Returns: (transfer full): the new #GdkWindow
*
* Since: 3.90
**/
GdkWindow *
gdk_window_new_temp (GdkDisplay *display)
{
GdkWindowAttr attr;
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
attr.event_mask = 0;
attr.wclass = GDK_INPUT_ONLY;
attr.x = -100;
attr.y = -100;
attr.width = 10;
attr.height = 10;
attr.window_type = GDK_WINDOW_TEMP;
return gdk_window_new (gdk_screen_get_root_window (gdk_display_get_default_screen (display)),
&attr,
GDK_WA_X | GDK_WA_Y);
}
/**
* gdk_window_new_child: (constructor)
* @parent: the parent window

View File

@ -475,6 +475,8 @@ GdkWindow * gdk_window_new_popup (GdkDisplay *display,
gint event_mask,
const GdkRectangle *position);
GDK_AVAILABLE_IN_3_90
GdkWindow * gdk_window_new_temp (GdkDisplay *display);
GDK_AVAILABLE_IN_3_90
GdkWindow * gdk_window_new_child (GdkWindow *parent,
gint event_mask,
const GdkRectangle *position);

View File

@ -1356,7 +1356,6 @@ _gdk_x11_display_open (const gchar *display_name)
Display *xdisplay;
GdkDisplay *display;
GdkX11Display *display_x11;
GdkWindowAttr attr;
gint argc;
gchar *argv[1];
@ -1417,16 +1416,7 @@ _gdk_x11_display_open (const gchar *display_name)
gdk_event_init (display);
attr.window_type = GDK_WINDOW_TOPLEVEL;
attr.wclass = GDK_INPUT_ONLY;
attr.x = 10;
attr.y = 10;
attr.width = 10;
attr.height = 10;
attr.event_mask = 0;
display_x11->leader_gdk_window = gdk_window_new (GDK_X11_SCREEN (display_x11->screen)->root_window,
&attr, GDK_WA_X | GDK_WA_Y);
display_x11->leader_gdk_window = gdk_window_new_temp (display);
(_gdk_x11_window_get_toplevel (display_x11->leader_gdk_window))->is_leader = TRUE;
display_x11->leader_window = GDK_WINDOW_XID (display_x11->leader_gdk_window);

View File

@ -4815,27 +4815,11 @@ static void
create_moveresize_window (MoveResizeData *mv_resize,
guint32 timestamp)
{
GdkWindowAttr attributes;
gint attributes_mask;
GdkGrabStatus status;
g_assert (mv_resize->moveresize_emulation_window == NULL);
attributes.x = -100;
attributes.y = -100;
attributes.width = 10;
attributes.height = 10;
attributes.window_type = GDK_WINDOW_TEMP;
attributes.wclass = GDK_INPUT_ONLY;
attributes.event_mask = 0;
attributes_mask = GDK_WA_X | GDK_WA_Y;
mv_resize->moveresize_emulation_window =
gdk_window_new (gdk_screen_get_root_window (gdk_display_get_default_screen (mv_resize->display)),
&attributes,
attributes_mask);
mv_resize->moveresize_emulation_window = gdk_window_new_temp (mv_resize->display);
gdk_window_show (mv_resize->moveresize_emulation_window);
status = gdk_seat_grab (gdk_device_get_seat (mv_resize->device),

View File

@ -229,28 +229,11 @@ gtk_invisible_get_screen (GtkInvisible *invisible)
static void
gtk_invisible_realize (GtkWidget *widget)
{
GdkWindow *parent;
GdkWindow *window;
GdkWindowAttr attributes;
gint attributes_mask;
gtk_widget_set_realized (widget, TRUE);
parent = gtk_widget_get_parent_window (widget);
if (parent == NULL)
parent = gdk_screen_get_root_window (gtk_widget_get_screen (widget));
attributes.x = -100;
attributes.y = -100;
attributes.width = 10;
attributes.height = 10;
attributes.window_type = GDK_WINDOW_TEMP;
attributes.wclass = GDK_INPUT_ONLY;
attributes.event_mask = gtk_widget_get_events (widget);
attributes_mask = GDK_WA_X | GDK_WA_Y;
window = gdk_window_new (parent, &attributes, attributes_mask);
window = gdk_window_new_temp (gtk_widget_get_display (widget));
gtk_widget_set_window (widget, window);
gtk_widget_register_window (widget, window);
}

View File

@ -2667,23 +2667,7 @@ menu_grab_transfer_window_get (GtkMenu *menu)
GdkWindow *window = g_object_get_data (G_OBJECT (menu), "gtk-menu-transfer-window");
if (!window)
{
GdkWindowAttr attributes;
gint attributes_mask;
GdkWindow *parent;
attributes.x = -100;
attributes.y = -100;
attributes.width = 10;
attributes.height = 10;
attributes.window_type = GDK_WINDOW_TEMP;
attributes.wclass = GDK_INPUT_ONLY;
attributes.event_mask = 0;
attributes_mask = GDK_WA_X | GDK_WA_Y;
parent = gdk_screen_get_root_window (gtk_widget_get_screen (GTK_WIDGET (menu)));
window = gdk_window_new (parent,
&attributes, attributes_mask);
window = gdk_window_new_temp (gtk_widget_get_display (GTK_WIDGET (menu)));
gtk_widget_register_window (GTK_WIDGET (menu), window);
gdk_window_show (window);