forked from AuroraMiddleware/gtk
API: gdk: Add gdk_window_new_popup()
... and use it.
This commit is contained in:
parent
13d8ac83ee
commit
24d0baec38
@ -279,6 +279,7 @@ GdkWindowAttr
|
||||
GdkWindowAttributesType
|
||||
gdk_window_new
|
||||
gdk_window_new_toplevel
|
||||
gdk_window_new_popup
|
||||
gdk_window_new_child
|
||||
gdk_window_new_input
|
||||
gdk_window_destroy
|
||||
|
@ -1330,6 +1330,41 @@ gdk_window_new_toplevel (GdkDisplay *display,
|
||||
0);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_window_new_popup: (constructor)
|
||||
* @display: the display to create the window on
|
||||
* @event_mask: event mask (see gdk_window_set_events())
|
||||
* @position: position of the window on screen
|
||||
*
|
||||
* Creates a new toplevel popup window. The window will bypass window
|
||||
* management.
|
||||
*
|
||||
* Returns: (transfer full): the new #GdkWindow
|
||||
*
|
||||
* Since: 3.90
|
||||
**/
|
||||
GdkWindow *
|
||||
gdk_window_new_popup (GdkDisplay *display,
|
||||
gint event_mask,
|
||||
const GdkRectangle *position)
|
||||
{
|
||||
GdkWindowAttr attr;
|
||||
|
||||
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
|
||||
g_return_val_if_fail (position != NULL, NULL);
|
||||
|
||||
attr.event_mask = event_mask;
|
||||
attr.wclass = GDK_INPUT_OUTPUT;
|
||||
attr.x = position->x;
|
||||
attr.y = position->y;
|
||||
attr.width = position->width;
|
||||
attr.height = position->height;
|
||||
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
|
||||
|
@ -471,6 +471,10 @@ GdkWindow * gdk_window_new_toplevel (GdkDisplay *display,
|
||||
int width,
|
||||
int height);
|
||||
GDK_AVAILABLE_IN_3_90
|
||||
GdkWindow * gdk_window_new_popup (GdkDisplay *display,
|
||||
gint event_mask,
|
||||
const GdkRectangle *position);
|
||||
GDK_AVAILABLE_IN_3_90
|
||||
GdkWindow * gdk_window_new_child (GdkWindow *parent,
|
||||
gint event_mask,
|
||||
const GdkRectangle *position);
|
||||
|
@ -4511,20 +4511,7 @@ static const struct wl_surface_listener pointer_surface_listener = {
|
||||
static GdkWindow *
|
||||
create_foreign_dnd_window (GdkDisplay *display)
|
||||
{
|
||||
GdkWindowAttr attrs;
|
||||
GdkScreen *screen;
|
||||
guint mask;
|
||||
|
||||
screen = gdk_display_get_default_screen (display);
|
||||
|
||||
attrs.x = attrs.y = 0;
|
||||
attrs.width = attrs.height = 1;
|
||||
attrs.wclass = GDK_INPUT_OUTPUT;
|
||||
attrs.window_type = GDK_WINDOW_TEMP;
|
||||
|
||||
mask = GDK_WA_X | GDK_WA_Y;
|
||||
|
||||
return gdk_window_new (gdk_screen_get_root_window (screen), &attrs, mask);
|
||||
return gdk_window_new_popup (display, 0, &(GdkRectangle) { 0, 0, 1, 1 });
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -498,20 +498,11 @@ _gdk_wayland_window_register_dnd (GdkWindow *window)
|
||||
}
|
||||
|
||||
static GdkWindow *
|
||||
create_dnd_window (GdkScreen *screen)
|
||||
create_dnd_window (GdkDisplay *display)
|
||||
{
|
||||
GdkWindowAttr attrs;
|
||||
GdkWindow *window;
|
||||
guint mask;
|
||||
|
||||
attrs.x = attrs.y = 0;
|
||||
attrs.width = attrs.height = 100;
|
||||
attrs.wclass = GDK_INPUT_OUTPUT;
|
||||
attrs.window_type = GDK_WINDOW_TEMP;
|
||||
|
||||
mask = GDK_WA_X | GDK_WA_Y;
|
||||
|
||||
window = gdk_window_new (gdk_screen_get_root_window (screen), &attrs, mask);
|
||||
window = gdk_window_new_popup (display, 0, &(GdkRectangle) { 0, 0, 100, 100 });
|
||||
|
||||
gdk_window_set_type_hint (window, GDK_WINDOW_TYPE_HINT_DND);
|
||||
|
||||
@ -538,7 +529,7 @@ _gdk_wayland_window_drag_begin (GdkWindow *window,
|
||||
|
||||
gdk_drag_context_set_device (context, device);
|
||||
|
||||
context_wayland->dnd_window = create_dnd_window (gdk_window_get_screen (window));
|
||||
context_wayland->dnd_window = create_dnd_window (gdk_window_get_display (window));
|
||||
context_wayland->dnd_surface = gdk_wayland_window_get_wl_surface (context_wayland->dnd_window);
|
||||
context_wayland->data_source =
|
||||
gdk_wayland_selection_get_data_source (window,
|
||||
|
@ -354,7 +354,6 @@ wintab_init_check (GdkDeviceManagerWin32 *device_manager)
|
||||
GdkWindow *root = gdk_screen_get_root_window (gdk_display_get_default_screen (display));
|
||||
static gboolean wintab_initialized = FALSE;
|
||||
GdkDeviceWintab *device;
|
||||
GdkWindowAttr wa;
|
||||
WORD specversion;
|
||||
HCTX *hctx;
|
||||
UINT ndevices, ncursors, ncsrtypes, firstcsr, hardware;
|
||||
@ -434,18 +433,7 @@ wintab_init_check (GdkDeviceManagerWin32 *device_manager)
|
||||
ndevices, ncursors));
|
||||
#endif
|
||||
/* Create a dummy window to receive wintab events */
|
||||
wa.wclass = GDK_INPUT_OUTPUT;
|
||||
wa.event_mask = GDK_ALL_EVENTS_MASK;
|
||||
wa.width = 2;
|
||||
wa.height = 2;
|
||||
wa.x = -100;
|
||||
wa.y = -100;
|
||||
wa.window_type = GDK_WINDOW_TOPLEVEL;
|
||||
if ((wintab_window = gdk_window_new (root, &wa, GDK_WA_X | GDK_WA_Y)) == NULL)
|
||||
{
|
||||
g_warning ("gdk_input_wintab_init: gdk_window_new failed");
|
||||
return;
|
||||
}
|
||||
wintab_window = gdk_window_new_popup (display, GDK_ALL_EVENTS_MASK, &(GdkRectangle) { -100, -100, 2, 2 });
|
||||
g_object_ref (wintab_window);
|
||||
|
||||
for (devix = 0; devix < ndevices; devix++)
|
||||
|
@ -1991,20 +1991,11 @@ gdk_drag_do_leave (GdkX11DragContext *context_x11,
|
||||
}
|
||||
|
||||
static GdkWindow *
|
||||
create_drag_window (GdkScreen *screen)
|
||||
create_drag_window (GdkDisplay *display)
|
||||
{
|
||||
GdkWindowAttr attrs = { 0 };
|
||||
GdkWindow *window;
|
||||
guint mask;
|
||||
|
||||
attrs.x = attrs.y = 0;
|
||||
attrs.width = attrs.height = 100;
|
||||
attrs.wclass = GDK_INPUT_OUTPUT;
|
||||
attrs.window_type = GDK_WINDOW_TEMP;
|
||||
|
||||
mask = GDK_WA_X | GDK_WA_Y;
|
||||
|
||||
window = gdk_window_new (gdk_screen_get_root_window (screen), &attrs, mask);
|
||||
window = gdk_window_new_popup (display, 0, &(GdkRectangle) { 0, 0, 100, 100 });
|
||||
|
||||
gdk_window_set_type_hint (window, GDK_WINDOW_TYPE_HINT_DND);
|
||||
|
||||
@ -2037,7 +2028,7 @@ _gdk_x11_window_drag_begin (GdkWindow *window,
|
||||
GDK_X11_DRAG_CONTEXT (context)->start_x = x_root;
|
||||
GDK_X11_DRAG_CONTEXT (context)->start_y = y_root;
|
||||
|
||||
GDK_X11_DRAG_CONTEXT (context)->drag_window = create_drag_window (gdk_window_get_screen (window));
|
||||
GDK_X11_DRAG_CONTEXT (context)->drag_window = create_drag_window (gdk_window_get_display(window));
|
||||
|
||||
return context;
|
||||
}
|
||||
|
@ -3938,25 +3938,15 @@ gtk_tree_view_motion_draw_column_motion_arrow (GtkTreeView *tree_view)
|
||||
/* Create the new window */
|
||||
if (tree_view->priv->drag_column_window_state != DRAG_COLUMN_WINDOW_STATE_ARROW)
|
||||
{
|
||||
GdkWindowAttr attributes;
|
||||
gint attributes_mask;
|
||||
|
||||
if (tree_view->priv->drag_highlight_window)
|
||||
{
|
||||
gtk_widget_unregister_window (GTK_WIDGET (tree_view), tree_view->priv->drag_highlight_window);
|
||||
gdk_window_destroy (tree_view->priv->drag_highlight_window);
|
||||
}
|
||||
|
||||
attributes.window_type = GDK_WINDOW_TEMP;
|
||||
attributes.wclass = GDK_INPUT_OUTPUT;
|
||||
attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK | GDK_POINTER_MOTION_MASK;
|
||||
attributes_mask = GDK_WA_X | GDK_WA_Y;
|
||||
attributes.x = x;
|
||||
attributes.y = y;
|
||||
attributes.width = width;
|
||||
attributes.height = height;
|
||||
tree_view->priv->drag_highlight_window = gdk_window_new (gdk_screen_get_root_window (gtk_widget_get_screen (widget)),
|
||||
&attributes, attributes_mask);
|
||||
tree_view->priv->drag_highlight_window = gdk_window_new_popup (gtk_widget_get_display (widget),
|
||||
GDK_VISIBILITY_NOTIFY_MASK | GDK_POINTER_MOTION_MASK,
|
||||
&(GdkRectangle) { x, y, width, height });
|
||||
gtk_widget_register_window (GTK_WIDGET (tree_view), tree_view->priv->drag_highlight_window);
|
||||
|
||||
mask_image = cairo_image_surface_create (CAIRO_FORMAT_A1, width, height);
|
||||
@ -4017,24 +4007,15 @@ gtk_tree_view_motion_draw_column_motion_arrow (GtkTreeView *tree_view)
|
||||
if (tree_view->priv->drag_column_window_state != DRAG_COLUMN_WINDOW_STATE_ARROW_LEFT &&
|
||||
tree_view->priv->drag_column_window_state != DRAG_COLUMN_WINDOW_STATE_ARROW_RIGHT)
|
||||
{
|
||||
GdkWindowAttr attributes;
|
||||
gint attributes_mask;
|
||||
|
||||
if (tree_view->priv->drag_highlight_window)
|
||||
{
|
||||
gtk_widget_unregister_window (GTK_WIDGET (tree_view), tree_view->priv->drag_highlight_window);
|
||||
gdk_window_destroy (tree_view->priv->drag_highlight_window);
|
||||
}
|
||||
|
||||
attributes.window_type = GDK_WINDOW_TEMP;
|
||||
attributes.wclass = GDK_INPUT_OUTPUT;
|
||||
attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK | GDK_POINTER_MOTION_MASK;
|
||||
attributes_mask = GDK_WA_X | GDK_WA_Y;
|
||||
attributes.x = x;
|
||||
attributes.y = y;
|
||||
attributes.width = width;
|
||||
attributes.height = height;
|
||||
tree_view->priv->drag_highlight_window = gdk_window_new (gdk_screen_get_root_window (gtk_widget_get_screen (widget)), &attributes, attributes_mask);
|
||||
tree_view->priv->drag_highlight_window = gdk_window_new_popup (gtk_widget_get_display (widget),
|
||||
GDK_VISIBILITY_NOTIFY_MASK | GDK_POINTER_MOTION_MASK,
|
||||
&(GdkRectangle) { x, y, width, height });
|
||||
gtk_widget_register_window (GTK_WIDGET (tree_view), tree_view->priv->drag_highlight_window);
|
||||
|
||||
mask_image = cairo_image_surface_create (CAIRO_FORMAT_A1, width, height);
|
||||
|
@ -6858,9 +6858,9 @@ gtk_window_realize (GtkWidget *widget)
|
||||
GtkAllocation child_allocation;
|
||||
GtkWindow *window;
|
||||
GdkWindow *gdk_window;
|
||||
GdkWindowAttr attributes;
|
||||
GtkBorder window_border;
|
||||
GtkWindowPrivate *priv;
|
||||
gint event_mask;
|
||||
gint i;
|
||||
GList *link;
|
||||
|
||||
@ -6931,13 +6931,9 @@ gtk_window_realize (GtkWidget *widget)
|
||||
}
|
||||
else
|
||||
{
|
||||
attributes.wclass = GDK_INPUT_OUTPUT;
|
||||
|
||||
_gtk_widget_get_allocation (widget, &allocation);
|
||||
attributes.width = allocation.width;
|
||||
attributes.height = allocation.height;
|
||||
attributes.event_mask = gtk_widget_get_events (widget);
|
||||
attributes.event_mask |= (GDK_EXPOSURE_MASK |
|
||||
event_mask = gtk_widget_get_events (widget);
|
||||
event_mask |= (GDK_EXPOSURE_MASK |
|
||||
GDK_BUTTON_PRESS_MASK |
|
||||
GDK_BUTTON_RELEASE_MASK |
|
||||
GDK_BUTTON_MOTION_MASK |
|
||||
@ -6948,13 +6944,13 @@ gtk_window_realize (GtkWidget *widget)
|
||||
GDK_FOCUS_CHANGE_MASK |
|
||||
GDK_STRUCTURE_MASK);
|
||||
if (priv->decorated && priv->client_decorated)
|
||||
attributes.event_mask |= GDK_POINTER_MOTION_MASK;
|
||||
event_mask |= GDK_POINTER_MOTION_MASK;
|
||||
|
||||
switch (priv->type)
|
||||
{
|
||||
case GTK_WINDOW_TOPLEVEL:
|
||||
gdk_window = gdk_window_new_toplevel (gtk_widget_get_display (widget),
|
||||
attributes.event_mask,
|
||||
event_mask,
|
||||
allocation.width,
|
||||
allocation.height);
|
||||
break;
|
||||
@ -6964,15 +6960,15 @@ gtk_window_realize (GtkWidget *widget)
|
||||
GDK_IS_WAYLAND_DISPLAY (gtk_widget_get_display (widget)))
|
||||
{
|
||||
gdk_window = gdk_wayland_window_new_subsurface (gtk_widget_get_display (widget),
|
||||
attributes.event_mask,
|
||||
event_mask,
|
||||
&allocation);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
attributes.window_type = GDK_WINDOW_TEMP;
|
||||
gdk_window = gdk_window_new (gdk_screen_get_root_window (_gtk_window_get_screen (window)),
|
||||
&attributes, 0);
|
||||
gdk_window = gdk_window_new_popup (gtk_widget_get_display (widget),
|
||||
event_mask,
|
||||
&allocation);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -107,13 +107,9 @@ test_type (gconstpointer data)
|
||||
instance = g_object_ref (gtk_settings_get_default ());
|
||||
else if (g_type_is_a (type, GDK_TYPE_WINDOW))
|
||||
{
|
||||
GdkWindowAttr attributes;
|
||||
attributes.wclass = GDK_INPUT_OUTPUT;
|
||||
attributes.window_type = GDK_WINDOW_TEMP;
|
||||
attributes.event_mask = 0;
|
||||
attributes.width = 100;
|
||||
attributes.height = 100;
|
||||
instance = g_object_ref (gdk_window_new (NULL, &attributes, 0));
|
||||
instance = g_object_ref (gdk_window_new_popup (gdk_display_get_default (),
|
||||
0,
|
||||
&(GdkRectangle) { 0, 0, 100, 100 }));
|
||||
}
|
||||
else if (g_str_equal (g_type_name (type), "GdkX11Cursor"))
|
||||
instance = g_object_new (type, "display", display, NULL);
|
||||
|
@ -403,13 +403,9 @@ test_type (gconstpointer data)
|
||||
instance = g_object_ref (gtk_settings_get_default ());
|
||||
else if (g_type_is_a (type, GDK_TYPE_WINDOW))
|
||||
{
|
||||
GdkWindowAttr attributes;
|
||||
attributes.wclass = GDK_INPUT_OUTPUT;
|
||||
attributes.window_type = GDK_WINDOW_TEMP;
|
||||
attributes.event_mask = 0;
|
||||
attributes.width = 100;
|
||||
attributes.height = 100;
|
||||
instance = g_object_ref (gdk_window_new (NULL, &attributes, 0));
|
||||
instance = g_object_ref (gdk_window_new_popup (gdk_display_get_default (),
|
||||
0,
|
||||
&(GdkRectangle) { 0, 0, 100, 100 }));
|
||||
}
|
||||
else if (g_str_equal (g_type_name (type), "GdkX11Cursor"))
|
||||
instance = g_object_new (type, "display", display, NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user