mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-25 21:21:21 +00:00
Cache the display name. There is only one GdkDisplay on Win32, and
2005-09-09 Tor Lillqvist <tml@novell.com> * gdk/win32/gdkdisplay-win32.c (gdk_display_get_name): Cache the display name. There is only one GdkDisplay on Win32, and constructing the display name isn't entirely trivial, so cacheing is probably worth it. For instance GIMP calls this function a lot. (gdk_display_open): Call gdk_display_get_name() to prime the cached name. (gdk_display_get_n_screens, gdk_display_get_screen, gdk_display_get_default_screen): Verify parameter correctness like the X11 backend does. * gdk/win32/gdkscreen-win32.c (gdk_screen_make_display_name): Return a freshly allocated string, as the API specifies. Fixes a heap corruption problem that caused random errors and crashes in GIMP, for instance.
This commit is contained in:
parent
93bb0e9248
commit
0905c73a88
17
ChangeLog
17
ChangeLog
@ -1,3 +1,20 @@
|
|||||||
|
2005-09-09 Tor Lillqvist <tml@novell.com>
|
||||||
|
|
||||||
|
* gdk/win32/gdkdisplay-win32.c (gdk_display_get_name): Cache the
|
||||||
|
display name. There is only one GdkDisplay on Win32, and
|
||||||
|
constructing the display name isn't entirely trivial, so cacheing
|
||||||
|
is probably worth it. For instance GIMP calls this function a lot.
|
||||||
|
(gdk_display_open): Call gdk_display_get_name() to prime the
|
||||||
|
cached name.
|
||||||
|
(gdk_display_get_n_screens, gdk_display_get_screen,
|
||||||
|
gdk_display_get_default_screen): Verify parameter correctness like
|
||||||
|
the X11 backend does.
|
||||||
|
|
||||||
|
* gdk/win32/gdkscreen-win32.c (gdk_screen_make_display_name):
|
||||||
|
Return a freshly allocated string, as the API specifies. Fixes a
|
||||||
|
heap corruption problem that caused random errors and crashes in
|
||||||
|
GIMP, for instance.
|
||||||
|
|
||||||
2005-09-07 Matthias Clasen <mclasen@redhat.com>
|
2005-09-07 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
* gtk/gtkimcontextsimple.c (gtk_im_context_simple_filter_keypress):
|
* gtk/gtkimcontextsimple.c (gtk_im_context_simple_filter_keypress):
|
||||||
|
@ -1,3 +1,20 @@
|
|||||||
|
2005-09-09 Tor Lillqvist <tml@novell.com>
|
||||||
|
|
||||||
|
* gdk/win32/gdkdisplay-win32.c (gdk_display_get_name): Cache the
|
||||||
|
display name. There is only one GdkDisplay on Win32, and
|
||||||
|
constructing the display name isn't entirely trivial, so cacheing
|
||||||
|
is probably worth it. For instance GIMP calls this function a lot.
|
||||||
|
(gdk_display_open): Call gdk_display_get_name() to prime the
|
||||||
|
cached name.
|
||||||
|
(gdk_display_get_n_screens, gdk_display_get_screen,
|
||||||
|
gdk_display_get_default_screen): Verify parameter correctness like
|
||||||
|
the X11 backend does.
|
||||||
|
|
||||||
|
* gdk/win32/gdkscreen-win32.c (gdk_screen_make_display_name):
|
||||||
|
Return a freshly allocated string, as the API specifies. Fixes a
|
||||||
|
heap corruption problem that caused random errors and crashes in
|
||||||
|
GIMP, for instance.
|
||||||
|
|
||||||
2005-09-07 Matthias Clasen <mclasen@redhat.com>
|
2005-09-07 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
* gtk/gtkimcontextsimple.c (gtk_im_context_simple_filter_keypress):
|
* gtk/gtkimcontextsimple.c (gtk_im_context_simple_filter_keypress):
|
||||||
|
@ -236,6 +236,9 @@ gdk_display_open (const gchar *display_name)
|
|||||||
_gdk_input_init (_gdk_display);
|
_gdk_input_init (_gdk_display);
|
||||||
_gdk_dnd_init ();
|
_gdk_dnd_init ();
|
||||||
|
|
||||||
|
/* Precalculate display name */
|
||||||
|
(void) gdk_display_get_name (_gdk_display);
|
||||||
|
|
||||||
g_signal_emit_by_name (gdk_display_manager_get (),
|
g_signal_emit_by_name (gdk_display_manager_get (),
|
||||||
"display_opened", _gdk_display);
|
"display_opened", _gdk_display);
|
||||||
|
|
||||||
@ -253,9 +256,13 @@ gdk_display_get_name (GdkDisplay *display)
|
|||||||
HWINSTA hwinsta = GetProcessWindowStation ();
|
HWINSTA hwinsta = GetProcessWindowStation ();
|
||||||
char *window_station_name;
|
char *window_station_name;
|
||||||
DWORD n;
|
DWORD n;
|
||||||
DWORD session_id;
|
|
||||||
char *display_name;
|
char *display_name;
|
||||||
const char *retval;
|
static const char *display_name_cache = NULL;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
|
||||||
|
|
||||||
|
if (display_name_cache != NULL)
|
||||||
|
return display_name_cache;
|
||||||
|
|
||||||
n = 0;
|
n = 0;
|
||||||
GetUserObjectInformation (hdesk, UOI_NAME, &dummy, 0, &n);
|
GetUserObjectInformation (hdesk, UOI_NAME, &dummy, 0, &n);
|
||||||
@ -285,22 +292,22 @@ gdk_display_get_name (GdkDisplay *display)
|
|||||||
window_station_name = "WinSta0";
|
window_station_name = "WinSta0";
|
||||||
}
|
}
|
||||||
|
|
||||||
display_name = g_strdup_printf ("%ld\\%s\\%s",
|
display_name = g_strdup_printf ("%d\\%s\\%s",
|
||||||
get_session_id (), window_station_name,
|
get_session_id (), window_station_name,
|
||||||
desktop_name);
|
desktop_name);
|
||||||
|
|
||||||
retval = g_quark_to_string (g_quark_from_string (display_name));
|
GDK_NOTE (MISC, g_print ("gdk_display_get_name: %s\n", display_name));
|
||||||
|
|
||||||
g_free (display_name);
|
display_name_cache = display_name;
|
||||||
|
|
||||||
GDK_NOTE (MISC, g_print ("gdk_display_get_name: %s\n", retval));
|
return display_name_cache;
|
||||||
|
|
||||||
return retval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gint
|
gint
|
||||||
gdk_display_get_n_screens (GdkDisplay *display)
|
gdk_display_get_n_screens (GdkDisplay *display)
|
||||||
{
|
{
|
||||||
|
g_return_val_if_fail (GDK_IS_DISPLAY (display), 0);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,12 +315,17 @@ GdkScreen *
|
|||||||
gdk_display_get_screen (GdkDisplay *display,
|
gdk_display_get_screen (GdkDisplay *display,
|
||||||
gint screen_num)
|
gint screen_num)
|
||||||
{
|
{
|
||||||
|
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
|
||||||
|
g_return_val_if_fail (screen_num != 0, NULL);
|
||||||
|
|
||||||
return _gdk_screen;
|
return _gdk_screen;
|
||||||
}
|
}
|
||||||
|
|
||||||
GdkScreen *
|
GdkScreen *
|
||||||
gdk_display_get_default_screen (GdkDisplay *display)
|
gdk_display_get_default_screen (GdkDisplay *display)
|
||||||
{
|
{
|
||||||
|
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
|
||||||
|
|
||||||
return _gdk_screen;
|
return _gdk_screen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,5 +115,5 @@ _gdk_windowing_substitute_screen_number (const gchar *display_name,
|
|||||||
gchar *
|
gchar *
|
||||||
gdk_screen_make_display_name (GdkScreen *screen)
|
gdk_screen_make_display_name (GdkScreen *screen)
|
||||||
{
|
{
|
||||||
return gdk_display_get_name (_gdk_display);
|
return g_strdup (gdk_display_get_name (_gdk_display));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user