gdk: Spread the errors

Call gdk_ensure_initialized() directly in gdk_display_open_default(),
gdk_display_open(), gdk_x11_display_open() and gdk_display_get_default(),
so we get the right function name in the error message. These functions
are likely candidates that people might call without ensuring that GDK is
initialized.
This commit is contained in:
Matthias Clasen 2024-10-15 20:57:40 -04:00
parent c239788a34
commit 1f20d0c9ed
4 changed files with 9 additions and 2 deletions

View File

@ -366,6 +366,8 @@ gdk_display_open_default (void)
{
GdkDisplay *display;
gdk_ensure_initialized ();
display = gdk_display_get_default ();
if (!display)

View File

@ -1198,8 +1198,9 @@ gdk_display_get_app_launch_context (GdkDisplay *display)
GdkDisplay *
gdk_display_open (const char *display_name)
{
return gdk_display_manager_open_display (gdk_display_manager_get (),
display_name);
gdk_ensure_initialized ();
return gdk_display_manager_open_display (gdk_display_manager_get (), display_name);
}
gulong

View File

@ -332,6 +332,8 @@ gdk_display_manager_get_default_display (GdkDisplayManager *manager)
GdkDisplay *
gdk_display_get_default (void)
{
gdk_ensure_initialized ();
return gdk_display_manager_get_default_display (gdk_display_manager_get ());
}

View File

@ -1432,6 +1432,8 @@ gdk_x11_display_open (const char *display_name)
gboolean rgba;
gboolean composited;
gdk_ensure_initialized ();
XInitThreads ();
xdisplay = XOpenDisplay (display_name);