/** * gdk_win32_display_set_cursor_theme: * @display: (type GdkWin32Display): a #GdkDisplay * @name: (allow-none): the name of the cursor theme to use, or %NULL to unset * a previously set value * @size: the cursor size to use, or 0 to keep the previous size * * Sets the cursor theme from which the images for cursor * should be taken. * * If the windowing system supports it, existing cursors created * with gdk_cursor_new(), gdk_cursor_new_for_display() and * gdk_cursor_new_from_name() are updated to reflect the theme * change. Custom cursors constructed with * gdk_cursor_new_from_texture() will have to be handled * by the application (GTK+ applications can learn about * cursor theme changes by listening for change notification * for the corresponding #GtkSetting). */ void gdk_win32_display_set_cursor_theme (GdkDisplay *display, const gchar *name, gint size) { gint cursor_size; gint w, h; Win32CursorTheme *theme; GdkWin32Display *win32_display = GDK_WIN32_DISPLAY (display); g_assert (win32_display); if (name == NULL) name = "system"; w = GetSystemMetrics (SM_CXCURSOR); h = GetSystemMetrics (SM_CYCURSOR); /* We can load cursors of any size, but SetCursor() will scale them back * to this value. It's possible to break that restrictions with SetSystemCursor(), * but that will override cursors for the whole desktop session. */ cursor_size = (w == h) ? w : size; if (win32_display->cursor_theme_name != NULL && g_strcmp0 (name, win32_display->cursor_theme_name) == 0 && win32_display->cursor_theme_size == cursor_size) return; theme = win32_cursor_theme_load (name, cursor_size); if (theme == NULL) { g_warning ("Failed to load cursor theme %s", name); return; } if (win32_display->cursor_theme) { win32_cursor_theme_destroy (win32_display->cursor_theme); win32_display->cursor_theme = NULL; } win32_display->cursor_theme = theme; g_free (win32_display->cursor_theme_name); win32_display->cursor_theme_name = g_strdup (name); win32_display->cursor_theme_size = cursor_size; _gdk_win32_display_update_cursors (win32_display); }
static void gdk_win32_display_finalize (GObject *object) { GdkWin32Display *display_win32 = GDK_WIN32_DISPLAY (object); _gdk_win32_display_finalize_cursors (display_win32); _gdk_win32_dnd_exit (); g_ptr_array_free (display_win32->monitors, TRUE); while (display_win32->filters) _gdk_win32_message_filter_unref (display_win32, display_win32->filters->data); G_OBJECT_CLASS (gdk_win32_display_parent_class)->finalize (object); }
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 || g_ascii_strcasecmp (display_name, gdk_display_get_name (_gdk_display)) == 0) { if (_gdk_display != NULL) { GDK_NOTE (MISC, g_print ("... return _gdk_display\n")); return _gdk_display; } } else { GDK_NOTE (MISC, g_print ("... return NULL\n")); return NULL; } _gdk_display = g_object_new (GDK_TYPE_WIN32_DISPLAY, 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 (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 (); /* Precalculate display name */ (void) gdk_display_get_name (_gdk_display); register_display_change_notification (_gdk_display); g_signal_emit_by_name (_gdk_display, "opened"); GDK_NOTE (MISC, g_print ("... _gdk_display now set up\n")); return _gdk_display; }
static void gdk_win32_display_dispose (GObject *object) { GdkWin32Display *display_win32 = GDK_WIN32_DISPLAY (object); if (display_win32->hwnd != NULL) { DestroyWindow (display_win32->hwnd); display_win32->hwnd = NULL; } if (display_win32->clipboard_hwnd != NULL) { DestroyWindow (display_win32->clipboard_hwnd); display_win32->clipboard_hwnd = NULL; _hwnd_next_viewer = NULL; } G_OBJECT_CLASS (gdk_win32_display_parent_class)->dispose (object); }
/* * Creates a hidden window and adds it to the clipboard chain */ static gboolean register_clipboard_notification (GdkDisplay *display) { GdkWin32Display *display_win32 = GDK_WIN32_DISPLAY (display); WNDCLASS wclass = { 0, }; ATOM klass; wclass.lpszClassName = "GdkClipboardNotification"; wclass.lpfnWndProc = _clipboard_window_procedure; wclass.hInstance = _gdk_app_hmodule; klass = RegisterClass (&wclass); if (!klass) return FALSE; display_win32->clipboard_hwnd = CreateWindow (MAKEINTRESOURCE (klass), NULL, WS_POPUP, 0, 0, 0, 0, NULL, NULL, _gdk_app_hmodule, NULL); if (display_win32->clipboard_hwnd == NULL) goto failed; SetLastError (0); _hwnd_next_viewer = SetClipboardViewer (display_win32->clipboard_hwnd); if (_hwnd_next_viewer == NULL && GetLastError() != 0) goto failed; /* FIXME: http://msdn.microsoft.com/en-us/library/ms649033(v=VS.85).aspx */ /* This is only supported by Vista, and not yet by mingw64 */ /* if (AddClipboardFormatListener (hwnd) == FALSE) */ /* goto failed; */ return TRUE; failed: g_critical ("Failed to install clipboard viewer"); UnregisterClass (MAKEINTRESOURCE (klass), _gdk_app_hmodule); return FALSE; }
static void gdk_win32_display_dispose (GObject *object) { GdkWin32Display *display_win32 = GDK_WIN32_DISPLAY (object); if (display_win32->hwnd != NULL) { DestroyWindow (display_win32->hwnd); display_win32->hwnd = NULL; } if (display_win32->have_at_least_win81) { if (display_win32->shcore_funcs.hshcore != NULL) { FreeLibrary (display_win32->shcore_funcs.hshcore); display_win32->shcore_funcs.hshcore = NULL; } } G_OBJECT_CLASS (gdk_win32_display_parent_class)->dispose (object); }
/* Use a hidden window to be notified about display changes */ static void register_display_change_notification (GdkDisplay *display) { GdkWin32Display *display_win32 = GDK_WIN32_DISPLAY (display); WNDCLASS wclass = { 0, }; ATOM klass; wclass.lpszClassName = "GdkDisplayChange"; wclass.lpfnWndProc = display_change_window_procedure; wclass.hInstance = _gdk_app_hmodule; klass = RegisterClass (&wclass); if (klass) { display_win32->hwnd = CreateWindow (MAKEINTRESOURCE (klass), NULL, WS_POPUP, 0, 0, 0, 0, NULL, NULL, _gdk_app_hmodule, NULL); if (!display_win32->hwnd) { UnregisterClass (MAKEINTRESOURCE (klass), _gdk_app_hmodule); } } }
static void gdk_device_wintab_query_state (GdkDevice *device, GdkSurface *window, GdkSurface **child_window, gdouble *root_x, gdouble *root_y, gdouble *win_x, gdouble *win_y, GdkModifierType *mask) { GdkDeviceWintab *device_wintab; POINT point; HWND hwnd, hwndc; int scale; device_wintab = GDK_DEVICE_WINTAB (device); if (window) { scale = GDK_SURFACE_IMPL_WIN32 (window->impl)->surface_scale; hwnd = GDK_SURFACE_HWND (window); } else { GdkDisplay *display = gdk_device_get_display (device); scale = GDK_WIN32_DISPLAY (display)->surface_scale; hwnd = NULL; } GetCursorPos (&point); if (root_x) *root_x = point.x / scale; if (root_y) *root_y = point.y / scale; if (hwnd) ScreenToClient (hwnd, &point); if (win_x) *win_x = point.x / scale; if (win_y) *win_y = point.y / scale; if (!window) { if (win_x) *win_x += _gdk_offset_x; if (win_y) *win_y += _gdk_offset_y; } if (hwnd && child_window) { hwndc = ChildWindowFromPoint (hwnd, point); if (hwndc && hwndc != hwnd) *child_window = gdk_win32_handle_table_lookup (hwndc); else *child_window = NULL; /* Direct child unknown to gdk */ } if (mask) { *mask = get_current_mask (); *mask &= 0xFF; /* Mask away core pointer buttons */ *mask |= ((device_wintab->button_state << 8) & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK | GDK_BUTTON4_MASK | GDK_BUTTON5_MASK)); } }