Merge branch 'backport-4-12' into 'gtk-4-12'
[4.12] Backport a few Windows and macOS fixes See merge request GNOME/gtk!6679
This commit is contained in:
@@ -27,10 +27,6 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#ifndef AVAILABLE_MAC_OS_X_VERSION_10_13_AND_LATER
|
||||
typedef NSString *NSPasteboardType;
|
||||
#endif
|
||||
|
||||
#define GDK_TYPE_MACOS_CLIPBOARD (_gdk_macos_clipboard_get_type())
|
||||
|
||||
G_DECLARE_FINAL_TYPE (GdkMacosClipboard, _gdk_macos_clipboard, GDK, MACOS_CLIPBOARD, GdkClipboard)
|
||||
|
||||
@@ -1265,6 +1265,14 @@ _gdk_macos_display_translate (GdkMacosDisplay *self,
|
||||
_gdk_macos_display_clear_sorting (self);
|
||||
}
|
||||
}
|
||||
else if (is_motion_event(event_type))
|
||||
{
|
||||
NSWindow *orig_window = [nsevent window];
|
||||
|
||||
if (orig_window && GDK_IS_MACOS_WINDOW (orig_window))
|
||||
[NSApp sendEvent:nsevent];
|
||||
}
|
||||
|
||||
return fill_event (self, window, nsevent, x, y);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,10 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#ifndef AVAILABLE_MAC_OS_X_VERSION_10_13_AND_LATER
|
||||
typedef NSString *NSPasteboardType;
|
||||
#endif
|
||||
|
||||
@interface GdkMacosPasteboardItemDataProvider : NSObject <NSPasteboardItemDataProvider>
|
||||
{
|
||||
GdkContentProvider *_contentProvider;
|
||||
|
||||
@@ -400,7 +400,7 @@ _gdk_macos_pasteboard_register_drag_types (NSWindow *window)
|
||||
gdk_content_formats_get_gtypes (formats, &n_gtypes);
|
||||
|
||||
if (n_gtypes)
|
||||
[ret addObject:NSPasteboardTypeURL];
|
||||
[ret addObject:PTYPE(URL)];
|
||||
|
||||
gdk_content_formats_unref (formats);
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ GTK might also call gdk_clipboard_store_async(), which instructs
|
||||
the W32 backend to put the data into the OS clipboard manager by
|
||||
sending WM_RENDERALLFORMATS to itself and then handling it normally.
|
||||
|
||||
Every time W32 backend gets WM_DRAWCLIPBOARD or WM_CLIPBOARDUPDATE,
|
||||
Every time W32 backend gets WM_CLIPBOARDUPDATE,
|
||||
it calls GetUpdatedClipboardFormats() and GetClipboardSequenceNumber()
|
||||
and caches the results of both. These calls do not require the clipboard
|
||||
to be opened.
|
||||
@@ -245,7 +245,7 @@ When clipboard owner changes, the old owner receives WM_DESTROYCLIPBOARD message
|
||||
the clipboard thread schedules a call to gdk_clipboard_claim_remote()
|
||||
in the main thread, with an empty list of formats,
|
||||
to indicate that the clipboard is now owned by a remote process.
|
||||
Later the OS will send WM_DRAWCLIPBOARD or WM_CLIPBOARDUPDATE to indicate
|
||||
Later the OS will send WM_CLIPBOARDUPDATE to indicate
|
||||
the new clipboard contents (see above).
|
||||
|
||||
DND:
|
||||
@@ -416,8 +416,6 @@ struct _GdkWin32ClipboardThread
|
||||
*/
|
||||
HWND clipboard_opened_for;
|
||||
|
||||
HWND hwnd_next_viewer;
|
||||
|
||||
/* We can't peek the queue or "unpop" queue items,
|
||||
* so the items that we can't act upon (yet) got
|
||||
* to be stored *somewhere*.
|
||||
@@ -1171,7 +1169,7 @@ inner_clipboard_window_procedure (HWND hwnd,
|
||||
|
||||
switch (message)
|
||||
{
|
||||
case WM_DESTROY: /* remove us from chain */
|
||||
case WM_DESTROY: /* unregister the clipboard listener */
|
||||
{
|
||||
if (clipboard_thread_data == NULL)
|
||||
{
|
||||
@@ -1179,34 +1177,15 @@ inner_clipboard_window_procedure (HWND hwnd,
|
||||
return DefWindowProcW (hwnd, message, wparam, lparam);
|
||||
}
|
||||
|
||||
ChangeClipboardChain (hwnd, clipboard_thread_data->hwnd_next_viewer);
|
||||
RemoveClipboardFormatListener (hwnd);
|
||||
PostQuitMessage (0);
|
||||
return 0;
|
||||
}
|
||||
case WM_CHANGECBCHAIN:
|
||||
{
|
||||
HWND hwndRemove = (HWND) wparam; /* handle of window being removed */
|
||||
HWND hwndNext = (HWND) lparam; /* handle of next window in chain */
|
||||
|
||||
if (clipboard_thread_data == NULL)
|
||||
{
|
||||
g_warning ("Clipboard thread got an actionable message with no thread data");
|
||||
return DefWindowProcW (hwnd, message, wparam, lparam);
|
||||
}
|
||||
|
||||
if (hwndRemove == clipboard_thread_data->hwnd_next_viewer)
|
||||
clipboard_thread_data->hwnd_next_viewer = hwndNext == hwnd ? NULL : hwndNext;
|
||||
else if (clipboard_thread_data->hwnd_next_viewer != NULL)
|
||||
return SendMessage (clipboard_thread_data->hwnd_next_viewer, message, wparam, lparam);
|
||||
|
||||
return 0;
|
||||
}
|
||||
case WM_DESTROYCLIPBOARD:
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
case WM_CLIPBOARDUPDATE:
|
||||
case WM_DRAWCLIPBOARD:
|
||||
{
|
||||
HWND hwnd_owner;
|
||||
HWND hwnd_opener;
|
||||
@@ -1272,9 +1251,6 @@ inner_clipboard_window_procedure (HWND hwnd,
|
||||
g_idle_add_full (G_PRIORITY_DEFAULT, clipboard_owner_changed, NULL, NULL);
|
||||
}
|
||||
|
||||
if (clipboard_thread_data->hwnd_next_viewer != NULL)
|
||||
return SendMessage (clipboard_thread_data->hwnd_next_viewer, message, wparam, lparam);
|
||||
|
||||
/* clear error to avoid confusing SetClipboardViewer() return */
|
||||
SetLastError (0);
|
||||
|
||||
@@ -1386,7 +1362,7 @@ inner_clipboard_window_procedure (HWND hwnd,
|
||||
* OpenClipboard() is required/possible
|
||||
*/
|
||||
GDK_NOTE (DND,
|
||||
g_print (" SetClipboardData (%s, %p)",
|
||||
g_print (" SetClipboardData (%s, %p)\n",
|
||||
_gdk_win32_cf_to_string (wparam),
|
||||
returned_render->main_thread_data_handle));
|
||||
|
||||
@@ -1426,7 +1402,7 @@ _clipboard_window_procedure (HWND hwnd,
|
||||
}
|
||||
|
||||
/*
|
||||
* Creates a hidden window and adds it to the clipboard chain
|
||||
* Creates a hidden window and add a clipboard listener
|
||||
*/
|
||||
static gboolean
|
||||
register_clipboard_notification ()
|
||||
@@ -1452,9 +1428,8 @@ register_clipboard_notification ()
|
||||
goto failed;
|
||||
|
||||
SetLastError (0);
|
||||
clipboard_thread_data->hwnd_next_viewer = SetClipboardViewer (clipboard_thread_data->clipboard_window);
|
||||
|
||||
if (clipboard_thread_data->hwnd_next_viewer == NULL && GetLastError() != NO_ERROR)
|
||||
if (AddClipboardFormatListener (clipboard_thread_data->clipboard_window) == FALSE)
|
||||
{
|
||||
DestroyWindow (clipboard_thread_data->clipboard_window);
|
||||
goto failed;
|
||||
@@ -1462,11 +1437,6 @@ register_clipboard_notification ()
|
||||
|
||||
g_idle_add_full (G_PRIORITY_DEFAULT, clipboard_window_created, (gpointer) clipboard_thread_data->clipboard_window, NULL);
|
||||
|
||||
/* 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:
|
||||
|
||||
@@ -548,6 +548,9 @@ _gdk_win32_display_open (const char *display_name)
|
||||
|
||||
g_signal_emit_by_name (_gdk_display, "opened");
|
||||
|
||||
/* Precalculate keymap, see #6203 */
|
||||
(void) _gdk_win32_display_get_keymap (_gdk_display);
|
||||
|
||||
GDK_NOTE (MISC, g_print ("... _gdk_display now set up\n"));
|
||||
|
||||
return _gdk_display;
|
||||
@@ -1170,6 +1173,9 @@ gdk_win32_display_get_setting (GdkDisplay *display,
|
||||
const char *name,
|
||||
GValue *value)
|
||||
{
|
||||
if (gdk_display_get_debug_flags (display) & GDK_DEBUG_DEFAULT_SETTINGS)
|
||||
return FALSE;
|
||||
|
||||
return _gdk_win32_get_setting (name, value);
|
||||
}
|
||||
|
||||
|
||||
@@ -57,14 +57,12 @@ typedef struct
|
||||
|
||||
G_DEFINE_TYPE (GtkApplicationImplQuartz, gtk_application_impl_quartz, GTK_TYPE_APPLICATION_IMPL)
|
||||
|
||||
@interface GtkApplicationQuartzDelegate : NSObject
|
||||
@interface GtkApplicationQuartzDelegate : NSObject<NSApplicationDelegate>
|
||||
{
|
||||
GtkApplicationImplQuartz *quartz;
|
||||
}
|
||||
|
||||
- (id)initWithImpl:(GtkApplicationImplQuartz*)impl;
|
||||
- (NSApplicationTerminateReply) applicationShouldTerminate:(NSApplication *)sender;
|
||||
- (void)application:(NSApplication *)theApplication openFiles:(NSArray *)filenames;
|
||||
@end
|
||||
|
||||
@implementation GtkApplicationQuartzDelegate
|
||||
@@ -114,6 +112,11 @@ G_DEFINE_TYPE (GtkApplicationImplQuartz, gtk_application_impl_quartz, GTK_TYPE_A
|
||||
|
||||
[theApplication replyToOpenOrPrint:NSApplicationDelegateReplySuccess];
|
||||
}
|
||||
|
||||
- (BOOL)applicationSupportsSecureRestorableState:(NSApplication *)app
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
@end
|
||||
|
||||
/* these exist only for accel handling */
|
||||
|
||||
@@ -13,9 +13,7 @@ tests = [
|
||||
{ 'name': 'contentformats' },
|
||||
{ 'name': 'contentserializer' },
|
||||
{ 'name': 'cursor' },
|
||||
{ 'name': 'display' },
|
||||
{ 'name': 'displaymanager' },
|
||||
{ 'name': 'encoding' },
|
||||
{ 'name': 'glcontext' },
|
||||
{ 'name': 'keysyms' },
|
||||
{ 'name': 'memorytexture' },
|
||||
@@ -27,6 +25,13 @@ tests = [
|
||||
{ 'name': 'popuplayout' },
|
||||
]
|
||||
|
||||
if x11_enabled
|
||||
tests += [
|
||||
{ 'name': 'display' },
|
||||
{ 'name': 'encoding' },
|
||||
]
|
||||
endif
|
||||
|
||||
foreach t : tests
|
||||
test_name = t.get('name')
|
||||
test_exe = executable(test_name,
|
||||
|
||||
@@ -59,7 +59,7 @@ assert_icon_lookup_size (const char *icon_name,
|
||||
{
|
||||
GtkIconPaintable *info;
|
||||
GFile *file;
|
||||
char *path = NULL;
|
||||
char *uri = NULL;
|
||||
|
||||
if (fallbacks)
|
||||
{
|
||||
@@ -83,26 +83,26 @@ assert_icon_lookup_size (const char *icon_name,
|
||||
file = gtk_icon_paintable_get_file (info);
|
||||
if (file)
|
||||
{
|
||||
path = g_file_get_path (file);
|
||||
uri = g_file_get_uri (file);
|
||||
g_object_unref (file);
|
||||
}
|
||||
|
||||
if (filename)
|
||||
{
|
||||
if (path == NULL || !g_str_has_suffix (path, filename))
|
||||
if (uri == NULL || !g_str_has_suffix (uri, filename))
|
||||
{
|
||||
g_error ("Icon for \"%s\" with flags %s at size %d should be \"...%s\" but is \"...%s\"",
|
||||
icon_name, lookup_flags_to_string (flags), size,
|
||||
filename, path);
|
||||
filename, uri);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
g_assert_null (path);
|
||||
g_assert_null (uri);
|
||||
}
|
||||
|
||||
g_free (path);
|
||||
g_free (uri);
|
||||
|
||||
g_assert_cmpint (gdk_paintable_get_intrinsic_width (GDK_PAINTABLE (info)), ==, size);
|
||||
|
||||
|
||||
@@ -100,12 +100,17 @@ tests = [
|
||||
{ 'name': 'treesorter' },
|
||||
{ 'name': 'treeview' },
|
||||
{ 'name': 'typename' },
|
||||
{ 'name': 'displayclose' },
|
||||
{ 'name': 'revealer-size' },
|
||||
{ 'name': 'widgetorder' },
|
||||
{ 'name': 'widget-refcount' },
|
||||
]
|
||||
|
||||
if x11_enabled
|
||||
tests += [
|
||||
{ 'name': 'displayclose' },
|
||||
]
|
||||
endif
|
||||
|
||||
# Tests that test private apis and therefore are linked against libgtk-4.a
|
||||
internal_tests = [
|
||||
{ 'name': 'bitmask' },
|
||||
|
||||
Reference in New Issue
Block a user