win32: get rid of _gdk_screen global variable

The screen is part of the display so it should be belong to it.
This commit is contained in:
Ignacio Casal Quinteiro 2016-01-15 11:45:45 -08:00
parent ea7c509afd
commit f6cc3be118
6 changed files with 25 additions and 19 deletions

View File

@ -259,9 +259,11 @@ inner_display_change_window_procedure (HWND hwnd,
}
case WM_DISPLAYCHANGE:
{
GdkWin32Display *win32_display = GDK_WIN32_DISPLAY (_gdk_display);
_gdk_monitor_init ();
_gdk_screen_init_root_window_size (GDK_WIN32_SCREEN (_gdk_screen));
g_signal_emit_by_name (_gdk_screen, "size_changed");
_gdk_screen_init_root_window_size (GDK_WIN32_SCREEN (win32_display->screen));
g_signal_emit_by_name (win32_display->screen, "size_changed");
return 0;
}
@ -322,6 +324,8 @@ register_display_change_notification (GdkDisplay *display)
GdkDisplay *
_gdk_win32_display_open (const gchar *display_name)
{
GdkWin32Display *win32_display;
GDK_NOTE (MISC, g_print ("gdk_display_open: %s\n", (display_name ? display_name : "NULL")));
if (display_name == NULL ||
@ -341,11 +345,13 @@ _gdk_win32_display_open (const gchar *display_name)
}
_gdk_display = g_object_new (GDK_TYPE_WIN32_DISPLAY, NULL);
_gdk_screen = g_object_new (GDK_TYPE_WIN32_SCREEN, NULL);
win32_display = GDK_WIN32_DISPLAY (_gdk_display);
win32_display->screen = g_object_new (GDK_TYPE_WIN32_SCREEN, NULL);
_gdk_monitor_init ();
_gdk_visual_init (_gdk_screen);
_gdk_screen_init_root_window (GDK_WIN32_SCREEN (_gdk_screen));
_gdk_visual_init (win32_display->screen);
_gdk_screen_init_root_window (GDK_WIN32_SCREEN (win32_display->screen));
_gdk_events_init ();
_gdk_input_init (_gdk_display);
_gdk_dnd_init ();
@ -431,9 +437,9 @@ gdk_win32_display_get_name (GdkDisplay *display)
static GdkScreen *
gdk_win32_display_get_default_screen (GdkDisplay *display)
{
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
g_return_val_if_fail (GDK_IS_WIN32_DISPLAY (display), NULL);
return _gdk_screen;
return GDK_WIN32_DISPLAY (display)->screen;
}
static GdkWindow *

View File

@ -26,6 +26,8 @@ struct _GdkWin32Display
{
GdkDisplay display;
GdkScreen *screen;
Win32CursorTheme *cursor_theme;
gchar *cursor_theme_name;
int cursor_theme_size;

View File

@ -28,7 +28,6 @@
#include "gdkprivate-win32.h"
GdkDisplay *_gdk_display = NULL;
GdkScreen *_gdk_screen = NULL;
gint _gdk_num_monitors;
GdkWin32Monitor *_gdk_monitors = NULL;

View File

@ -256,7 +256,6 @@ void _gdk_other_api_failed (const gchar *where,
extern LRESULT CALLBACK _gdk_win32_window_procedure (HWND, UINT, WPARAM, LPARAM);
extern GdkDisplay *_gdk_display;
extern GdkScreen *_gdk_screen;
extern gint _gdk_num_monitors;
typedef struct _GdkWin32Monitor GdkWin32Monitor;

View File

@ -158,7 +158,7 @@ gdk_win32_screen_get_root_window (GdkScreen *screen)
static gint
gdk_win32_screen_get_n_monitors (GdkScreen *screen)
{
g_return_val_if_fail (screen == _gdk_screen, 0);
g_return_val_if_fail (screen == gdk_display_get_default_screen (gdk_display_get_default ()), 0);
return _gdk_num_monitors;
}
@ -166,7 +166,7 @@ gdk_win32_screen_get_n_monitors (GdkScreen *screen)
static gint
gdk_win32_screen_get_primary_monitor (GdkScreen *screen)
{
g_return_val_if_fail (screen == _gdk_screen, 0);
g_return_val_if_fail (screen == gdk_display_get_default_screen (gdk_display_get_default ()), 0);
return 0;
}
@ -175,7 +175,7 @@ static gint
gdk_win32_screen_get_monitor_width_mm (GdkScreen *screen,
gint num_monitor)
{
g_return_val_if_fail (screen == _gdk_screen, 0);
g_return_val_if_fail (screen == gdk_display_get_default_screen (gdk_display_get_default ()), 0);
g_return_val_if_fail (num_monitor < _gdk_num_monitors, 0);
return _gdk_monitors[num_monitor].width_mm;
@ -185,7 +185,7 @@ static gint
gdk_win32_screen_get_monitor_height_mm (GdkScreen *screen,
gint num_monitor)
{
g_return_val_if_fail (screen == _gdk_screen, 0);
g_return_val_if_fail (screen == gdk_display_get_default_screen (gdk_display_get_default ()), 0);
g_return_val_if_fail (num_monitor < _gdk_num_monitors, 0);
return _gdk_monitors[num_monitor].height_mm;
@ -195,7 +195,7 @@ static gchar *
gdk_win32_screen_get_monitor_plug_name (GdkScreen *screen,
gint num_monitor)
{
g_return_val_if_fail (screen == _gdk_screen, 0);
g_return_val_if_fail (screen == gdk_display_get_default_screen (gdk_display_get_default ()), 0);
g_return_val_if_fail (num_monitor < _gdk_num_monitors, 0);
return g_strdup (_gdk_monitors[num_monitor].name);
@ -206,7 +206,7 @@ gdk_win32_screen_get_monitor_geometry (GdkScreen *screen,
gint num_monitor,
GdkRectangle *dest)
{
g_return_if_fail (screen == _gdk_screen);
g_return_if_fail (screen == gdk_display_get_default_screen (gdk_display_get_default ()));
g_return_if_fail (num_monitor < _gdk_num_monitors);
*dest = _gdk_monitors[num_monitor].rect;
@ -215,7 +215,7 @@ gdk_win32_screen_get_monitor_geometry (GdkScreen *screen,
static gint
gdk_win32_screen_get_number (GdkScreen *screen)
{
g_return_val_if_fail (screen == _gdk_screen, 0);
g_return_val_if_fail (screen == gdk_display_get_default_screen (gdk_display_get_default ()), 0);
return 0;
}

View File

@ -81,7 +81,7 @@ static void _gdk_win32_impl_release_dc (GdkWindowImplWin32 *impl);
GdkScreen *
GDK_WINDOW_SCREEN (GObject *win)
{
return _gdk_screen;
return gdk_display_get_default_screen (gdk_display_get_default ());
}
struct _GdkWin32Window {
@ -708,7 +708,7 @@ gdk_win32_window_foreign_new_for_display (GdkDisplay *display,
return g_object_ref (window);
window = _gdk_display_create_window (display);
window->visual = gdk_screen_get_system_visual (_gdk_screen);
window->visual = gdk_screen_get_system_visual (gdk_display_get_default_screen (display));
window->impl = g_object_new (GDK_TYPE_WINDOW_IMPL_WIN32, NULL);
window->impl_window = window;
impl = GDK_WINDOW_IMPL_WIN32 (window->impl);
@ -2136,7 +2136,7 @@ gdk_display_warp_device (GdkDisplay *display,
gint y)
{
g_return_if_fail (display == _gdk_display);
g_return_if_fail (screen == _gdk_screen);
g_return_if_fail (screen == gdk_display_get_default_screen (display));
g_return_if_fail (GDK_IS_DEVICE (device));
g_return_if_fail (display == gdk_device_get_display (device));