[gtk+] GDK/Win32: Fix build after GDK Root Window and DND changes
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] GDK/Win32: Fix build after GDK Root Window and DND changes
- Date: Wed, 22 Nov 2017 14:19:18 +0000 (UTC)
commit e076cc7b1f609ad278c3759563d63781f42e4dc2
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Fri Nov 17 15:27:10 2017 +0800
GDK/Win32: Fix build after GDK Root Window and DND changes
Ensure that things build again, and instead use the Windows API to
acquire the screen dimensions (note: this may need to be scaled for
HiDPI, but since I do not own a WinTab-based device, I will need to
keep the dimensions as-is for now).
Also update the gdkdnd-win32.c code to use formats rather than targets.
https://bugzilla.gnome.org/show_bug.cgi?id=773299
gdk/win32/gdkdevice-win32.c | 4 ++--
gdk/win32/gdkdevice-wintab.c | 30 ++++++++++++++++++++----------
gdk/win32/gdkdevicemanager-win32.c | 2 +-
gdk/win32/gdkdisplay-win32.h | 1 -
gdk/win32/gdkdnd-win32.c | 33 +++++++++++++++++++--------------
gdk/win32/gdkprivate-win32.h | 6 +++++-
gdk/win32/gdkselection-win32.c | 6 +++---
7 files changed, 50 insertions(+), 32 deletions(-)
---
diff --git a/gdk/win32/gdkdevice-win32.c b/gdk/win32/gdkdevice-win32.c
index b2ad705..110d73d 100644
--- a/gdk/win32/gdkdevice-win32.c
+++ b/gdk/win32/gdkdevice-win32.c
@@ -22,9 +22,9 @@
#include <windowsx.h>
#include <objbase.h>
-#include "gdkdisplayprivate.h"
#include "gdkdevice-win32.h"
#include "gdkwin32.h"
+#include "gdkdisplay-win32.h"
G_DEFINE_TYPE (GdkDeviceWin32, gdk_device_win32, GDK_TYPE_DEVICE)
@@ -119,7 +119,7 @@ gdk_device_win32_query_state (GdkDevice *device,
{
GdkDisplay *display = gdk_device_get_display (device);
- scale = GDK_WIN32_SCREEN (GDK_WIN32_DISPLAY (display)->screen)->window_scale;
+ scale = GDK_WIN32_DISPLAY (display)->window_scale;
hwnd = NULL;
}
diff --git a/gdk/win32/gdkdevice-wintab.c b/gdk/win32/gdkdevice-wintab.c
index 8b5d321..0de1ecb 100644
--- a/gdk/win32/gdkdevice-wintab.c
+++ b/gdk/win32/gdkdevice-wintab.c
@@ -24,7 +24,7 @@
#include "gdkwin32.h"
#include "gdkdevice-wintab.h"
-#include "gdkdisplayprivate.h"
+#include "gdkdisplay-win32.h"
G_DEFINE_TYPE (GdkDeviceWintab, gdk_device_wintab, GDK_TYPE_DEVICE)
@@ -132,7 +132,7 @@ gdk_device_wintab_query_state (GdkDevice *device,
{
GdkDisplay *display = gdk_device_get_display (device);
- scale = GDK_WIN32_SCREEN (GDK_WIN32_DISPLAY (display)->screen)->window_scale;
+ scale = GDK_WIN32_DISPLAY (display)->window_scale;
hwnd = NULL;
}
@@ -144,7 +144,7 @@ gdk_device_wintab_query_state (GdkDevice *device,
if (root_y)
*root_y = point.y / scale;
- if (hwn)
+ if (hwnd)
ScreenToClient (hwnd, &point);
if (win_x)
@@ -256,13 +256,23 @@ _gdk_device_wintab_translate_axes (GdkDeviceWintab *device_wintab,
device_wintab->last_axis_data[i],
&axes[i]);
else
- _gdk_device_translate_screen_coord (device, window,
- root_x, root_y,
- GDK_WIN32_SCREEN (GDK_WIN32_DISPLAY
(display)->screen)->width,
- GDK_WIN32_SCREEN (GDK_WIN32_DISPLAY
(display)->screen)->height,
- i,
- device_wintab->last_axis_data[i],
- &axes[i]);
+ {
+ HMONITOR hmonitor;
+ MONITORINFO minfo = {sizeof (MONITORINFO),};
+
+ hmonitor = MonitorFromWindow (GDK_WINDOW_HWND (window),
+ MONITOR_DEFAULTTONEAREST);
+ GetMonitorInfo (hmonitor, &minfo);
+
+ /* XXX: the dimensions from minfo may need to be scaled for HiDPI usage */
+ _gdk_device_translate_screen_coord (device, window,
+ root_x, root_y,
+ minfo.rcWork.right - minfo.rcWork.left,
+ minfo.rcWork.bottom - minfo.rcWork.top,
+ i,
+ device_wintab->last_axis_data[i],
+ &axes[i]);
+ }
if (use == GDK_AXIS_X)
temp_x = axes[i];
else if (use == GDK_AXIS_Y)
diff --git a/gdk/win32/gdkdevicemanager-win32.c b/gdk/win32/gdkdevicemanager-win32.c
index eef0453..3bff210 100644
--- a/gdk/win32/gdkdevicemanager-win32.c
+++ b/gdk/win32/gdkdevicemanager-win32.c
@@ -434,7 +434,7 @@ wintab_init_check (GdkDeviceManagerWin32 *device_manager)
ndevices, ncursors));
#endif
/* Create a dummy window to receive wintab events */
- wintab_window = gdk_window_new_popup (display, GDK_ALL_EVENTS_MASK, &(GdkRectangle) { -100, -100, 2, 2 });
+ wintab_window = gdk_window_new_popup (display, &(GdkRectangle) { -100, -100, 2, 2 });
g_object_ref (wintab_window);
for (devix = 0; devix < ndevices; devix++)
diff --git a/gdk/win32/gdkdisplay-win32.h b/gdk/win32/gdkdisplay-win32.h
index fa1eb19..05239c6 100644
--- a/gdk/win32/gdkdisplay-win32.h
+++ b/gdk/win32/gdkdisplay-win32.h
@@ -18,7 +18,6 @@
*/
#include "gdkdisplayprivate.h"
-#include "gdkscreen-win32.h"
#ifndef __GDK_DISPLAY__WIN32_H__
#define __GDK_DISPLAY__WIN32_H__
diff --git a/gdk/win32/gdkdnd-win32.c b/gdk/win32/gdkdnd-win32.c
index 5d20b88..a7eb521 100644
--- a/gdk/win32/gdkdnd-win32.c
+++ b/gdk/win32/gdkdnd-win32.c
@@ -46,7 +46,7 @@
* data types, and file list dnd (which is handled seperately as it predates OLE2
* both in this implementation and on Windows in general).
*
- * As such, the data type conversion from gdk selection targets to OLE2 CF_* data
+ * As such, the data type conversion from gdk selection formats to OLE2 CF_* data
* type specifiers is partially hardwired. Fixing this is complicated by (a) the
* fact that the widget’s declared selection types aren’t accessible in calls here
* that need to declare the corresponding OLE2 data types, and (b) there isn’t a
@@ -1190,8 +1190,8 @@ target_context_new (GdkWindow *window)
}
static source_drag_context *
-source_context_new (GdkWindow *window,
- GList *targets)
+source_context_new (GdkWindow *window,
+ GdkContentFormats *formats)
{
GdkDragContext *context;
GdkWin32DragContext *context_win32;
@@ -1211,7 +1211,7 @@ source_context_new (GdkWindow *window,
g_object_ref (window);
result->context->dest_window = NULL;
- result->context->targets = g_list_copy (targets);
+ result->context->formats = gdk_content_formats_ref (formats);
context_win32->ole2_dnd_iface = (IUnknown *) &result->ids;
idropsource_addref (&result->ids);
@@ -1417,6 +1417,9 @@ gdk_dropfiles_filter (GdkXEvent *xev,
POINT pt;
gint nfiles, i;
gchar *fileName, *linkedFile;
+ GPtrArray *formats;
+
+ formats = g_ptr_array_new ();
if (msg->message == WM_DROPFILES)
{
@@ -1432,8 +1435,10 @@ gdk_dropfiles_filter (GdkXEvent *xev,
g_object_ref (context->dest_window);
/* WM_DROPFILES drops are always file names */
- context->targets =
- g_list_append (NULL, _text_uri_list);
+ g_ptr_array_add (formats, _text_uri_list);
+ context->formats = gdk_content_formats_new ((const char **) formats->pdata, formats->len);
+ g_ptr_array_unref (formats);
+
context->actions = GDK_ACTION_COPY;
context->suggested_action = GDK_ACTION_COPY;
current_dest_drag = context;
@@ -1664,7 +1669,7 @@ local_send_enter (GdkDragContext *context,
new_context->dest_window = context->dest_window;
g_object_ref (new_context->dest_window);
- new_context->targets = g_list_copy (context->targets);
+ new_context->formats = gdk_content_formats_ref (context->formats);
gdk_window_set_events (new_context->source_window,
gdk_window_get_events (new_context->source_window) |
@@ -1789,11 +1794,11 @@ gdk_drag_do_leave (GdkDragContext *context,
}
GdkDragContext *
-_gdk_win32_window_drag_begin (GdkWindow *window,
- GdkDevice *device,
- GList *targets,
- gint x_root,
- gint y_root)
+_gdk_win32_window_drag_begin (GdkWindow *window,
+ GdkDevice *device,
+ GdkContentFormats *formats,
+ gint x_root,
+ gint y_root)
{
if (!use_ole2_dnd)
{
@@ -1807,7 +1812,7 @@ _gdk_win32_window_drag_begin (GdkWindow *window,
new_context->source_window = window;
g_object_ref (window);
- new_context->targets = g_list_copy (targets);
+ new_context->formats = gdk_content_formats_ref (formats);
new_context->actions = 0;
return new_context;
@@ -1820,7 +1825,7 @@ _gdk_win32_window_drag_begin (GdkWindow *window,
GDK_NOTE (DND, g_print ("gdk_drag_begin\n"));
- ctx = source_context_new (window, targets);
+ ctx = source_context_new (window, formats);
_dnd_source_state = GDK_WIN32_DND_PENDING;
diff --git a/gdk/win32/gdkprivate-win32.h b/gdk/win32/gdkprivate-win32.h
index b40c5b4..25c44f0 100644
--- a/gdk/win32/gdkprivate-win32.h
+++ b/gdk/win32/gdkprivate-win32.h
@@ -475,7 +475,11 @@ void _gdk_win32_display_create_window_impl (GdkDisplay *display,
/* stray GdkWindowImplWin32 members */
void _gdk_win32_window_register_dnd (GdkWindow *window);
-GdkDragContext *_gdk_win32_window_drag_begin (GdkWindow *window, GdkDevice *device, GList *targets, gint
x_root, gint y_root);
+GdkDragContext *_gdk_win32_window_drag_begin (GdkWindow *window,
+ GdkDevice *device,
+ GdkContentFormats *formats,
+ gint x_root,
+ gint y_root);
gint _gdk_win32_window_get_property (GdkWindow *window,
GdkAtom property,
diff --git a/gdk/win32/gdkselection-win32.c b/gdk/win32/gdkselection-win32.c
index 9f70386..336a88f 100644
--- a/gdk/win32/gdkselection-win32.c
+++ b/gdk/win32/gdkselection-win32.c
@@ -1166,13 +1166,13 @@ gdk_win32_display_add_selection_targets (GdkDisplay *display,
sel_name);
g_free (sel_name);
- for (i = 0; i < n_targets; i++)
+ for (i = 0; i < ntargets; i++)
{
gchar *tgt_name = gdk_atom_name (targets[i]);
g_print ("%s", tgt_name);
g_free (tgt_name);
- if (i < n_targets - 1)
+ if (i < ntargets - 1)
g_print (", ");
}
g_print ("\n");
@@ -1199,7 +1199,7 @@ gdk_win32_display_add_selection_targets (GdkDisplay *display,
* support for it in Windows software, but note that alpha won't be
* handled.
*/
- for (i = 0; !has_image && i < n_targets; ++i)
+ for (i = 0; !has_image && i < ntargets; ++i)
{
UINT cf;
gchar *target_name;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]