diff options
author | Руслан Ижбулатов <lrn1986@gmail.com> | 2015-05-13 07:45:40 +0000 |
---|---|---|
committer | Руслан Ижбулатов <lrn1986@gmail.com> | 2015-05-20 08:42:24 +0000 |
commit | 26c24328d57aa0c7d727008706c5d4aa46dac9b1 (patch) | |
tree | aa7f953d8f35ee8e8b93e13bbdf83b9c0ae0da69 /gdk/win32/gdkprivate-win32.h | |
parent | 641fbd86d796bb0f7838b1d7387031a106386439 (diff) | |
download | gtk+-26c24328d57aa0c7d727008706c5d4aa46dac9b1.tar.gz |
GDK: Add cursor theme support to W32 backend
Load themed cursors from the same places they are loaded on freedesktop systems,
but use W32 API functions to do so (works for .cur/.ani cursors instead of X
cursors).
Refactor the code for cursor handling. Prefer loading cursors by name.
Do not load actual cursors when loading the theme. Find the files and remember
the arguments/calls for loading them instead. Keeping HCURSOR instance in the
hashmap would result in multiple GdkCursors using the same HCURSOR. Given that
we use DestroyCursor() to off them, this would cause problems (at the very
least - DestroyCursor() would fail).
Store GdkCursor instances in a cache. Update cached cursors when theme changes.
Recognize "system" theme as a special (and default) case. When it is set,
prefer system cursors and fall back to Adwaita cursors and (as a last resort)
built-in X cursors. Otherwise prefer theme cursors and fall back to system and
X cursors.
Force GTK to use "left_ptr" cursor when no cursor is set. Using NULL makes
it use the system default "arrow", which is not the intended behaviour when
a non-system theme is selected.
Ignore cursor size setting and query the OS for the required cursor size, as
Windows (almost) does not allow setting cursors of arbitrary size.
https://bugzilla.gnome.org/show_bug.cgi?id=749287
Diffstat (limited to 'gdk/win32/gdkprivate-win32.h')
-rw-r--r-- | gdk/win32/gdkprivate-win32.h | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/gdk/win32/gdkprivate-win32.h b/gdk/win32/gdkprivate-win32.h index 98b64a3edb..a94a1885e2 100644 --- a/gdk/win32/gdkprivate-win32.h +++ b/gdk/win32/gdkprivate-win32.h @@ -37,6 +37,7 @@ #include <gdk/gdkprivate.h> #include <gdk/gdkcursorprivate.h> #include <gdk/win32/gdkwindow-win32.h> +#include <gdk/win32/gdkwin32display.h> #include "gdkinternals.h" @@ -114,6 +115,8 @@ typedef struct _GdkWin32SingleFont GdkWin32SingleFont; struct _GdkWin32Cursor { GdkCursor cursor; + + gchar *name; HCURSOR hcursor; }; @@ -374,6 +377,42 @@ HICON _gdk_win32_pixbuf_to_hcursor (GdkPixbuf *pixbuf, gint x_hotspot, gint y_hotspot); +void _gdk_win32_display_init_cursors (GdkWin32Display *display); +void _gdk_win32_display_finalize_cursors (GdkWin32Display *display); +void _gdk_win32_display_update_cursors (GdkWin32Display *display); + +typedef struct _Win32CursorTheme Win32CursorTheme; + +struct _Win32CursorTheme { + GHashTable *named_cursors; +}; + +typedef enum GdkWin32CursorLoadType { + GDK_WIN32_CURSOR_LOAD_FROM_FILE = 0, + GDK_WIN32_CURSOR_LOAD_FROM_RESOURCE_NULL = 1, + GDK_WIN32_CURSOR_LOAD_FROM_RESOURCE_THIS = 2, + GDK_WIN32_CURSOR_CREATE = 3, +} GdkWin32CursorLoadType; + +typedef struct _Win32Cursor Win32Cursor; + +struct _Win32Cursor { + GdkWin32CursorLoadType load_type; + gunichar2 *resource_name; + gint width; + gint height; + guint load_flags; + gint xcursor_number; + GdkCursorType cursor_type; +}; + +Win32CursorTheme *win32_cursor_theme_load (const gchar *name, + gint size); +Win32Cursor * win32_cursor_theme_get_cursor (Win32CursorTheme *theme, + const gchar *name); +void win32_cursor_theme_destroy (Win32CursorTheme *theme); +Win32CursorTheme *_gdk_win32_display_get_cursor_theme (GdkWin32Display *win32_display); + /* GdkDisplay member functions */ GdkCursor *_gdk_win32_display_get_cursor_for_type (GdkDisplay *display, GdkCursorType cursor_type); |