summaryrefslogtreecommitdiff
path: root/gdk/win32
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2011-11-10 21:32:50 +0100
committerAlexander Larsson <alexl@redhat.com>2011-11-10 21:32:50 +0100
commita2b879fe532f4d60ceb88d56f6b581a0a7aca3b1 (patch)
tree9abd13fcdc8af8e5c89cd53fe5b3894d837ce503 /gdk/win32
parent2f14732b1d48b5c4abf378daa0875881ad507c0f (diff)
downloadgtk+-a2b879fe532f4d60ceb88d56f6b581a0a7aca3b1.tar.gz
win32: Make grab cursors work again
Diffstat (limited to 'gdk/win32')
-rw-r--r--gdk/win32/gdkdevice-win32.c43
-rw-r--r--gdk/win32/gdkevents-win32.c60
-rw-r--r--gdk/win32/gdkprivate-win32.h2
3 files changed, 46 insertions, 59 deletions
diff --git a/gdk/win32/gdkdevice-win32.c b/gdk/win32/gdkdevice-win32.c
index 09ec36a150..93fc5198f8 100644
--- a/gdk/win32/gdkdevice-win32.c
+++ b/gdk/win32/gdkdevice-win32.c
@@ -318,8 +318,37 @@ gdk_device_win32_grab (GdkDevice *device,
GdkCursor *cursor,
guint32 time_)
{
+ GdkWindowImplWin32 *impl = GDK_WINDOW_IMPL_WIN32 (window->impl);
+ HCURSOR hcursor;
+ GdkWin32Cursor *cursor_private;
+
+ cursor_private = (GdkWin32Cursor*) cursor;
+
if (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD)
- SetCapture (GDK_WINDOW_HWND (window));
+ {
+ if (!cursor)
+ hcursor = NULL;
+ else if ((hcursor = CopyCursor (cursor_private->hcursor)) == NULL)
+ WIN32_API_FAILED ("CopyCursor");
+
+ if (_gdk_win32_grab_cursor != NULL)
+ {
+ if (GetCursor () == _gdk_win32_grab_cursor)
+ SetCursor (NULL);
+ DestroyCursor (_gdk_win32_grab_cursor);
+ }
+
+ _gdk_win32_grab_cursor = hcursor;
+
+ if (_gdk_win32_grab_cursor != NULL)
+ SetCursor (_gdk_win32_grab_cursor);
+ else if (impl->hcursor != NULL)
+ SetCursor (impl->hcursor);
+ else
+ SetCursor (LoadCursor (NULL, IDC_ARROW));
+
+ SetCapture (GDK_WINDOW_HWND (window));
+ }
return GDK_GRAB_SUCCESS;
}
@@ -338,7 +367,17 @@ gdk_device_win32_ungrab (GdkDevice *device,
info->serial_end = 0;
if (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD)
- ReleaseCapture ();
+ {
+ if (_gdk_win32_grab_cursor != NULL)
+ {
+ if (GetCursor () == _gdk_win32_grab_cursor)
+ SetCursor (NULL);
+ DestroyCursor (_gdk_win32_grab_cursor);
+ }
+ _gdk_win32_grab_cursor = NULL;
+
+ ReleaseCapture ();
+ }
_gdk_display_device_grab_update (display, device, NULL, 0);
}
diff --git a/gdk/win32/gdkevents-win32.c b/gdk/win32/gdkevents-win32.c
index 2627e79635..6fc6f58216 100644
--- a/gdk/win32/gdkevents-win32.c
+++ b/gdk/win32/gdkevents-win32.c
@@ -112,7 +112,7 @@ static gboolean gdk_event_dispatch (GSource *source,
static GList *client_filters; /* Filters for client messages */
extern gint _gdk_input_ignore_core;
-static HCURSOR p_grab_cursor;
+HCURSOR _gdk_win32_grab_cursor;
static GSourceFuncs event_funcs = {
gdk_event_prepare,
@@ -445,60 +445,6 @@ event_mask_string (GdkEventMask mask)
#endif
-GdkGrabStatus
-_gdk_windowing_device_grab (GdkDevice *device,
- GdkWindow *window,
- GdkWindow *native_window,
- gboolean owner_events,
- GdkEventMask event_mask,
- GdkWindow *confine_to,
- GdkCursor *cursor,
- guint32 time)
-{
- HCURSOR hcursor;
- GdkWin32Cursor *cursor_private;
- gint return_val;
- GdkWindowImplWin32 *impl = GDK_WINDOW_IMPL_WIN32 (native_window->impl);
-
- g_return_val_if_fail (window != NULL, 0);
- g_return_val_if_fail (GDK_IS_WINDOW (window), 0);
- g_return_val_if_fail (confine_to == NULL || GDK_IS_WINDOW (confine_to), 0);
-
- cursor_private = (GdkWin32Cursor*) cursor;
-
- if (!cursor)
- hcursor = NULL;
- else if ((hcursor = CopyCursor (cursor_private->hcursor)) == NULL)
- WIN32_API_FAILED ("CopyCursor");
-
- return_val = GDK_DEVICE_GET_CLASS (device)->grab (device,
- native_window,
- owner_events,
- event_mask,
- confine_to,
- cursor,
- time);
-
- /* TODO_CSW: grab brokens, confine window, input_grab */
- if (p_grab_cursor != NULL)
- {
- if (GetCursor () == p_grab_cursor)
- SetCursor (NULL);
- DestroyCursor (p_grab_cursor);
- }
-
- p_grab_cursor = hcursor;
-
- if (p_grab_cursor != NULL)
- SetCursor (p_grab_cursor);
- else if (impl->hcursor != NULL)
- SetCursor (impl->hcursor);
- else
- SetCursor (LoadCursor (NULL, IDC_ARROW));
-
- return return_val;
-}
-
static GdkWindow *
find_window_for_mouse_event (GdkWindow* reported_window,
MSG* msg)
@@ -2682,8 +2628,8 @@ gdk_event_translate (MSG *msg,
if (grab_window == NULL && LOWORD (msg->lParam) != HTCLIENT)
break;
- if (grab_window != NULL && p_grab_cursor != NULL)
- hcursor = p_grab_cursor;
+ if (grab_window != NULL && _gdk_win32_grab_cursor != NULL)
+ hcursor = _gdk_win32_grab_cursor;
else if (!GDK_WINDOW_DESTROYED (window))
hcursor = GDK_WINDOW_IMPL_WIN32 (window->impl)->hcursor;
else
diff --git a/gdk/win32/gdkprivate-win32.h b/gdk/win32/gdkprivate-win32.h
index c039c9ef39..c9625cb43c 100644
--- a/gdk/win32/gdkprivate-win32.h
+++ b/gdk/win32/gdkprivate-win32.h
@@ -356,6 +356,8 @@ extern GHashTable *_format_atom_table;
/* Hold the result of a delayed rendering */
extern HGLOBAL _delayed_rendering_data;
+extern HCURSOR _gdk_win32_grab_cursor;
+
HGLOBAL _gdk_win32_selection_convert_to_dib (HGLOBAL hdata,
GdkAtom target);