display: Remove x/y/w/h from create_surface()

This commit is contained in:
Benjamin Otte 2023-04-15 20:06:36 +02:00
parent 9364da673f
commit 7ef5f6ef1a
17 changed files with 61 additions and 177 deletions

View File

@ -488,7 +488,7 @@ gdk_broadway_display_class_init (GdkBroadwayDisplayClass * class)
display_class->get_next_serial = gdk_broadway_display_get_next_serial; display_class->get_next_serial = gdk_broadway_display_get_next_serial;
display_class->notify_startup_complete = gdk_broadway_display_notify_startup_complete; display_class->notify_startup_complete = gdk_broadway_display_notify_startup_complete;
display_class->create_surface = _gdk_broadway_display_create_surface; display_class->create_surface = gdk_broadway_display_create_surface;
display_class->get_keymap = _gdk_broadway_display_get_keymap; display_class->get_keymap = _gdk_broadway_display_get_keymap;
display_class->get_monitors = gdk_broadway_display_get_monitors; display_class->get_monitors = gdk_broadway_display_get_monitors;

View File

@ -103,13 +103,9 @@ void _gdk_broadway_display_get_default_cursor_size (GdkDisplay *display,
void _gdk_broadway_display_get_maximal_cursor_size (GdkDisplay *display, void _gdk_broadway_display_get_maximal_cursor_size (GdkDisplay *display,
guint *width, guint *width,
guint *height); guint *height);
GdkSurface * _gdk_broadway_display_create_surface (GdkDisplay *display, GdkSurface * gdk_broadway_display_create_surface (GdkDisplay *display,
GdkSurfaceType surface_type, GdkSurfaceType surface_type,
GdkSurface *parent, GdkSurface *parent);
int x,
int y,
int width,
int height);
GdkKeymap* _gdk_broadway_display_get_keymap (GdkDisplay *display); GdkKeymap* _gdk_broadway_display_get_keymap (GdkDisplay *display);
void _gdk_broadway_display_consume_all_input (GdkDisplay *display); void _gdk_broadway_display_consume_all_input (GdkDisplay *display);
BroadwayInputMsg * _gdk_broadway_display_block_for_input (GdkDisplay *display, BroadwayInputMsg * _gdk_broadway_display_block_for_input (GdkDisplay *display,

View File

@ -208,13 +208,9 @@ disconnect_frame_clock (GdkSurface *surface)
} }
GdkSurface * GdkSurface *
_gdk_broadway_display_create_surface (GdkDisplay *display, gdk_broadway_display_create_surface (GdkDisplay *display,
GdkSurfaceType surface_type, GdkSurfaceType surface_type,
GdkSurface *parent, GdkSurface *parent)
int x,
int y,
int width,
int height)
{ {
GdkBroadwayDisplay *broadway_display; GdkBroadwayDisplay *broadway_display;
GdkFrameClock *frame_clock; GdkFrameClock *frame_clock;
@ -251,27 +247,22 @@ _gdk_broadway_display_create_surface (GdkDisplay *display,
g_object_unref (frame_clock); g_object_unref (frame_clock);
surface->parent = parent; surface->parent = parent;
surface->x = x;
surface->y = y;
surface->width = width;
surface->height = height;
broadway_display = GDK_BROADWAY_DISPLAY (display); broadway_display = GDK_BROADWAY_DISPLAY (display);
impl = GDK_BROADWAY_SURFACE (surface); impl = GDK_BROADWAY_SURFACE (surface);
impl->root_x = x; impl->root_x = 0;
impl->root_y = y; impl->root_y = 0;
if (parent) if (parent)
{ {
impl->root_x += GDK_BROADWAY_SURFACE (parent)->root_x; impl->root_x = GDK_BROADWAY_SURFACE (parent)->root_x;
impl->root_y += GDK_BROADWAY_SURFACE (parent)->root_y; impl->root_y = GDK_BROADWAY_SURFACE (parent)->root_y;
} }
impl->id = _gdk_broadway_server_new_surface (broadway_display->server, impl->id = _gdk_broadway_server_new_surface (broadway_display->server,
impl->root_x, impl->root_x,
impl->root_y, impl->root_y,
surface->width, 1, 1);
surface->height);
g_hash_table_insert (broadway_display->id_ht, GINT_TO_POINTER(impl->id), surface); g_hash_table_insert (broadway_display->id_ht, GINT_TO_POINTER(impl->id), surface);
g_object_ref (surface); g_object_ref (surface);
@ -1108,11 +1099,11 @@ create_moveresize_surface (MoveResizeData *mv_resize,
g_assert (mv_resize->moveresize_emulation_surface == NULL); g_assert (mv_resize->moveresize_emulation_surface == NULL);
mv_resize->moveresize_emulation_surface = mv_resize->moveresize_emulation_surface =
_gdk_broadway_display_create_surface (mv_resize->display, gdk_broadway_display_create_surface (mv_resize->display,
GDK_SURFACE_DRAG, GDK_SURFACE_DRAG,
NULL, NULL);
-100, -100, 1, 1);
gdk_broadway_surface_move_resize_internal (mv_resize->moveresize_emulation_surface, TRUE, -100, -100, 1, 1);
gdk_broadway_surface_show (mv_resize->moveresize_emulation_surface, FALSE); gdk_broadway_surface_show (mv_resize->moveresize_emulation_surface, FALSE);
seat = gdk_display_get_default_seat (mv_resize->display); seat = gdk_display_get_default_seat (mv_resize->display);

View File

@ -1199,16 +1199,11 @@ _gdk_display_unpause_events (GdkDisplay *display)
GdkSurface * GdkSurface *
gdk_display_create_surface (GdkDisplay *display, gdk_display_create_surface (GdkDisplay *display,
GdkSurfaceType surface_type, GdkSurfaceType surface_type,
GdkSurface *parent, GdkSurface *parent)
int x,
int y,
int width,
int height)
{ {
return GDK_DISPLAY_GET_CLASS (display)->create_surface (display, return GDK_DISPLAY_GET_CLASS (display)->create_surface (display,
surface_type, surface_type,
parent, parent);
x, y, width, height);
} }
/*< private > /*< private >

View File

@ -134,15 +134,11 @@ struct _GdkDisplayClass
const char *startup_id); const char *startup_id);
const char * (*get_startup_notification_id) (GdkDisplay *display); const char * (*get_startup_notification_id) (GdkDisplay *display);
GdkSurface * (*create_surface) (GdkDisplay *display, GdkSurface * (*create_surface) (GdkDisplay *display,
GdkSurfaceType surface_type, GdkSurfaceType surface_type,
GdkSurface *parent, GdkSurface *parent);
int x,
int y,
int width,
int height);
GdkKeymap * (*get_keymap) (GdkDisplay *display); GdkKeymap * (*get_keymap) (GdkDisplay *display);
GdkGLContext * (* init_gl) (GdkDisplay *display, GdkGLContext * (* init_gl) (GdkDisplay *display,
GError **error); GError **error);
@ -209,11 +205,7 @@ void _gdk_display_pause_events (GdkDisplay *display
void _gdk_display_unpause_events (GdkDisplay *display); void _gdk_display_unpause_events (GdkDisplay *display);
GdkSurface * gdk_display_create_surface (GdkDisplay *display, GdkSurface * gdk_display_create_surface (GdkDisplay *display,
GdkSurfaceType surface_type, GdkSurfaceType surface_type,
GdkSurface *parent, GdkSurface *parent);
int x,
int y,
int width,
int height);
GdkGLContext * gdk_display_get_gl_context (GdkDisplay *display); GdkGLContext * gdk_display_get_gl_context (GdkDisplay *display);

View File

@ -848,16 +848,11 @@ _gdk_surface_update_size (GdkSurface *surface)
static GdkSurface * static GdkSurface *
gdk_surface_new (GdkDisplay *display, gdk_surface_new (GdkDisplay *display,
GdkSurfaceType surface_type, GdkSurfaceType surface_type,
GdkSurface *parent, GdkSurface *parent)
int x,
int y,
int width,
int height)
{ {
return gdk_display_create_surface (display, return gdk_display_create_surface (display,
surface_type, surface_type,
parent, parent);
x, y, width, height);
} }
/** /**
@ -874,7 +869,7 @@ gdk_surface_new_toplevel (GdkDisplay *display)
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL); g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
return gdk_surface_new (display, GDK_SURFACE_TOPLEVEL, return gdk_surface_new (display, GDK_SURFACE_TOPLEVEL,
NULL, 0, 0, 1, 1); NULL);
} }
/** /**
@ -898,7 +893,7 @@ gdk_surface_new_popup (GdkSurface *parent,
g_return_val_if_fail (GDK_IS_SURFACE (parent), NULL); g_return_val_if_fail (GDK_IS_SURFACE (parent), NULL);
surface = gdk_surface_new (parent->display, GDK_SURFACE_POPUP, surface = gdk_surface_new (parent->display, GDK_SURFACE_POPUP,
parent, 0, 0, 100, 100); parent);
surface->autohide = autohide; surface->autohide = autohide;

View File

@ -542,11 +542,7 @@ _gdk_macos_display_surface_resigned_main (GdkMacosDisplay *self,
static GdkSurface * static GdkSurface *
gdk_macos_display_create_surface (GdkDisplay *display, gdk_macos_display_create_surface (GdkDisplay *display,
GdkSurfaceType surface_type, GdkSurfaceType surface_type,
GdkSurface *parent, GdkSurface *parent)
int x,
int y,
int width,
int height)
{ {
GdkMacosDisplay *self = (GdkMacosDisplay *)display; GdkMacosDisplay *self = (GdkMacosDisplay *)display;
GdkMacosSurface *surface; GdkMacosSurface *surface;
@ -554,7 +550,7 @@ gdk_macos_display_create_surface (GdkDisplay *display,
g_assert (GDK_IS_MACOS_DISPLAY (self)); g_assert (GDK_IS_MACOS_DISPLAY (self));
g_assert (!parent || GDK_IS_MACOS_SURFACE (parent)); g_assert (!parent || GDK_IS_MACOS_SURFACE (parent));
surface = _gdk_macos_surface_new (self, surface_type, parent, x, y, width, height); surface = _gdk_macos_surface_new (self, surface_type, parent, 0, 0, 100, 100);
if (surface != NULL) if (surface != NULL)
_gdk_macos_display_surface_added (self, surface); _gdk_macos_display_surface_added (self, surface);

View File

@ -987,7 +987,7 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
display_class->get_startup_notification_id = gdk_wayland_display_get_startup_notification_id; display_class->get_startup_notification_id = gdk_wayland_display_get_startup_notification_id;
G_GNUC_END_IGNORE_DEPRECATIONS G_GNUC_END_IGNORE_DEPRECATIONS
display_class->notify_startup_complete = gdk_wayland_display_notify_startup_complete; display_class->notify_startup_complete = gdk_wayland_display_notify_startup_complete;
display_class->create_surface = _gdk_wayland_display_create_surface; display_class->create_surface = gdk_wayland_display_create_surface;
display_class->get_keymap = _gdk_wayland_display_get_keymap; display_class->get_keymap = _gdk_wayland_display_get_keymap;
display_class->init_gl = gdk_wayland_display_init_gl; display_class->init_gl = gdk_wayland_display_init_gl;

View File

@ -382,7 +382,7 @@ _gdk_wayland_surface_drag_begin (GdkSurface *surface,
drag = GDK_DRAG (drag_wayland); drag = GDK_DRAG (drag_wayland);
drag_wayland->dnd_surface = _gdk_wayland_display_create_surface (display, GDK_SURFACE_DRAG, NULL, 0, 0, 100, 100); drag_wayland->dnd_surface = gdk_wayland_display_create_surface (display, GDK_SURFACE_DRAG, NULL);
drag_wayland->dnd_wl_surface = gdk_wayland_surface_get_wl_surface (drag_wayland->dnd_surface); drag_wayland->dnd_wl_surface = gdk_wayland_surface_get_wl_surface (drag_wayland->dnd_surface);
gdk_wayland_drag_create_data_source (drag); gdk_wayland_drag_create_data_source (drag);

View File

@ -157,13 +157,9 @@ void gdk_wayland_drop_set_source_actions (GdkDrop
void gdk_wayland_drop_set_action (GdkDrop *drop, void gdk_wayland_drop_set_action (GdkDrop *drop,
uint32_t action); uint32_t action);
GdkSurface * _gdk_wayland_display_create_surface (GdkDisplay *display, GdkSurface * gdk_wayland_display_create_surface (GdkDisplay *display,
GdkSurfaceType surface_type, GdkSurfaceType surface_type,
GdkSurface *parent, GdkSurface *parent);
int x,
int y,
int width,
int height);
void _gdk_wayland_display_create_seat (GdkWaylandDisplay *display, void _gdk_wayland_display_create_seat (GdkWaylandDisplay *display,
guint32 id, guint32 id,

View File

@ -832,13 +832,9 @@ gdk_wayland_surface_destroy_wl_surface (GdkWaylandSurface *self)
} }
GdkSurface * GdkSurface *
_gdk_wayland_display_create_surface (GdkDisplay *display, gdk_wayland_display_create_surface (GdkDisplay *display,
GdkSurfaceType surface_type, GdkSurfaceType surface_type,
GdkSurface *parent, GdkSurface *parent)
int x,
int y,
int width,
int height)
{ {
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display); GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
GdkSurface *surface; GdkSurface *surface;
@ -880,22 +876,6 @@ _gdk_wayland_display_create_surface (GdkDisplay *display,
break; break;
} }
if (width > 65535)
{
g_warning ("Native Surfaces wider than 65535 pixels are not supported");
width = 65535;
}
if (height > 65535)
{
g_warning ("Native Surfaces taller than 65535 pixels are not supported");
height = 65535;
}
surface->x = x;
surface->y = y;
surface->width = width;
surface->height = height;
/* More likely to be right than just assuming 1 */ /* More likely to be right than just assuming 1 */
if (wl_compositor_get_version (display_wayland->compositor) >= WL_SURFACE_SET_BUFFER_SCALE_SINCE_VERSION) if (wl_compositor_get_version (display_wayland->compositor) >= WL_SURFACE_SET_BUFFER_SCALE_SINCE_VERSION)
{ {

View File

@ -428,10 +428,9 @@ wintab_init_check (GdkDeviceManagerWin32 *device_manager)
#endif #endif
/* Create a dummy window to receive wintab events */ /* Create a dummy window to receive wintab events */
wintab_window = wintab_window =
_gdk_win32_display_create_surface (display, gdk_win32_display_create_surface (display,
GDK_SURFACE_DRAG, GDK_SURFACE_DRAG,
NULL, NULL);
-100, -100, 2, 2);
g_object_ref (wintab_window); g_object_ref (wintab_window);

View File

@ -1281,7 +1281,7 @@ gdk_win32_display_class_init (GdkWin32DisplayClass *klass)
display_class->get_next_serial = gdk_win32_display_get_next_serial; display_class->get_next_serial = gdk_win32_display_get_next_serial;
display_class->notify_startup_complete = gdk_win32_display_notify_startup_complete; display_class->notify_startup_complete = gdk_win32_display_notify_startup_complete;
display_class->create_surface = _gdk_win32_display_create_surface; display_class->create_surface = gdk_win32_display_create_surface;
display_class->get_keymap = _gdk_win32_display_get_keymap; display_class->get_keymap = _gdk_win32_display_get_keymap;

View File

@ -1649,10 +1649,9 @@ create_drag_surface (GdkDisplay *display)
{ {
GdkSurface *surface; GdkSurface *surface;
surface = _gdk_win32_display_create_surface (display, surface = gdk_win32_display_create_surface (display,
GDK_SURFACE_DRAG, GDK_SURFACE_DRAG,
NULL, NULL);
0, 0, 100, 100);
return surface; return surface;
} }

View File

@ -381,13 +381,9 @@ GdkModifierType _gdk_win32_keymap_get_mod_mask (GdkWin32Keymap *keymap);
GdkKeymap *_gdk_win32_display_get_keymap (GdkDisplay *display); GdkKeymap *_gdk_win32_display_get_keymap (GdkDisplay *display);
GdkSurface *_gdk_win32_display_create_surface (GdkDisplay *display, GdkSurface *gdk_win32_display_create_surface (GdkDisplay *display,
GdkSurfaceType surface_type, GdkSurfaceType surface_type,
GdkSurface *parent, GdkSurface *parent);
int x,
int y,
int width,
int height);
/* stray GdkSurfaceImplWin32 members */ /* stray GdkSurfaceImplWin32 members */
void _gdk_win32_surface_register_dnd (GdkSurface *window); void _gdk_win32_surface_register_dnd (GdkSurface *window);

View File

@ -447,25 +447,10 @@ RegisterGdkClass (GdkSurfaceType wtype)
return klass; return klass;
} }
/*
* Create native windows.
*
* With the default Gdk the created windows are mostly toplevel windows.
*
* Placement of the window is derived from the passed in window,
* except for toplevel window where OS/Window Manager placement
* is used.
*
* [1] http://mail.gnome.org/archives/gtk-devel-list/2010-August/msg00214.html
*/
GdkSurface * GdkSurface *
_gdk_win32_display_create_surface (GdkDisplay *display, gdk_win32_display_create_surface (GdkDisplay *display,
GdkSurfaceType surface_type, GdkSurfaceType surface_type,
GdkSurface *parent, GdkSurface *parent)
int x,
int y,
int width,
int height)
{ {
HWND hwndNew; HWND hwndNew;
HANDLE owner; HANDLE owner;
@ -477,9 +462,6 @@ _gdk_win32_display_create_surface (GdkDisplay *display,
GdkSurface *surface; GdkSurface *surface;
const char *title; const char *title;
wchar_t *wtitle; wchar_t *wtitle;
int window_width, window_height;
int window_x, window_y;
int real_x = 0, real_y = 0;
GdkFrameClock *frame_clock; GdkFrameClock *frame_clock;
g_return_val_if_fail (display == _gdk_display, NULL); g_return_val_if_fail (display == _gdk_display, NULL);
@ -522,12 +504,6 @@ _gdk_win32_display_create_surface (GdkDisplay *display,
break; break;
} }
surface = GDK_SURFACE (impl);
surface->x = x;
surface->y = y;
surface->width = width;
surface->height = height;
impl->surface_scale = gdk_win32_display_get_monitor_scale_factor (display_win32, NULL, NULL); impl->surface_scale = gdk_win32_display_get_monitor_scale_factor (display_win32, NULL, NULL);
dwExStyle = 0; dwExStyle = 0;
@ -557,32 +533,6 @@ _gdk_win32_display_create_surface (GdkDisplay *display,
g_assert_not_reached (); g_assert_not_reached ();
} }
rect.left = x * impl->surface_scale;
rect.top = y * impl->surface_scale;
rect.right = rect.left + width * impl->surface_scale;
rect.bottom = rect.top + height * impl->surface_scale;
AdjustWindowRectEx (&rect, dwStyle, FALSE, dwExStyle);
real_x = x * impl->surface_scale;
real_y = y * impl->surface_scale;
if (surface_type == GDK_SURFACE_TOPLEVEL)
{
/* We initially place it at default so that we can get the
default window positioning if we want */
window_x = window_y = CW_USEDEFAULT;
}
else
{
/* TEMP: Put these where requested */
window_x = real_x;
window_y = real_y;
}
window_width = rect.right - rect.left;
window_height = rect.bottom - rect.top;
title = get_default_title (); title = get_default_title ();
if (!title || !*title) if (!title || !*title)
title = ""; title = "";
@ -595,8 +545,8 @@ _gdk_win32_display_create_surface (GdkDisplay *display,
MAKEINTRESOURCEW (klass), MAKEINTRESOURCEW (klass),
wtitle, wtitle,
dwStyle, dwStyle,
window_x, window_y, CW_USEDEFAULT, CW_USEDEFAULT,
window_width, window_height, CW_USEDEFAULT, CW_USEDEFAULT,
owner, owner,
NULL, NULL,
_gdk_dll_hinstance, _gdk_dll_hinstance,
@ -607,15 +557,6 @@ _gdk_win32_display_create_surface (GdkDisplay *display,
impl->initial_x = rect.left; impl->initial_x = rect.left;
impl->initial_y = rect.top; impl->initial_y = rect.top;
/* Now we know the initial position, move to actually specified position */
if (real_x != window_x || real_y != window_y)
{
API_CALL (SetWindowPos, (hwndNew,
SWP_NOZORDER_SPECIFIED,
real_x, real_y, 0, 0,
SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER));
}
g_object_ref (impl); g_object_ref (impl);
/* Take note: we're inserting a pointer into a heap-allocated /* Take note: we're inserting a pointer into a heap-allocated
* object (impl). Inserting a pointer to a stack variable * object (impl). Inserting a pointer to a stack variable

View File

@ -2753,6 +2753,14 @@ gdk_x11_display_get_screen (GdkDisplay *display)
return GDK_X11_DISPLAY (display)->screen; return GDK_X11_DISPLAY (display)->screen;
} }
static GdkSurface *
gdk_x11_display_create_surface (GdkDisplay *display,
GdkSurfaceType surface_type,
GdkSurface *parent)
{
return _gdk_x11_display_create_surface (display, surface_type, parent, 0, 0, 100, 100);
}
static GdkKeymap * static GdkKeymap *
gdk_x11_display_get_keymap (GdkDisplay *display) gdk_x11_display_get_keymap (GdkDisplay *display)
{ {
@ -3052,7 +3060,7 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
display_class->get_startup_notification_id = gdk_x11_display_get_startup_notification_id; display_class->get_startup_notification_id = gdk_x11_display_get_startup_notification_id;
G_GNUC_END_IGNORE_DEPRECATIONS G_GNUC_END_IGNORE_DEPRECATIONS
display_class->notify_startup_complete = gdk_x11_display_notify_startup_complete; display_class->notify_startup_complete = gdk_x11_display_notify_startup_complete;
display_class->create_surface = _gdk_x11_display_create_surface; display_class->create_surface = gdk_x11_display_create_surface;
display_class->get_keymap = gdk_x11_display_get_keymap; display_class->get_keymap = gdk_x11_display_get_keymap;
display_class->init_gl = gdk_x11_display_init_gl; display_class->init_gl = gdk_x11_display_init_gl;