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
This commit is contained in:
Chun-wei Fan 2017-11-17 15:27:10 +08:00
parent a687fd9aeb
commit e076cc7b1f
7 changed files with 50 additions and 32 deletions

View File

@ -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;
}

View File

@ -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)

View File

@ -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++)

View File

@ -18,7 +18,6 @@
*/
#include "gdkdisplayprivate.h"
#include "gdkscreen-win32.h"
#ifndef __GDK_DISPLAY__WIN32_H__
#define __GDK_DISPLAY__WIN32_H__

View File

@ -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 widgets declared selection types arent accessible in calls here
* that need to declare the corresponding OLE2 data types, and (b) there isnt 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;

View File

@ -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,

View File

@ -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;