2005-11-22 10:03:32 +00:00
|
|
|
/* gdkevents-quartz.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
|
|
|
* Copyright (C) 1998-2002 Tor Lillqvist
|
2008-05-12 11:23:28 +00:00
|
|
|
* Copyright (C) 2005-2008 Imendio AB
|
2005-11-22 10:03:32 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2012-02-27 13:01:10 +00:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2005-11-22 10:03:32 +00:00
|
|
|
*/
|
|
|
|
|
2008-06-22 14:28:52 +00:00
|
|
|
#include "config.h"
|
2005-11-22 10:03:32 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/sysctl.h>
|
2006-03-27 18:46:38 +00:00
|
|
|
#include <pthread.h>
|
|
|
|
#include <unistd.h>
|
2005-11-22 10:03:32 +00:00
|
|
|
|
2007-06-17 20:36:26 +00:00
|
|
|
#import <Cocoa/Cocoa.h>
|
2006-07-17 18:39:43 +00:00
|
|
|
#include <Carbon/Carbon.h>
|
|
|
|
|
2010-12-23 11:59:26 +00:00
|
|
|
#include <gdk/gdkdisplayprivate.h>
|
|
|
|
|
2005-11-22 10:03:32 +00:00
|
|
|
#include "gdkscreen.h"
|
2006-07-17 18:39:43 +00:00
|
|
|
#include "gdkkeysyms.h"
|
2011-08-13 22:30:59 +00:00
|
|
|
#include "gdkquartz.h"
|
2010-12-23 11:59:26 +00:00
|
|
|
#include "gdkquartzdisplay.h"
|
2005-11-22 10:03:32 +00:00
|
|
|
#include "gdkprivate-quartz.h"
|
2019-03-16 23:45:44 +00:00
|
|
|
#include "gdkinternal-quartz.h"
|
2010-12-23 11:59:26 +00:00
|
|
|
#include "gdkquartzdevicemanager-core.h"
|
2018-12-03 12:06:41 +00:00
|
|
|
#include "gdkquartzkeys.h"
|
2019-03-16 23:45:44 +00:00
|
|
|
#include "gdkkeys-quartz.h"
|
2005-11-22 10:03:32 +00:00
|
|
|
|
2009-09-25 19:52:13 +00:00
|
|
|
#define GRIP_WIDTH 15
|
|
|
|
#define GRIP_HEIGHT 15
|
2011-08-13 22:30:59 +00:00
|
|
|
#define GDK_LION_RESIZE 5
|
2019-01-27 19:16:33 +00:00
|
|
|
#define TABLET_AXES 5
|
2009-09-25 19:52:13 +00:00
|
|
|
|
2019-03-15 19:35:57 +00:00
|
|
|
#if MAC_OS_X_VERSION_MAX_ALLOWED < 1060
|
|
|
|
#define NSEventTypeRotate 13
|
|
|
|
#define NSEventTypeMagnify 30
|
|
|
|
#endif
|
|
|
|
|
2010-08-08 16:22:51 +00:00
|
|
|
#define WINDOW_IS_TOPLEVEL(window) \
|
|
|
|
(GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD && \
|
|
|
|
GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN && \
|
|
|
|
GDK_WINDOW_TYPE (window) != GDK_WINDOW_OFFSCREEN)
|
|
|
|
|
2019-03-16 23:45:44 +00:00
|
|
|
|
2005-11-22 10:03:32 +00:00
|
|
|
/* This is the window corresponding to the key window */
|
2007-06-01 21:46:45 +00:00
|
|
|
static GdkWindow *current_keyboard_window;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
2007-07-03 20:31:59 +00:00
|
|
|
|
2010-01-03 14:27:53 +00:00
|
|
|
static void append_event (GdkEvent *event,
|
|
|
|
gboolean windowing);
|
2006-07-20 08:06:54 +00:00
|
|
|
|
2011-11-06 08:25:16 +00:00
|
|
|
static GdkWindow *find_toplevel_under_pointer (GdkDisplay *display,
|
|
|
|
NSPoint screen_point,
|
|
|
|
gint *x,
|
|
|
|
gint *y);
|
|
|
|
|
|
|
|
|
2012-08-24 09:49:43 +00:00
|
|
|
static void
|
|
|
|
gdk_quartz_ns_notification_callback (CFNotificationCenterRef center,
|
|
|
|
void *observer,
|
|
|
|
CFStringRef name,
|
|
|
|
const void *object,
|
|
|
|
CFDictionaryRef userInfo)
|
|
|
|
{
|
|
|
|
GdkEvent new_event;
|
|
|
|
|
|
|
|
new_event.type = GDK_SETTING;
|
|
|
|
new_event.setting.window = gdk_screen_get_root_window (_gdk_screen);
|
|
|
|
new_event.setting.send_event = FALSE;
|
|
|
|
new_event.setting.action = GDK_SETTING_ACTION_CHANGED;
|
|
|
|
new_event.setting.name = NULL;
|
|
|
|
|
|
|
|
/* Translate name */
|
|
|
|
if (CFStringCompare (name,
|
|
|
|
CFSTR("AppleNoRedisplayAppearancePreferenceChanged"),
|
|
|
|
0) == kCFCompareEqualTo)
|
|
|
|
new_event.setting.name = "gtk-primary-button-warps-slider";
|
|
|
|
|
|
|
|
if (!new_event.setting.name)
|
|
|
|
return;
|
|
|
|
|
|
|
|
gdk_event_put (&new_event);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_quartz_events_init_notifications (void)
|
|
|
|
{
|
|
|
|
static gboolean notifications_initialized = FALSE;
|
|
|
|
|
|
|
|
if (notifications_initialized)
|
|
|
|
return;
|
|
|
|
notifications_initialized = TRUE;
|
|
|
|
|
|
|
|
/* Initialize any handlers for notifications we want to push to GTK
|
|
|
|
* through GdkEventSettings.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* This is an undocumented *distributed* notification to listen for changes
|
|
|
|
* in scrollbar jump behavior. It is used by LibreOffice and WebKit as well.
|
|
|
|
*/
|
|
|
|
CFNotificationCenterAddObserver (CFNotificationCenterGetDistributedCenter (),
|
|
|
|
NULL,
|
|
|
|
&gdk_quartz_ns_notification_callback,
|
|
|
|
CFSTR ("AppleNoRedisplayAppearancePreferenceChanged"),
|
|
|
|
NULL,
|
|
|
|
CFNotificationSuspensionBehaviorDeliverImmediately);
|
|
|
|
}
|
|
|
|
|
2009-01-16 19:22:51 +00:00
|
|
|
void
|
2010-12-17 16:38:02 +00:00
|
|
|
_gdk_quartz_events_init (void)
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
2006-12-28 09:04:48 +00:00
|
|
|
_gdk_quartz_event_loop_init ();
|
2012-08-24 09:49:43 +00:00
|
|
|
gdk_quartz_events_init_notifications ();
|
2005-11-22 10:03:32 +00:00
|
|
|
|
|
|
|
current_keyboard_window = g_object_ref (_gdk_root);
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2010-12-17 16:46:22 +00:00
|
|
|
_gdk_quartz_display_has_pending (GdkDisplay *display)
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
2010-12-17 16:46:22 +00:00
|
|
|
return (_gdk_event_queue_find_first (display) ||
|
|
|
|
(_gdk_quartz_event_loop_check_pending ()));
|
2005-11-22 10:03:32 +00:00
|
|
|
}
|
|
|
|
|
2012-02-19 15:02:09 +00:00
|
|
|
void
|
|
|
|
_gdk_quartz_events_break_all_grabs (guint32 time)
|
2007-06-16 15:43:23 +00:00
|
|
|
{
|
2018-12-03 12:24:03 +00:00
|
|
|
GdkSeat *seat = gdk_display_get_default_seat (_gdk_display);
|
|
|
|
gdk_seat_ungrab (seat);
|
2007-06-16 15:43:23 +00:00
|
|
|
}
|
|
|
|
|
2005-11-22 10:03:32 +00:00
|
|
|
static void
|
|
|
|
fixup_event (GdkEvent *event)
|
|
|
|
{
|
|
|
|
if (event->any.window)
|
|
|
|
g_object_ref (event->any.window);
|
|
|
|
if (((event->any.type == GDK_ENTER_NOTIFY) ||
|
|
|
|
(event->any.type == GDK_LEAVE_NOTIFY)) &&
|
|
|
|
(event->crossing.subwindow != NULL))
|
|
|
|
g_object_ref (event->crossing.subwindow);
|
|
|
|
event->any.send_event = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-01-03 14:27:53 +00:00
|
|
|
append_event (GdkEvent *event,
|
|
|
|
gboolean windowing)
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
2010-01-03 14:27:53 +00:00
|
|
|
GList *node;
|
|
|
|
|
2005-11-22 10:03:32 +00:00
|
|
|
fixup_event (event);
|
2010-01-03 14:27:53 +00:00
|
|
|
node = _gdk_event_queue_append (_gdk_display, event);
|
|
|
|
|
|
|
|
if (windowing)
|
|
|
|
_gdk_windowing_got_event (_gdk_display, node, event, 0);
|
2005-11-22 10:03:32 +00:00
|
|
|
}
|
|
|
|
|
2009-01-16 11:21:46 +00:00
|
|
|
static gint
|
|
|
|
gdk_event_apply_filters (NSEvent *nsevent,
|
|
|
|
GdkEvent *event,
|
2010-11-20 22:58:50 +00:00
|
|
|
GList **filters)
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
|
|
|
GList *tmp_list;
|
2009-01-16 11:21:46 +00:00
|
|
|
GdkFilterReturn result;
|
2019-01-27 19:16:33 +00:00
|
|
|
|
2010-11-20 22:58:50 +00:00
|
|
|
tmp_list = *filters;
|
2009-01-16 11:21:46 +00:00
|
|
|
|
2005-11-22 10:03:32 +00:00
|
|
|
while (tmp_list)
|
|
|
|
{
|
2009-01-16 11:21:46 +00:00
|
|
|
GdkEventFilter *filter = (GdkEventFilter*) tmp_list->data;
|
2010-11-20 22:58:50 +00:00
|
|
|
GList *node;
|
|
|
|
|
|
|
|
if ((filter->flags & GDK_EVENT_FILTER_REMOVED) != 0)
|
|
|
|
{
|
|
|
|
tmp_list = tmp_list->next;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
filter->ref_count++;
|
2005-11-22 10:03:32 +00:00
|
|
|
result = filter->function (nsevent, event, filter->data);
|
2010-11-20 22:58:50 +00:00
|
|
|
|
|
|
|
/* get the next node after running the function since the
|
|
|
|
function may add or remove a next node */
|
|
|
|
node = tmp_list;
|
|
|
|
tmp_list = tmp_list->next;
|
|
|
|
|
|
|
|
filter->ref_count--;
|
|
|
|
if (filter->ref_count == 0)
|
|
|
|
{
|
|
|
|
*filters = g_list_remove_link (*filters, node);
|
|
|
|
g_list_free_1 (node);
|
|
|
|
g_free (filter);
|
|
|
|
}
|
|
|
|
|
2009-01-16 11:21:46 +00:00
|
|
|
if (result != GDK_FILTER_CONTINUE)
|
|
|
|
return result;
|
2005-11-22 10:03:32 +00:00
|
|
|
}
|
|
|
|
|
2009-01-16 11:21:46 +00:00
|
|
|
return GDK_FILTER_CONTINUE;
|
2005-11-22 10:03:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static guint32
|
2007-06-01 21:03:34 +00:00
|
|
|
get_time_from_ns_event (NSEvent *event)
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
|
|
|
double time = [event timestamp];
|
2012-08-23 07:28:13 +00:00
|
|
|
|
|
|
|
/* cast via double->uint64 conversion to make sure that it is
|
|
|
|
* wrapped on 32-bit machines when it overflows
|
|
|
|
*/
|
|
|
|
return (guint32) (guint64) (time * 1000.0);
|
2005-11-22 10:03:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-06-01 21:03:34 +00:00
|
|
|
get_mouse_button_from_ns_event (NSEvent *event)
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
2009-12-27 16:01:25 +00:00
|
|
|
NSInteger button;
|
2007-06-01 21:03:34 +00:00
|
|
|
|
|
|
|
button = [event buttonNumber];
|
|
|
|
|
2005-11-22 10:03:32 +00:00
|
|
|
switch (button)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
return 1;
|
|
|
|
case 1:
|
|
|
|
return 3;
|
|
|
|
case 2:
|
|
|
|
return 2;
|
|
|
|
default:
|
|
|
|
return button + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-08 20:41:19 +00:00
|
|
|
static GdkModifierType
|
|
|
|
get_mouse_button_modifiers_from_ns_buttons (NSUInteger nsbuttons)
|
|
|
|
{
|
|
|
|
GdkModifierType modifiers = 0;
|
|
|
|
|
|
|
|
if (nsbuttons & (1 << 0))
|
|
|
|
modifiers |= GDK_BUTTON1_MASK;
|
|
|
|
if (nsbuttons & (1 << 1))
|
|
|
|
modifiers |= GDK_BUTTON3_MASK;
|
|
|
|
if (nsbuttons & (1 << 2))
|
|
|
|
modifiers |= GDK_BUTTON2_MASK;
|
|
|
|
if (nsbuttons & (1 << 3))
|
|
|
|
modifiers |= GDK_BUTTON4_MASK;
|
|
|
|
if (nsbuttons & (1 << 4))
|
|
|
|
modifiers |= GDK_BUTTON5_MASK;
|
|
|
|
|
|
|
|
return modifiers;
|
|
|
|
}
|
|
|
|
|
2007-07-03 20:31:59 +00:00
|
|
|
static GdkModifierType
|
|
|
|
get_mouse_button_modifiers_from_ns_event (NSEvent *event)
|
|
|
|
{
|
|
|
|
int button;
|
|
|
|
GdkModifierType state = 0;
|
|
|
|
|
|
|
|
/* This maps buttons 1 to 5 to GDK_BUTTON[1-5]_MASK */
|
|
|
|
button = get_mouse_button_from_ns_event (event);
|
|
|
|
if (button >= 1 && button <= 5)
|
|
|
|
state = (1 << (button + 7));
|
|
|
|
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
2007-06-01 21:03:34 +00:00
|
|
|
static GdkModifierType
|
2011-11-08 20:41:19 +00:00
|
|
|
get_keyboard_modifiers_from_ns_flags (NSUInteger nsflags)
|
2007-06-01 21:03:34 +00:00
|
|
|
{
|
|
|
|
GdkModifierType modifiers = 0;
|
|
|
|
|
2018-12-03 12:06:41 +00:00
|
|
|
if (nsflags & GDK_QUARTZ_ALPHA_SHIFT_KEY_MASK)
|
2007-06-01 21:03:34 +00:00
|
|
|
modifiers |= GDK_LOCK_MASK;
|
2018-12-03 12:06:41 +00:00
|
|
|
if (nsflags & GDK_QUARTZ_SHIFT_KEY_MASK)
|
2007-06-01 21:03:34 +00:00
|
|
|
modifiers |= GDK_SHIFT_MASK;
|
2018-12-03 12:06:41 +00:00
|
|
|
if (nsflags & GDK_QUARTZ_CONTROL_KEY_MASK)
|
2007-06-01 21:03:34 +00:00
|
|
|
modifiers |= GDK_CONTROL_MASK;
|
2018-12-03 12:06:41 +00:00
|
|
|
if (nsflags & GDK_QUARTZ_ALTERNATE_KEY_MASK)
|
2007-06-01 21:03:34 +00:00
|
|
|
modifiers |= GDK_MOD1_MASK;
|
2018-12-03 12:06:41 +00:00
|
|
|
if (nsflags & GDK_QUARTZ_COMMAND_KEY_MASK)
|
2011-09-16 13:54:03 +00:00
|
|
|
modifiers |= GDK_MOD2_MASK;
|
2007-06-01 21:03:34 +00:00
|
|
|
|
|
|
|
return modifiers;
|
|
|
|
}
|
|
|
|
|
2011-11-08 20:41:19 +00:00
|
|
|
static GdkModifierType
|
|
|
|
get_keyboard_modifiers_from_ns_event (NSEvent *nsevent)
|
|
|
|
{
|
|
|
|
return get_keyboard_modifiers_from_ns_flags ([nsevent modifierFlags]);
|
|
|
|
}
|
|
|
|
|
2005-11-22 10:03:32 +00:00
|
|
|
/* Return an event mask from an NSEvent */
|
|
|
|
static GdkEventMask
|
|
|
|
get_event_mask_from_ns_event (NSEvent *nsevent)
|
|
|
|
{
|
2006-07-20 08:06:54 +00:00
|
|
|
switch ([nsevent type])
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
2018-12-03 12:06:41 +00:00
|
|
|
case GDK_QUARTZ_LEFT_MOUSE_DOWN:
|
|
|
|
case GDK_QUARTZ_RIGHT_MOUSE_DOWN:
|
|
|
|
case GDK_QUARTZ_OTHER_MOUSE_DOWN:
|
2005-11-22 10:03:32 +00:00
|
|
|
return GDK_BUTTON_PRESS_MASK;
|
2018-12-03 12:06:41 +00:00
|
|
|
case GDK_QUARTZ_LEFT_MOUSE_UP:
|
|
|
|
case GDK_QUARTZ_RIGHT_MOUSE_UP:
|
|
|
|
case GDK_QUARTZ_OTHER_MOUSE_UP:
|
2005-11-22 10:03:32 +00:00
|
|
|
return GDK_BUTTON_RELEASE_MASK;
|
2018-12-03 12:06:41 +00:00
|
|
|
case GDK_QUARTZ_MOUSE_MOVED:
|
2006-07-20 08:06:54 +00:00
|
|
|
return GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK;
|
2018-12-03 12:06:41 +00:00
|
|
|
case GDK_QUARTZ_SCROLL_WHEEL:
|
2005-11-22 10:03:32 +00:00
|
|
|
/* Since applications that want button press events can get
|
|
|
|
* scroll events on X11 (since scroll wheel events are really
|
|
|
|
* button press events there), we need to use GDK_BUTTON_PRESS_MASK too.
|
|
|
|
*/
|
2006-07-20 08:06:54 +00:00
|
|
|
return GDK_SCROLL_MASK | GDK_BUTTON_PRESS_MASK;
|
2018-12-03 12:06:41 +00:00
|
|
|
case GDK_QUARTZ_LEFT_MOUSE_DRAGGED:
|
2006-08-15 20:13:13 +00:00
|
|
|
return (GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
|
|
|
|
GDK_BUTTON_MOTION_MASK | GDK_BUTTON1_MOTION_MASK |
|
|
|
|
GDK_BUTTON1_MASK);
|
2018-12-03 12:06:41 +00:00
|
|
|
case GDK_QUARTZ_RIGHT_MOUSE_DRAGGED:
|
2006-08-15 20:13:13 +00:00
|
|
|
return (GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
|
|
|
|
GDK_BUTTON_MOTION_MASK | GDK_BUTTON3_MOTION_MASK |
|
|
|
|
GDK_BUTTON3_MASK);
|
2018-12-03 12:06:41 +00:00
|
|
|
case GDK_QUARTZ_OTHER_MOUSE_DRAGGED:
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
2006-07-20 08:06:54 +00:00
|
|
|
GdkEventMask mask;
|
|
|
|
|
|
|
|
mask = (GDK_POINTER_MOTION_MASK |
|
|
|
|
GDK_POINTER_MOTION_HINT_MASK |
|
|
|
|
GDK_BUTTON_MOTION_MASK);
|
|
|
|
|
2007-06-01 21:03:34 +00:00
|
|
|
if (get_mouse_button_from_ns_event (nsevent) == 2)
|
2006-08-15 20:13:13 +00:00
|
|
|
mask |= (GDK_BUTTON2_MOTION_MASK | GDK_BUTTON2_MOTION_MASK |
|
|
|
|
GDK_BUTTON2_MASK);
|
2005-11-22 10:03:32 +00:00
|
|
|
|
|
|
|
return mask;
|
|
|
|
}
|
2016-01-07 14:51:31 +00:00
|
|
|
case NSEventTypeMagnify:
|
|
|
|
case NSEventTypeRotate:
|
|
|
|
return GDK_TOUCHPAD_GESTURE_MASK;
|
2018-12-03 12:06:41 +00:00
|
|
|
case GDK_QUARTZ_KEY_DOWN:
|
|
|
|
case GDK_QUARTZ_KEY_UP:
|
|
|
|
case GDK_QUARTZ_FLAGS_CHANGED:
|
2006-07-07 20:19:22 +00:00
|
|
|
{
|
2007-04-06 21:12:48 +00:00
|
|
|
switch (_gdk_quartz_keys_event_type (nsevent))
|
2006-07-20 08:06:54 +00:00
|
|
|
{
|
|
|
|
case GDK_KEY_PRESS:
|
|
|
|
return GDK_KEY_PRESS_MASK;
|
|
|
|
case GDK_KEY_RELEASE:
|
|
|
|
return GDK_KEY_RELEASE_MASK;
|
|
|
|
case GDK_NOTHING:
|
|
|
|
return 0;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
2006-07-07 20:19:22 +00:00
|
|
|
}
|
2009-01-16 18:51:15 +00:00
|
|
|
break;
|
|
|
|
|
2018-12-03 12:06:41 +00:00
|
|
|
case GDK_QUARTZ_MOUSE_ENTERED:
|
2009-01-16 18:51:15 +00:00
|
|
|
return GDK_ENTER_NOTIFY_MASK;
|
|
|
|
|
2018-12-03 12:06:41 +00:00
|
|
|
case GDK_QUARTZ_MOUSE_EXITED:
|
2009-01-16 18:51:15 +00:00
|
|
|
return GDK_LEAVE_NOTIFY_MASK;
|
|
|
|
|
2005-11-22 10:03:32 +00:00
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-11-05 21:43:17 +00:00
|
|
|
static void
|
|
|
|
get_window_point_from_screen_point (GdkWindow *window,
|
|
|
|
NSPoint screen_point,
|
|
|
|
gint *x,
|
|
|
|
gint *y)
|
|
|
|
{
|
|
|
|
NSPoint point;
|
2018-12-03 12:03:34 +00:00
|
|
|
GdkQuartzNSWindow *nswindow;
|
2011-11-05 21:43:17 +00:00
|
|
|
|
2018-12-03 12:03:34 +00:00
|
|
|
nswindow = (GdkQuartzNSWindow*)(((GdkWindowImplQuartz *)window->impl)->toplevel);
|
|
|
|
point = [nswindow convertPointFromScreen:screen_point];
|
2011-11-05 21:43:17 +00:00
|
|
|
*x = point.x;
|
|
|
|
*y = window->height - point.y;
|
|
|
|
}
|
|
|
|
|
2012-11-15 10:34:15 +00:00
|
|
|
static gboolean
|
|
|
|
is_mouse_button_press_event (NSEventType type)
|
|
|
|
{
|
|
|
|
switch (type)
|
|
|
|
{
|
2018-12-03 12:06:41 +00:00
|
|
|
case GDK_QUARTZ_LEFT_MOUSE_DOWN:
|
|
|
|
case GDK_QUARTZ_RIGHT_MOUSE_DOWN:
|
|
|
|
case GDK_QUARTZ_OTHER_MOUSE_DOWN:
|
2012-11-15 10:34:15 +00:00
|
|
|
return TRUE;
|
2018-12-03 12:03:34 +00:00
|
|
|
default:
|
|
|
|
return FALSE;
|
2012-11-15 10:34:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-11-05 21:53:22 +00:00
|
|
|
static GdkWindow *
|
|
|
|
get_toplevel_from_ns_event (NSEvent *nsevent,
|
|
|
|
NSPoint *screen_point,
|
|
|
|
gint *x,
|
|
|
|
gint *y)
|
|
|
|
{
|
2012-11-15 10:34:15 +00:00
|
|
|
GdkWindow *toplevel = NULL;
|
2011-11-05 21:53:22 +00:00
|
|
|
|
2011-11-06 08:25:16 +00:00
|
|
|
if ([nsevent window])
|
|
|
|
{
|
|
|
|
GdkQuartzView *view;
|
2012-11-15 10:34:15 +00:00
|
|
|
NSPoint point, view_point;
|
|
|
|
NSRect view_frame;
|
2011-11-05 21:53:22 +00:00
|
|
|
|
2011-11-06 08:25:16 +00:00
|
|
|
view = (GdkQuartzView *)[[nsevent window] contentView];
|
2011-11-05 21:53:22 +00:00
|
|
|
|
2011-11-06 08:25:16 +00:00
|
|
|
toplevel = [view gdkWindow];
|
2011-11-05 21:53:22 +00:00
|
|
|
|
2011-11-06 08:25:16 +00:00
|
|
|
point = [nsevent locationInWindow];
|
2012-11-15 10:34:15 +00:00
|
|
|
view_point = [view convertPoint:point fromView:nil];
|
|
|
|
view_frame = [view frame];
|
|
|
|
|
|
|
|
/* NSEvents come in with a window set, but with window coordinates
|
|
|
|
* out of window bounds. For e.g. moved events this is fine, we use
|
|
|
|
* this information to properly handle enter/leave notify and motion
|
|
|
|
* events. For mouse button press/release, we want to avoid forwarding
|
|
|
|
* these events however, because the window they relate to is not the
|
|
|
|
* window set in the event. This situation appears to occur when button
|
|
|
|
* presses come in just before (or just after?) a window is resized and
|
|
|
|
* also when a button press occurs on the OS X window titlebar.
|
|
|
|
*
|
|
|
|
* By setting toplevel to NULL, we do another attempt to get the right
|
|
|
|
* toplevel window below.
|
|
|
|
*/
|
|
|
|
if (is_mouse_button_press_event ([nsevent type]) &&
|
|
|
|
(view_point.x < view_frame.origin.x ||
|
|
|
|
view_point.x >= view_frame.origin.x + view_frame.size.width ||
|
|
|
|
view_point.y < view_frame.origin.y ||
|
|
|
|
view_point.y >= view_frame.origin.y + view_frame.size.height))
|
|
|
|
{
|
|
|
|
toplevel = NULL;
|
|
|
|
|
|
|
|
/* This is a hack for button presses to break all grabs. E.g. if
|
|
|
|
* a menu is open and one clicks on the title bar (or anywhere
|
|
|
|
* out of window bounds), we really want to pop down the menu (by
|
|
|
|
* breaking the grabs) before OS X handles the action of the title
|
|
|
|
* bar button.
|
|
|
|
*
|
|
|
|
* Because we cannot ingest this event into GDK, we have to do it
|
|
|
|
* here, not very nice.
|
|
|
|
*/
|
|
|
|
_gdk_quartz_events_break_all_grabs (get_time_from_ns_event (nsevent));
|
2019-10-19 10:15:35 +00:00
|
|
|
|
|
|
|
/* Check if the event occurred on the titlebar. If it did,
|
|
|
|
* explicitly return NULL to prevent going through the
|
|
|
|
* fallback path, which could match the window that is
|
|
|
|
* directly under the titlebar.
|
|
|
|
*/
|
|
|
|
if (view_point.y < 0 &&
|
|
|
|
view_point.x >= view_frame.origin.x &&
|
|
|
|
view_point.x < view_frame.origin.x + view_frame.size.width)
|
|
|
|
{
|
|
|
|
NSView *superview = [view superview];
|
|
|
|
if (superview)
|
|
|
|
{
|
|
|
|
NSRect superview_frame = [superview frame];
|
|
|
|
int titlebar_height = superview_frame.size.height -
|
|
|
|
view_frame.size.height;
|
|
|
|
|
|
|
|
if (titlebar_height > 0 && view_point.y >= -titlebar_height)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-11-15 10:34:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-12-15 00:10:35 +00:00
|
|
|
*screen_point = [(GdkQuartzNSWindow*)[nsevent window] convertPointToScreen:point];
|
2012-11-15 10:34:15 +00:00
|
|
|
*x = point.x;
|
|
|
|
*y = toplevel->height - point.y;
|
|
|
|
}
|
2011-11-06 08:25:16 +00:00
|
|
|
}
|
2012-11-15 10:34:15 +00:00
|
|
|
|
|
|
|
if (!toplevel)
|
2011-11-06 08:25:16 +00:00
|
|
|
{
|
|
|
|
/* Fallback used when no NSWindow set. This happens e.g. when
|
|
|
|
* we allow motion events without a window set in gdk_event_translate()
|
|
|
|
* that occur immediately after the main menu bar was clicked/used.
|
2012-11-15 10:34:15 +00:00
|
|
|
* This fallback will not return coordinates contained in a window's
|
|
|
|
* titlebar.
|
2011-11-06 08:25:16 +00:00
|
|
|
*/
|
|
|
|
*screen_point = [NSEvent mouseLocation];
|
|
|
|
toplevel = find_toplevel_under_pointer (_gdk_display,
|
|
|
|
*screen_point,
|
|
|
|
x, y);
|
|
|
|
}
|
2011-11-05 21:53:22 +00:00
|
|
|
|
|
|
|
return toplevel;
|
|
|
|
}
|
|
|
|
|
2005-11-22 10:03:32 +00:00
|
|
|
static GdkEvent *
|
|
|
|
create_focus_event (GdkWindow *window,
|
|
|
|
gboolean in)
|
|
|
|
{
|
|
|
|
GdkEvent *event;
|
2018-12-03 12:24:03 +00:00
|
|
|
GdkDisplay *display = gdk_window_get_display (window);
|
|
|
|
GdkSeat *seat = gdk_display_get_default_seat (display);
|
2005-11-22 10:03:32 +00:00
|
|
|
|
|
|
|
event = gdk_event_new (GDK_FOCUS_CHANGE);
|
|
|
|
event->focus_change.window = window;
|
|
|
|
event->focus_change.in = in;
|
|
|
|
|
2018-12-03 12:24:03 +00:00
|
|
|
gdk_event_set_device (event, gdk_seat_get_keyboard (seat));
|
|
|
|
gdk_event_set_seat (event, seat);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
2005-11-22 10:03:32 +00:00
|
|
|
return event;
|
|
|
|
}
|
|
|
|
|
2010-01-03 14:27:53 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
generate_motion_event (GdkWindow *window)
|
|
|
|
{
|
|
|
|
NSPoint screen_point;
|
|
|
|
GdkEvent *event;
|
|
|
|
gint x, y, x_root, y_root;
|
2018-12-03 12:24:03 +00:00
|
|
|
GdkDisplay *display = gdk_window_get_display (window);
|
|
|
|
GdkSeat *seat = gdk_display_get_default_seat (display);
|
2010-01-03 14:27:53 +00:00
|
|
|
|
|
|
|
event = gdk_event_new (GDK_MOTION_NOTIFY);
|
|
|
|
event->any.window = NULL;
|
|
|
|
event->any.send_event = TRUE;
|
|
|
|
|
|
|
|
screen_point = [NSEvent mouseLocation];
|
|
|
|
|
|
|
|
_gdk_quartz_window_nspoint_to_gdk_xy (screen_point, &x_root, &y_root);
|
2011-11-05 21:43:17 +00:00
|
|
|
get_window_point_from_screen_point (window, screen_point, &x, &y);
|
2010-01-03 14:27:53 +00:00
|
|
|
|
|
|
|
event->any.type = GDK_MOTION_NOTIFY;
|
|
|
|
event->motion.window = window;
|
2012-11-18 19:14:32 +00:00
|
|
|
event->motion.time = get_time_from_ns_event ([NSApp currentEvent]);
|
2010-01-03 14:27:53 +00:00
|
|
|
event->motion.x = x;
|
|
|
|
event->motion.y = y;
|
|
|
|
event->motion.x_root = x_root;
|
|
|
|
event->motion.y_root = y_root;
|
|
|
|
/* FIXME event->axes */
|
2011-11-08 20:41:19 +00:00
|
|
|
event->motion.state = _gdk_quartz_events_get_current_keyboard_modifiers () |
|
|
|
|
_gdk_quartz_events_get_current_mouse_modifiers ();
|
2010-01-03 14:27:53 +00:00
|
|
|
event->motion.is_hint = FALSE;
|
2019-01-27 19:16:33 +00:00
|
|
|
gdk_event_set_device (event, gdk_seat_get_pointer (seat));
|
2018-12-03 12:24:03 +00:00
|
|
|
gdk_event_set_seat (event, seat);
|
2010-01-03 14:27:53 +00:00
|
|
|
|
|
|
|
append_event (event, TRUE);
|
|
|
|
}
|
|
|
|
|
2006-07-19 17:06:40 +00:00
|
|
|
/* Note: Used to both set a new focus window and to unset the old one. */
|
2005-11-22 10:03:32 +00:00
|
|
|
void
|
2007-04-06 21:12:48 +00:00
|
|
|
_gdk_quartz_events_update_focus_window (GdkWindow *window,
|
|
|
|
gboolean got_focus)
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
2006-07-19 17:06:40 +00:00
|
|
|
GdkEvent *event;
|
|
|
|
|
|
|
|
if (got_focus && window == current_keyboard_window)
|
|
|
|
return;
|
|
|
|
|
2010-12-22 15:55:56 +00:00
|
|
|
/* FIXME: Don't do this when grabbed? Or make GdkQuartzNSWindow
|
2006-07-24 10:46:21 +00:00
|
|
|
* disallow it in the first place instead?
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (!got_focus && window == current_keyboard_window)
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
2007-06-06 08:29:20 +00:00
|
|
|
event = create_focus_event (current_keyboard_window, FALSE);
|
2010-01-03 14:27:53 +00:00
|
|
|
append_event (event, FALSE);
|
2007-06-06 08:29:20 +00:00
|
|
|
g_object_unref (current_keyboard_window);
|
|
|
|
current_keyboard_window = NULL;
|
2006-07-19 17:06:40 +00:00
|
|
|
}
|
2005-11-22 10:03:32 +00:00
|
|
|
|
2006-07-19 17:06:40 +00:00
|
|
|
if (got_focus)
|
|
|
|
{
|
|
|
|
if (current_keyboard_window)
|
|
|
|
{
|
|
|
|
event = create_focus_event (current_keyboard_window, FALSE);
|
2010-01-03 14:27:53 +00:00
|
|
|
append_event (event, FALSE);
|
2006-07-19 17:06:40 +00:00
|
|
|
g_object_unref (current_keyboard_window);
|
|
|
|
current_keyboard_window = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
event = create_focus_event (window, TRUE);
|
2010-01-03 14:27:53 +00:00
|
|
|
append_event (event, FALSE);
|
2006-07-19 17:06:40 +00:00
|
|
|
current_keyboard_window = g_object_ref (window);
|
2010-01-03 14:27:53 +00:00
|
|
|
|
|
|
|
/* We just became the active window. Unlike X11, Mac OS X does
|
|
|
|
* not send us motion events while the window does not have focus
|
|
|
|
* ("is not key"). We send a dummy motion notify event now, so that
|
|
|
|
* everything in the window is set to correct state.
|
|
|
|
*/
|
|
|
|
generate_motion_event (window);
|
2005-11-22 10:03:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-16 19:57:43 +00:00
|
|
|
void
|
|
|
|
_gdk_quartz_events_send_map_event (GdkWindow *window)
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
2010-12-06 13:13:40 +00:00
|
|
|
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
|
2005-11-22 10:03:32 +00:00
|
|
|
|
2009-01-16 19:57:43 +00:00
|
|
|
if (!impl->toplevel)
|
2007-06-30 21:50:06 +00:00
|
|
|
return;
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
if (window->event_mask & GDK_STRUCTURE_MASK)
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
2009-01-16 19:57:43 +00:00
|
|
|
GdkEvent event;
|
2006-01-16 10:52:40 +00:00
|
|
|
|
2009-01-16 19:57:43 +00:00
|
|
|
event.any.type = GDK_MAP;
|
|
|
|
event.any.window = window;
|
2006-01-16 10:52:40 +00:00
|
|
|
|
2009-01-16 19:57:43 +00:00
|
|
|
gdk_event_put (&event);
|
2006-01-16 10:52:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-04 09:41:22 +00:00
|
|
|
static GdkWindow *
|
|
|
|
find_toplevel_under_pointer (GdkDisplay *display,
|
|
|
|
NSPoint screen_point,
|
|
|
|
gint *x,
|
|
|
|
gint *y)
|
|
|
|
{
|
|
|
|
GdkWindow *toplevel;
|
2010-05-25 22:38:44 +00:00
|
|
|
GdkPointerWindowInfo *info;
|
2018-12-03 12:24:03 +00:00
|
|
|
GdkSeat *seat = gdk_display_get_default_seat (display);
|
2009-02-04 09:41:22 +00:00
|
|
|
|
2018-12-03 12:24:03 +00:00
|
|
|
info = _gdk_display_get_pointer_info (display, gdk_seat_get_pointer (seat));
|
2010-05-25 22:38:44 +00:00
|
|
|
toplevel = info->toplevel_under_pointer;
|
2019-04-23 20:43:44 +00:00
|
|
|
|
2019-03-18 19:57:53 +00:00
|
|
|
if (!(toplevel && WINDOW_IS_TOPLEVEL (toplevel)))
|
|
|
|
{
|
|
|
|
gint gdk_x = 0, gdk_y = 0;
|
2020-06-20 18:16:18 +00:00
|
|
|
GdkDevice *pointer = gdk_seat_get_pointer(seat);
|
2019-03-18 19:57:53 +00:00
|
|
|
_gdk_quartz_window_nspoint_to_gdk_xy (screen_point, &gdk_x, &gdk_y);
|
2020-06-20 18:16:18 +00:00
|
|
|
toplevel = gdk_device_get_window_at_position (pointer, &gdk_x, &gdk_y);
|
2019-04-23 20:43:44 +00:00
|
|
|
|
|
|
|
if (toplevel && ! WINDOW_IS_TOPLEVEL (toplevel))
|
|
|
|
toplevel = gdk_window_get_toplevel (toplevel);
|
|
|
|
|
2019-04-23 18:39:17 +00:00
|
|
|
if (toplevel)
|
|
|
|
info->toplevel_under_pointer = g_object_ref (toplevel);
|
|
|
|
else
|
|
|
|
info->toplevel_under_pointer = NULL;
|
2019-04-23 20:43:44 +00:00
|
|
|
|
2019-03-18 19:57:53 +00:00
|
|
|
}
|
2019-04-23 20:43:44 +00:00
|
|
|
|
2012-11-15 10:34:15 +00:00
|
|
|
if (toplevel)
|
|
|
|
{
|
2019-03-18 19:57:53 +00:00
|
|
|
get_window_point_from_screen_point (toplevel, screen_point, x, y);
|
2012-11-15 10:34:15 +00:00
|
|
|
/* If the coordinates are out of window bounds, this toplevel is not
|
|
|
|
* under the pointer and we thus return NULL. This can occur when
|
|
|
|
* toplevel under pointer has not yet been updated due to a very recent
|
|
|
|
* window resize. Alternatively, we should no longer be relying on
|
|
|
|
* the toplevel_under_pointer value which is maintained in gdkwindow.c.
|
|
|
|
*/
|
|
|
|
if (*x < 0 || *y < 0 || *x >= toplevel->width || *y >= toplevel->height)
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-02-04 09:41:22 +00:00
|
|
|
return toplevel;
|
|
|
|
}
|
|
|
|
|
2010-05-25 22:38:44 +00:00
|
|
|
static GdkWindow *
|
|
|
|
find_toplevel_for_keyboard_event (NSEvent *nsevent)
|
|
|
|
{
|
2019-03-11 21:35:05 +00:00
|
|
|
GdkQuartzView *view = (GdkQuartzView *)[[nsevent window] contentView];
|
|
|
|
GdkWindow *window = [view gdkWindow];
|
|
|
|
GdkDisplay *display = gdk_window_get_display (window);
|
|
|
|
GdkSeat *seat = gdk_display_get_default_seat (display);
|
|
|
|
GdkDevice *device = gdk_seat_get_keyboard (seat);
|
|
|
|
GdkDeviceGrabInfo *grab = _gdk_display_get_last_device_grab (display, device);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
2019-03-11 21:35:05 +00:00
|
|
|
if (grab && grab->window && !grab->owner_events)
|
|
|
|
window = gdk_window_get_effective_toplevel (grab->window);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
|
|
return window;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GdkWindow *
|
|
|
|
find_toplevel_for_mouse_event (NSEvent *nsevent,
|
|
|
|
gint *x,
|
|
|
|
gint *y)
|
|
|
|
{
|
|
|
|
NSPoint screen_point;
|
|
|
|
NSEventType event_type;
|
|
|
|
GdkWindow *toplevel;
|
|
|
|
GdkDisplay *display;
|
|
|
|
GdkDeviceGrabInfo *grab;
|
2018-12-03 12:24:03 +00:00
|
|
|
GdkSeat *seat;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
2011-11-06 09:36:00 +00:00
|
|
|
toplevel = get_toplevel_from_ns_event (nsevent, &screen_point, x, y);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
2010-08-29 00:08:47 +00:00
|
|
|
display = gdk_window_get_display (toplevel);
|
2018-12-03 12:24:03 +00:00
|
|
|
seat = gdk_display_get_default_seat (_gdk_display);
|
|
|
|
|
2010-05-25 22:38:44 +00:00
|
|
|
event_type = [nsevent type];
|
|
|
|
|
|
|
|
/* From the docs for XGrabPointer:
|
|
|
|
*
|
|
|
|
* If owner_events is True and if a generated pointer event
|
|
|
|
* would normally be reported to this client, it is reported
|
|
|
|
* as usual. Otherwise, the event is reported with respect to
|
|
|
|
* the grab_window and is reported only if selected by
|
|
|
|
* event_mask. For either value of owner_events, unreported
|
|
|
|
* events are discarded.
|
|
|
|
*/
|
|
|
|
grab = _gdk_display_get_last_device_grab (display,
|
2018-12-03 12:24:03 +00:00
|
|
|
gdk_seat_get_pointer (seat));
|
2010-08-08 16:22:51 +00:00
|
|
|
if (WINDOW_IS_TOPLEVEL (toplevel) && grab)
|
2010-05-25 22:38:44 +00:00
|
|
|
{
|
|
|
|
/* Implicit grabs do not go through XGrabPointer and thus the
|
|
|
|
* event mask should not be checked.
|
|
|
|
*/
|
|
|
|
if (!grab->implicit
|
|
|
|
&& (grab->event_mask & get_event_mask_from_ns_event (nsevent)) == 0)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (grab->owner_events)
|
|
|
|
{
|
|
|
|
/* For owner events, we need to use the toplevel under the
|
|
|
|
* pointer, not the window from the NSEvent, since that is
|
|
|
|
* reported with respect to the key window, which could be
|
|
|
|
* wrong.
|
|
|
|
*/
|
|
|
|
GdkWindow *toplevel_under_pointer;
|
|
|
|
gint x_tmp, y_tmp;
|
|
|
|
|
|
|
|
toplevel_under_pointer = find_toplevel_under_pointer (display,
|
|
|
|
screen_point,
|
|
|
|
&x_tmp, &y_tmp);
|
|
|
|
if (toplevel_under_pointer)
|
|
|
|
{
|
|
|
|
toplevel = toplevel_under_pointer;
|
|
|
|
*x = x_tmp;
|
|
|
|
*y = y_tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
return toplevel;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Finally check the grab window. */
|
|
|
|
GdkWindow *grab_toplevel;
|
|
|
|
|
2010-08-08 16:22:51 +00:00
|
|
|
grab_toplevel = gdk_window_get_effective_toplevel (grab->window);
|
2011-11-05 21:43:17 +00:00
|
|
|
get_window_point_from_screen_point (grab_toplevel, screen_point,
|
|
|
|
x, y);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
|
|
return grab_toplevel;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* The non-grabbed case. */
|
|
|
|
GdkWindow *toplevel_under_pointer;
|
|
|
|
gint x_tmp, y_tmp;
|
|
|
|
|
|
|
|
/* Ignore all events but mouse moved that might be on the title
|
|
|
|
* bar (above the content view). The reason is that otherwise
|
|
|
|
* gdk gets confused about getting e.g. button presses with no
|
|
|
|
* window (the title bar is not known to it).
|
|
|
|
*/
|
2018-12-03 12:06:41 +00:00
|
|
|
if (event_type != GDK_QUARTZ_MOUSE_MOVED)
|
2010-05-25 22:38:44 +00:00
|
|
|
if (*y < 0)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* As for owner events, we need to use the toplevel under the
|
|
|
|
* pointer, not the window from the NSEvent.
|
|
|
|
*/
|
|
|
|
toplevel_under_pointer = find_toplevel_under_pointer (display,
|
|
|
|
screen_point,
|
|
|
|
&x_tmp, &y_tmp);
|
2010-08-08 16:22:51 +00:00
|
|
|
if (toplevel_under_pointer
|
|
|
|
&& WINDOW_IS_TOPLEVEL (toplevel_under_pointer))
|
2010-05-25 22:38:44 +00:00
|
|
|
{
|
|
|
|
GdkWindowImplQuartz *toplevel_impl;
|
|
|
|
|
|
|
|
toplevel = toplevel_under_pointer;
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
toplevel_impl = (GdkWindowImplQuartz *)toplevel->impl;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
|
|
*x = x_tmp;
|
|
|
|
*y = y_tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
return toplevel;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2007-06-17 18:41:36 +00:00
|
|
|
/* This function finds the correct window to send an event to, taking
|
|
|
|
* into account grabs, event propagation, and event masks.
|
|
|
|
*/
|
|
|
|
static GdkWindow *
|
|
|
|
find_window_for_ns_event (NSEvent *nsevent,
|
|
|
|
gint *x,
|
2009-01-29 12:53:13 +00:00
|
|
|
gint *y,
|
|
|
|
gint *x_root,
|
|
|
|
gint *y_root)
|
2007-06-17 18:41:36 +00:00
|
|
|
{
|
2009-02-03 15:01:31 +00:00
|
|
|
GdkQuartzView *view;
|
2011-11-05 21:53:22 +00:00
|
|
|
GdkWindow *toplevel;
|
2009-02-02 13:46:47 +00:00
|
|
|
NSPoint screen_point;
|
2007-06-17 18:41:36 +00:00
|
|
|
NSEventType event_type;
|
|
|
|
|
2009-02-03 15:01:31 +00:00
|
|
|
view = (GdkQuartzView *)[[nsevent window] contentView];
|
2009-01-21 18:09:34 +00:00
|
|
|
|
2011-11-05 21:53:22 +00:00
|
|
|
toplevel = get_toplevel_from_ns_event (nsevent, &screen_point, x, y);
|
2012-11-15 10:34:15 +00:00
|
|
|
if (!toplevel)
|
|
|
|
return NULL;
|
2009-10-25 20:36:56 +00:00
|
|
|
_gdk_quartz_window_nspoint_to_gdk_xy (screen_point, x_root, y_root);
|
2009-01-29 12:53:13 +00:00
|
|
|
|
2007-06-17 18:41:36 +00:00
|
|
|
event_type = [nsevent type];
|
2005-11-22 10:03:32 +00:00
|
|
|
|
|
|
|
switch (event_type)
|
|
|
|
{
|
2018-12-03 12:06:41 +00:00
|
|
|
case GDK_QUARTZ_LEFT_MOUSE_DOWN:
|
|
|
|
case GDK_QUARTZ_RIGHT_MOUSE_DOWN:
|
|
|
|
case GDK_QUARTZ_OTHER_MOUSE_DOWN:
|
|
|
|
case GDK_QUARTZ_LEFT_MOUSE_UP:
|
|
|
|
case GDK_QUARTZ_RIGHT_MOUSE_UP:
|
|
|
|
case GDK_QUARTZ_OTHER_MOUSE_UP:
|
|
|
|
case GDK_QUARTZ_MOUSE_MOVED:
|
|
|
|
case GDK_QUARTZ_SCROLL_WHEEL:
|
|
|
|
case GDK_QUARTZ_LEFT_MOUSE_DRAGGED:
|
|
|
|
case GDK_QUARTZ_RIGHT_MOUSE_DRAGGED:
|
|
|
|
case GDK_QUARTZ_OTHER_MOUSE_DRAGGED:
|
2016-01-07 14:51:31 +00:00
|
|
|
case NSEventTypeMagnify:
|
|
|
|
case NSEventTypeRotate:
|
2010-05-25 22:38:44 +00:00
|
|
|
return find_toplevel_for_mouse_event (nsevent, x, y);
|
2018-12-03 12:06:41 +00:00
|
|
|
|
|
|
|
case GDK_QUARTZ_MOUSE_ENTERED:
|
|
|
|
case GDK_QUARTZ_MOUSE_EXITED:
|
2009-02-03 15:01:31 +00:00
|
|
|
/* Only handle our own entered/exited events, not the ones for the
|
|
|
|
* titlebar buttons.
|
|
|
|
*/
|
|
|
|
if ([view trackingRect] == [nsevent trackingNumber])
|
|
|
|
return toplevel;
|
|
|
|
else
|
|
|
|
return NULL;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
2018-12-03 12:06:41 +00:00
|
|
|
case GDK_QUARTZ_KEY_DOWN:
|
|
|
|
case GDK_QUARTZ_KEY_UP:
|
|
|
|
case GDK_QUARTZ_FLAGS_CHANGED:
|
2010-05-25 22:38:44 +00:00
|
|
|
return find_toplevel_for_keyboard_event (nsevent);
|
2005-11-22 10:03:32 +00:00
|
|
|
|
|
|
|
default:
|
2007-06-17 14:29:21 +00:00
|
|
|
/* Ignore everything else. */
|
|
|
|
break;
|
2005-11-22 10:03:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-01-16 19:22:01 +00:00
|
|
|
static void
|
|
|
|
fill_crossing_event (GdkWindow *toplevel,
|
|
|
|
GdkEvent *event,
|
|
|
|
NSEvent *nsevent,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
2009-01-29 12:53:13 +00:00
|
|
|
gint x_root,
|
|
|
|
gint y_root,
|
2009-01-16 19:22:01 +00:00
|
|
|
GdkEventType event_type,
|
|
|
|
GdkCrossingMode mode,
|
|
|
|
GdkNotifyType detail)
|
|
|
|
{
|
2018-12-03 12:24:03 +00:00
|
|
|
GdkSeat *seat = gdk_display_get_default_seat (_gdk_display);
|
2016-03-10 06:10:04 +00:00
|
|
|
|
2009-01-16 19:22:01 +00:00
|
|
|
event->any.type = event_type;
|
|
|
|
event->crossing.window = toplevel;
|
|
|
|
event->crossing.subwindow = NULL;
|
|
|
|
event->crossing.time = get_time_from_ns_event (nsevent);
|
|
|
|
event->crossing.x = x;
|
|
|
|
event->crossing.y = y;
|
2009-01-29 12:53:13 +00:00
|
|
|
event->crossing.x_root = x_root;
|
|
|
|
event->crossing.y_root = y_root;
|
2009-01-16 19:22:01 +00:00
|
|
|
event->crossing.mode = mode;
|
|
|
|
event->crossing.detail = detail;
|
2011-11-08 20:41:19 +00:00
|
|
|
event->crossing.state = get_keyboard_modifiers_from_ns_event (nsevent) |
|
|
|
|
_gdk_quartz_events_get_current_mouse_modifiers ();
|
2009-01-16 19:22:01 +00:00
|
|
|
|
2018-12-03 12:24:03 +00:00
|
|
|
gdk_event_set_device (event, gdk_seat_get_pointer (seat));
|
|
|
|
gdk_event_set_seat (event, seat);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
2009-01-16 19:22:01 +00:00
|
|
|
/* FIXME: Focus and button state? */
|
|
|
|
}
|
|
|
|
|
2016-01-07 14:51:31 +00:00
|
|
|
/* fill_pinch_event handles the conversion from the two OSX gesture events
|
|
|
|
NSEventTypeMagnfiy and NSEventTypeRotate to the GDK_TOUCHPAD_PINCH event.
|
|
|
|
The normal behavior of the OSX events is that they produce as sequence of
|
|
|
|
1 x NSEventPhaseBegan,
|
|
|
|
n x NSEventPhaseChanged,
|
|
|
|
1 x NSEventPhaseEnded
|
|
|
|
This can happen for both the Magnify and the Rotate events independently.
|
|
|
|
As both events are summarized in one GDK_TOUCHPAD_PINCH event sequence, a
|
|
|
|
little state machine handles the case of two NSEventPhaseBegan events in
|
|
|
|
a sequence, e.g. Magnify(Began), Magnify(Changed)..., Rotate(Began)...
|
|
|
|
such that PINCH(STARTED), PINCH(UPDATE).... will not show a second
|
|
|
|
PINCH(STARTED) event.
|
|
|
|
*/
|
2016-04-07 07:33:41 +00:00
|
|
|
#ifdef AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER
|
2016-01-07 14:51:31 +00:00
|
|
|
static void
|
|
|
|
fill_pinch_event (GdkWindow *window,
|
|
|
|
GdkEvent *event,
|
|
|
|
NSEvent *nsevent,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint x_root,
|
|
|
|
gint y_root)
|
|
|
|
{
|
|
|
|
static double last_scale = 1.0;
|
|
|
|
static enum {
|
|
|
|
FP_STATE_IDLE,
|
|
|
|
FP_STATE_UPDATE
|
|
|
|
} last_state = FP_STATE_IDLE;
|
2018-12-03 12:24:03 +00:00
|
|
|
GdkSeat *seat = gdk_display_get_default_seat (_gdk_display);
|
2016-01-07 14:51:31 +00:00
|
|
|
|
|
|
|
event->any.type = GDK_TOUCHPAD_PINCH;
|
|
|
|
event->touchpad_pinch.window = window;
|
|
|
|
event->touchpad_pinch.time = get_time_from_ns_event (nsevent);
|
|
|
|
event->touchpad_pinch.x = x;
|
|
|
|
event->touchpad_pinch.y = y;
|
|
|
|
event->touchpad_pinch.x_root = x_root;
|
|
|
|
event->touchpad_pinch.y_root = y_root;
|
|
|
|
event->touchpad_pinch.state = get_keyboard_modifiers_from_ns_event (nsevent);
|
|
|
|
event->touchpad_pinch.n_fingers = 2;
|
|
|
|
event->touchpad_pinch.dx = 0.0;
|
|
|
|
event->touchpad_pinch.dy = 0.0;
|
2018-12-03 12:24:03 +00:00
|
|
|
gdk_event_set_device (event, gdk_seat_get_pointer (seat));
|
2016-01-07 14:51:31 +00:00
|
|
|
|
|
|
|
switch ([nsevent phase])
|
|
|
|
{
|
|
|
|
case NSEventPhaseBegan:
|
|
|
|
switch (last_state)
|
|
|
|
{
|
|
|
|
case FP_STATE_IDLE:
|
|
|
|
event->touchpad_pinch.phase = GDK_TOUCHPAD_GESTURE_PHASE_BEGIN;
|
|
|
|
last_state = FP_STATE_UPDATE;
|
|
|
|
last_scale = 1.0;
|
|
|
|
break;
|
|
|
|
case FP_STATE_UPDATE:
|
|
|
|
/* We have already received a PhaseBegan event but no PhaseEnded
|
|
|
|
event. This can happen, e.g. Magnify(Began), Magnify(Change)...
|
|
|
|
Rotate(Began), Rotate (Change),...., Magnify(End) Rotate(End)
|
|
|
|
*/
|
|
|
|
event->touchpad_pinch.phase = GDK_TOUCHPAD_GESTURE_PHASE_UPDATE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NSEventPhaseChanged:
|
|
|
|
event->touchpad_pinch.phase = GDK_TOUCHPAD_GESTURE_PHASE_UPDATE;
|
|
|
|
break;
|
|
|
|
case NSEventPhaseEnded:
|
|
|
|
event->touchpad_pinch.phase = GDK_TOUCHPAD_GESTURE_PHASE_END;
|
|
|
|
switch (last_state)
|
|
|
|
{
|
|
|
|
case FP_STATE_IDLE:
|
|
|
|
/* We are idle but have received a second PhaseEnded event.
|
|
|
|
This can happen because we have Magnify and Rotate OSX
|
|
|
|
event sequences. We just send a second end GDK_PHASE_END.
|
|
|
|
*/
|
|
|
|
break;
|
|
|
|
case FP_STATE_UPDATE:
|
|
|
|
last_state = FP_STATE_IDLE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NSEventPhaseCancelled:
|
|
|
|
event->touchpad_pinch.phase = GDK_TOUCHPAD_GESTURE_PHASE_CANCEL;
|
|
|
|
last_state = FP_STATE_IDLE;
|
|
|
|
break;
|
|
|
|
case NSEventPhaseMayBegin:
|
|
|
|
case NSEventPhaseStationary:
|
|
|
|
event->touchpad_pinch.phase = GDK_TOUCHPAD_GESTURE_PHASE_CANCEL;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch ([nsevent type])
|
|
|
|
{
|
|
|
|
case NSEventTypeMagnify:
|
|
|
|
last_scale *= [nsevent magnification] + 1.0;
|
|
|
|
event->touchpad_pinch.angle_delta = 0.0;
|
|
|
|
break;
|
|
|
|
case NSEventTypeRotate:
|
|
|
|
event->touchpad_pinch.angle_delta = - [nsevent rotation] * G_PI / 180.0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
|
|
|
event->touchpad_pinch.scale = last_scale;
|
|
|
|
}
|
2016-04-07 07:33:41 +00:00
|
|
|
#endif /* OSX Version >= 10.8 */
|
2016-01-07 14:51:31 +00:00
|
|
|
|
2009-01-16 11:21:46 +00:00
|
|
|
static void
|
|
|
|
fill_button_event (GdkWindow *window,
|
|
|
|
GdkEvent *event,
|
|
|
|
NSEvent *nsevent,
|
|
|
|
gint x,
|
2009-01-29 12:53:13 +00:00
|
|
|
gint y,
|
|
|
|
gint x_root,
|
|
|
|
gint y_root)
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
|
|
|
GdkEventType type;
|
2019-01-27 19:16:33 +00:00
|
|
|
GdkDevice *event_device = NULL;
|
|
|
|
gdouble *axes = NULL;
|
2007-07-03 20:31:59 +00:00
|
|
|
gint state;
|
2018-12-03 12:24:03 +00:00
|
|
|
GdkSeat *seat = gdk_display_get_default_seat (_gdk_display);
|
2007-07-03 20:31:59 +00:00
|
|
|
|
2011-11-08 23:25:01 +00:00
|
|
|
state = get_keyboard_modifiers_from_ns_event (nsevent) |
|
|
|
|
_gdk_quartz_events_get_current_mouse_modifiers ();
|
2005-11-22 10:03:32 +00:00
|
|
|
|
|
|
|
switch ([nsevent type])
|
|
|
|
{
|
2018-12-03 12:06:41 +00:00
|
|
|
case GDK_QUARTZ_LEFT_MOUSE_DOWN:
|
|
|
|
case GDK_QUARTZ_RIGHT_MOUSE_DOWN:
|
|
|
|
case GDK_QUARTZ_OTHER_MOUSE_DOWN:
|
2005-11-22 10:03:32 +00:00
|
|
|
type = GDK_BUTTON_PRESS;
|
2011-11-08 23:25:01 +00:00
|
|
|
state &= ~get_mouse_button_modifiers_from_ns_event (nsevent);
|
2005-11-22 10:03:32 +00:00
|
|
|
break;
|
2011-11-08 23:25:01 +00:00
|
|
|
|
2018-12-03 12:06:41 +00:00
|
|
|
case GDK_QUARTZ_LEFT_MOUSE_UP:
|
|
|
|
case GDK_QUARTZ_RIGHT_MOUSE_UP:
|
|
|
|
case GDK_QUARTZ_OTHER_MOUSE_UP:
|
2005-11-22 10:03:32 +00:00
|
|
|
type = GDK_BUTTON_RELEASE;
|
2007-07-03 20:31:59 +00:00
|
|
|
state |= get_mouse_button_modifiers_from_ns_event (nsevent);
|
2005-11-22 10:03:32 +00:00
|
|
|
break;
|
2011-11-08 23:25:01 +00:00
|
|
|
|
2005-11-22 10:03:32 +00:00
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
2006-07-24 10:46:21 +00:00
|
|
|
|
2019-01-27 19:16:33 +00:00
|
|
|
event_device = _gdk_quartz_device_manager_core_device_for_ns_event (gdk_display_get_device_manager (_gdk_display),
|
|
|
|
nsevent);
|
|
|
|
|
|
|
|
if ([nsevent subtype] == GDK_QUARTZ_EVENT_SUBTYPE_TABLET_POINT)
|
|
|
|
{
|
|
|
|
axes = g_new (gdouble, TABLET_AXES);
|
|
|
|
|
|
|
|
axes[0] = x;
|
|
|
|
axes[1] = y;
|
|
|
|
axes[2] = [nsevent pressure];
|
|
|
|
axes[3] = [nsevent tilt].x;
|
|
|
|
axes[4] = [nsevent tilt].y;
|
|
|
|
}
|
|
|
|
|
2009-01-16 11:21:46 +00:00
|
|
|
event->any.type = type;
|
2005-11-22 10:03:32 +00:00
|
|
|
event->button.window = window;
|
2007-06-01 21:03:34 +00:00
|
|
|
event->button.time = get_time_from_ns_event (nsevent);
|
2005-11-22 10:03:32 +00:00
|
|
|
event->button.x = x;
|
|
|
|
event->button.y = y;
|
2009-01-29 12:53:13 +00:00
|
|
|
event->button.x_root = x_root;
|
|
|
|
event->button.y_root = y_root;
|
2019-01-27 19:16:33 +00:00
|
|
|
event->button.axes = axes;
|
2007-07-03 20:31:59 +00:00
|
|
|
event->button.state = state;
|
2011-11-08 23:25:01 +00:00
|
|
|
event->button.button = get_mouse_button_from_ns_event (nsevent);
|
2018-12-03 12:24:03 +00:00
|
|
|
|
2019-01-27 19:16:33 +00:00
|
|
|
gdk_event_set_device (event, gdk_seat_get_pointer (seat));
|
|
|
|
gdk_event_set_source_device (event, event_device);
|
2018-12-03 12:24:03 +00:00
|
|
|
gdk_event_set_seat (event, seat);
|
2005-11-22 10:03:32 +00:00
|
|
|
}
|
|
|
|
|
2009-01-16 11:21:46 +00:00
|
|
|
static void
|
|
|
|
fill_motion_event (GdkWindow *window,
|
|
|
|
GdkEvent *event,
|
|
|
|
NSEvent *nsevent,
|
|
|
|
gint x,
|
2009-01-29 12:53:13 +00:00
|
|
|
gint y,
|
|
|
|
gint x_root,
|
|
|
|
gint y_root)
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
2018-12-03 12:24:03 +00:00
|
|
|
GdkSeat *seat = gdk_display_get_default_seat (_gdk_display);
|
2019-01-27 19:16:33 +00:00
|
|
|
GdkDevice *event_device = NULL;
|
|
|
|
gdouble *axes = NULL;
|
|
|
|
|
|
|
|
event_device = _gdk_quartz_device_manager_core_device_for_ns_event (gdk_display_get_device_manager (_gdk_display),
|
|
|
|
nsevent);
|
|
|
|
|
|
|
|
if ([nsevent subtype] == GDK_QUARTZ_EVENT_SUBTYPE_TABLET_POINT)
|
|
|
|
{
|
|
|
|
axes = g_new (gdouble, TABLET_AXES);
|
|
|
|
|
|
|
|
axes[0] = x;
|
|
|
|
axes[1] = y;
|
|
|
|
axes[2] = [nsevent pressure];
|
|
|
|
axes[3] = [nsevent tilt].x;
|
|
|
|
axes[4] = [nsevent tilt].y;
|
|
|
|
}
|
2016-03-10 06:10:04 +00:00
|
|
|
|
2009-01-16 18:42:09 +00:00
|
|
|
event->any.type = GDK_MOTION_NOTIFY;
|
2005-11-22 10:03:32 +00:00
|
|
|
event->motion.window = window;
|
2007-06-01 21:03:34 +00:00
|
|
|
event->motion.time = get_time_from_ns_event (nsevent);
|
2005-11-22 10:03:32 +00:00
|
|
|
event->motion.x = x;
|
|
|
|
event->motion.y = y;
|
2009-01-29 12:53:13 +00:00
|
|
|
event->motion.x_root = x_root;
|
|
|
|
event->motion.y_root = y_root;
|
2019-01-27 19:16:33 +00:00
|
|
|
event->motion.axes = axes;
|
2011-11-08 23:34:45 +00:00
|
|
|
event->motion.state = get_keyboard_modifiers_from_ns_event (nsevent) |
|
|
|
|
_gdk_quartz_events_get_current_mouse_modifiers ();
|
2005-11-22 10:03:32 +00:00
|
|
|
event->motion.is_hint = FALSE;
|
2019-01-27 19:16:33 +00:00
|
|
|
gdk_event_set_device (event, gdk_seat_get_pointer (seat));
|
|
|
|
gdk_event_set_source_device (event, event_device);
|
|
|
|
|
2018-12-03 12:24:03 +00:00
|
|
|
gdk_event_set_seat (event, seat);
|
2005-11-22 10:03:32 +00:00
|
|
|
}
|
|
|
|
|
2009-01-16 11:21:46 +00:00
|
|
|
static void
|
|
|
|
fill_scroll_event (GdkWindow *window,
|
|
|
|
GdkEvent *event,
|
|
|
|
NSEvent *nsevent,
|
2009-01-16 18:42:09 +00:00
|
|
|
gint x,
|
|
|
|
gint y,
|
2009-01-29 12:53:13 +00:00
|
|
|
gint x_root,
|
|
|
|
gint y_root,
|
2012-01-23 23:41:49 +00:00
|
|
|
gdouble delta_x,
|
|
|
|
gdouble delta_y,
|
2009-01-16 11:21:46 +00:00
|
|
|
GdkScrollDirection direction)
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
2018-12-03 12:24:03 +00:00
|
|
|
GdkSeat *seat = gdk_display_get_default_seat (_gdk_display);
|
2006-07-17 08:07:55 +00:00
|
|
|
NSPoint point;
|
2009-01-16 18:42:09 +00:00
|
|
|
|
|
|
|
point = [nsevent locationInWindow];
|
|
|
|
|
2009-01-16 11:21:46 +00:00
|
|
|
event->any.type = GDK_SCROLL;
|
2005-11-22 10:03:32 +00:00
|
|
|
event->scroll.window = window;
|
2007-06-01 21:03:34 +00:00
|
|
|
event->scroll.time = get_time_from_ns_event (nsevent);
|
2009-01-16 18:42:09 +00:00
|
|
|
event->scroll.x = x;
|
|
|
|
event->scroll.y = y;
|
2009-01-29 12:53:13 +00:00
|
|
|
event->scroll.x_root = x_root;
|
|
|
|
event->scroll.y_root = y_root;
|
2008-02-16 09:49:52 +00:00
|
|
|
event->scroll.state = get_keyboard_modifiers_from_ns_event (nsevent);
|
2005-11-22 10:03:32 +00:00
|
|
|
event->scroll.direction = direction;
|
2012-01-23 23:41:49 +00:00
|
|
|
event->scroll.delta_x = delta_x;
|
|
|
|
event->scroll.delta_y = delta_y;
|
2019-01-27 19:16:33 +00:00
|
|
|
gdk_event_set_device (event, gdk_seat_get_pointer (seat));
|
2018-12-03 12:24:03 +00:00
|
|
|
gdk_event_set_seat (event, seat);
|
2005-11-22 10:03:32 +00:00
|
|
|
}
|
|
|
|
|
2009-01-16 11:21:46 +00:00
|
|
|
static void
|
|
|
|
fill_key_event (GdkWindow *window,
|
|
|
|
GdkEvent *event,
|
|
|
|
NSEvent *nsevent,
|
|
|
|
GdkEventType type)
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
2008-05-06 21:00:06 +00:00
|
|
|
GdkEventPrivate *priv;
|
2018-12-03 12:24:03 +00:00
|
|
|
GdkSeat *seat = gdk_display_get_default_seat (_gdk_display);
|
2006-07-17 18:39:43 +00:00
|
|
|
gchar buf[7];
|
|
|
|
gunichar c = 0;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
2008-05-06 21:00:06 +00:00
|
|
|
priv = (GdkEventPrivate *) event;
|
|
|
|
priv->windowing_data = [nsevent retain];
|
|
|
|
|
2009-01-16 18:42:09 +00:00
|
|
|
event->any.type = type;
|
2005-11-22 10:03:32 +00:00
|
|
|
event->key.window = window;
|
2007-06-01 21:03:34 +00:00
|
|
|
event->key.time = get_time_from_ns_event (nsevent);
|
|
|
|
event->key.state = get_keyboard_modifiers_from_ns_event (nsevent);
|
2005-11-22 10:03:32 +00:00
|
|
|
event->key.hardware_keycode = [nsevent keyCode];
|
2016-05-10 19:16:45 +00:00
|
|
|
gdk_event_set_scancode (event, [nsevent keyCode]);
|
2018-12-03 12:06:41 +00:00
|
|
|
event->key.group = ([nsevent modifierFlags] & GDK_QUARTZ_ALTERNATE_KEY_MASK) ? 1 : 0;
|
2010-09-13 14:26:02 +00:00
|
|
|
event->key.keyval = GDK_KEY_VoidSymbol;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
2018-12-03 12:24:03 +00:00
|
|
|
gdk_event_set_device (event, gdk_seat_get_keyboard (seat));
|
|
|
|
gdk_event_set_seat (event, seat);
|
|
|
|
|
2010-12-22 21:33:05 +00:00
|
|
|
gdk_keymap_translate_keyboard_state (gdk_keymap_get_for_display (_gdk_display),
|
2005-11-22 10:03:32 +00:00
|
|
|
event->key.hardware_keycode,
|
2018-12-03 12:24:03 +00:00
|
|
|
event->key.state,
|
2005-11-22 10:03:32 +00:00
|
|
|
event->key.group,
|
|
|
|
&event->key.keyval,
|
|
|
|
NULL, NULL, NULL);
|
|
|
|
|
2007-04-06 21:12:48 +00:00
|
|
|
event->key.is_modifier = _gdk_quartz_keys_is_modifier (event->key.hardware_keycode);
|
2006-07-17 18:39:43 +00:00
|
|
|
|
2007-07-03 18:49:09 +00:00
|
|
|
/* If the key press is a modifier, the state should include the mask
|
|
|
|
* for that modifier but only for releases, not presses. This
|
|
|
|
* matches the X11 backend behavior.
|
|
|
|
*/
|
|
|
|
if (event->key.is_modifier)
|
|
|
|
{
|
|
|
|
int mask = 0;
|
|
|
|
|
|
|
|
switch (event->key.keyval)
|
|
|
|
{
|
2010-09-13 14:26:02 +00:00
|
|
|
case GDK_KEY_Meta_R:
|
|
|
|
case GDK_KEY_Meta_L:
|
2011-09-16 13:54:03 +00:00
|
|
|
mask = GDK_MOD2_MASK;
|
2007-07-03 18:49:09 +00:00
|
|
|
break;
|
2010-09-13 14:26:02 +00:00
|
|
|
case GDK_KEY_Shift_R:
|
|
|
|
case GDK_KEY_Shift_L:
|
2007-07-03 18:49:09 +00:00
|
|
|
mask = GDK_SHIFT_MASK;
|
|
|
|
break;
|
2010-09-13 14:26:02 +00:00
|
|
|
case GDK_KEY_Caps_Lock:
|
2007-07-03 18:49:09 +00:00
|
|
|
mask = GDK_LOCK_MASK;
|
|
|
|
break;
|
2010-09-13 14:26:02 +00:00
|
|
|
case GDK_KEY_Alt_R:
|
|
|
|
case GDK_KEY_Alt_L:
|
2011-09-16 13:54:03 +00:00
|
|
|
mask = GDK_MOD1_MASK;
|
2007-07-03 18:49:09 +00:00
|
|
|
break;
|
2010-09-13 14:26:02 +00:00
|
|
|
case GDK_KEY_Control_R:
|
|
|
|
case GDK_KEY_Control_L:
|
2007-07-03 18:49:09 +00:00
|
|
|
mask = GDK_CONTROL_MASK;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
mask = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (type == GDK_KEY_PRESS)
|
|
|
|
event->key.state &= ~mask;
|
|
|
|
else if (type == GDK_KEY_RELEASE)
|
|
|
|
event->key.state |= mask;
|
|
|
|
}
|
|
|
|
|
2011-11-08 20:41:19 +00:00
|
|
|
event->key.state |= _gdk_quartz_events_get_current_mouse_modifiers ();
|
2007-07-03 20:31:59 +00:00
|
|
|
|
2012-01-19 15:12:11 +00:00
|
|
|
/* The X11 backend adds the first virtual modifier MOD2..MOD5 are
|
|
|
|
* mapped to. Since we only have one virtual modifier in the quartz
|
|
|
|
* backend, calling the standard function will do.
|
|
|
|
*/
|
|
|
|
gdk_keymap_add_virtual_modifiers (gdk_keymap_get_for_display (_gdk_display),
|
|
|
|
&event->key.state);
|
|
|
|
|
2006-07-17 18:39:43 +00:00
|
|
|
event->key.string = NULL;
|
|
|
|
|
|
|
|
/* Fill in ->string since apps depend on it, taken from the x11 backend. */
|
2010-09-13 14:26:02 +00:00
|
|
|
if (event->key.keyval != GDK_KEY_VoidSymbol)
|
2006-07-17 18:39:43 +00:00
|
|
|
c = gdk_keyval_to_unicode (event->key.keyval);
|
|
|
|
|
2009-02-03 12:45:06 +00:00
|
|
|
if (c)
|
2006-07-17 18:39:43 +00:00
|
|
|
{
|
|
|
|
gsize bytes_written;
|
|
|
|
gint len;
|
|
|
|
|
|
|
|
len = g_unichar_to_utf8 (c, buf);
|
|
|
|
buf[len] = '\0';
|
|
|
|
|
|
|
|
event->key.string = g_locale_from_utf8 (buf, len,
|
|
|
|
NULL, &bytes_written,
|
|
|
|
NULL);
|
|
|
|
if (event->key.string)
|
|
|
|
event->key.length = bytes_written;
|
|
|
|
}
|
2010-09-13 14:26:02 +00:00
|
|
|
else if (event->key.keyval == GDK_KEY_Escape)
|
2006-07-17 18:39:43 +00:00
|
|
|
{
|
|
|
|
event->key.length = 1;
|
|
|
|
event->key.string = g_strdup ("\033");
|
|
|
|
}
|
2010-09-13 14:26:02 +00:00
|
|
|
else if (event->key.keyval == GDK_KEY_Return ||
|
|
|
|
event->key.keyval == GDK_KEY_KP_Enter)
|
2006-07-17 18:39:43 +00:00
|
|
|
{
|
|
|
|
event->key.length = 1;
|
|
|
|
event->key.string = g_strdup ("\r");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!event->key.string)
|
|
|
|
{
|
|
|
|
event->key.length = 0;
|
|
|
|
event->key.string = g_strdup ("");
|
|
|
|
}
|
|
|
|
|
2006-07-07 20:19:22 +00:00
|
|
|
GDK_NOTE(EVENTS,
|
|
|
|
g_message ("key %s:\t\twindow: %p key: %12s %d",
|
|
|
|
type == GDK_KEY_PRESS ? "press" : "release",
|
|
|
|
event->key.window,
|
|
|
|
event->key.keyval ? gdk_keyval_name (event->key.keyval) : "(none)",
|
|
|
|
event->key.keyval));
|
2005-11-22 10:03:32 +00:00
|
|
|
}
|
|
|
|
|
2009-01-16 19:57:43 +00:00
|
|
|
static gboolean
|
|
|
|
synthesize_crossing_event (GdkWindow *window,
|
|
|
|
GdkEvent *event,
|
|
|
|
NSEvent *nsevent,
|
|
|
|
gint x,
|
2009-01-29 12:53:13 +00:00
|
|
|
gint y,
|
|
|
|
gint x_root,
|
|
|
|
gint y_root)
|
2009-01-16 19:57:43 +00:00
|
|
|
{
|
|
|
|
switch ([nsevent type])
|
|
|
|
{
|
2018-12-03 12:06:41 +00:00
|
|
|
case GDK_QUARTZ_MOUSE_ENTERED:
|
2012-11-09 16:12:30 +00:00
|
|
|
/* Enter events are considered always to be from another toplevel
|
|
|
|
* window, this shouldn't negatively affect any app or gtk code,
|
|
|
|
* and is the only way to make GtkMenu work. EEK EEK EEK.
|
2009-02-03 12:45:06 +00:00
|
|
|
*/
|
2010-12-06 13:13:40 +00:00
|
|
|
if (!(window->event_mask & GDK_ENTER_NOTIFY_MASK))
|
2009-02-03 12:45:06 +00:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
fill_crossing_event (window, event, nsevent,
|
|
|
|
x, y,
|
|
|
|
x_root, y_root,
|
|
|
|
GDK_ENTER_NOTIFY,
|
|
|
|
GDK_CROSSING_NORMAL,
|
2012-11-09 16:12:30 +00:00
|
|
|
GDK_NOTIFY_NONLINEAR);
|
2009-01-16 19:57:43 +00:00
|
|
|
return TRUE;
|
|
|
|
|
2018-12-03 12:06:41 +00:00
|
|
|
case GDK_QUARTZ_MOUSE_EXITED:
|
2012-11-09 16:12:30 +00:00
|
|
|
/* See above */
|
2010-12-06 13:13:40 +00:00
|
|
|
if (!(window->event_mask & GDK_LEAVE_NOTIFY_MASK))
|
2009-02-03 12:45:06 +00:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
fill_crossing_event (window, event, nsevent,
|
|
|
|
x, y,
|
|
|
|
x_root, y_root,
|
|
|
|
GDK_LEAVE_NOTIFY,
|
|
|
|
GDK_CROSSING_NORMAL,
|
2012-11-09 16:12:30 +00:00
|
|
|
GDK_NOTIFY_NONLINEAR);
|
2009-01-16 19:57:43 +00:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2013-08-16 16:54:34 +00:00
|
|
|
void
|
|
|
|
_gdk_quartz_synthesize_null_key_event (GdkWindow *window)
|
|
|
|
{
|
|
|
|
GdkEvent *event;
|
2018-12-03 12:24:03 +00:00
|
|
|
GdkSeat *seat = gdk_display_get_default_seat (_gdk_display);
|
2013-08-16 16:54:34 +00:00
|
|
|
|
|
|
|
event = gdk_event_new (GDK_KEY_PRESS);
|
|
|
|
event->any.type = GDK_KEY_PRESS;
|
|
|
|
event->key.window = window;
|
|
|
|
event->key.state = 0;
|
|
|
|
event->key.hardware_keycode = 0;
|
|
|
|
event->key.group = 0;
|
|
|
|
event->key.keyval = GDK_KEY_VoidSymbol;
|
2018-12-03 12:24:03 +00:00
|
|
|
|
|
|
|
gdk_event_set_device (event, gdk_seat_get_keyboard (seat));
|
|
|
|
gdk_event_set_seat (event, seat);
|
2013-08-16 16:54:34 +00:00
|
|
|
append_event(event, FALSE);
|
|
|
|
}
|
|
|
|
|
2011-07-25 20:26:52 +00:00
|
|
|
GdkModifierType
|
|
|
|
_gdk_quartz_events_get_current_keyboard_modifiers (void)
|
|
|
|
{
|
2011-11-08 20:41:19 +00:00
|
|
|
if (gdk_quartz_osx_version () >= GDK_OSX_SNOW_LEOPARD)
|
|
|
|
{
|
|
|
|
return get_keyboard_modifiers_from_ns_flags ([NSClassFromString(@"NSEvent") modifierFlags]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
guint carbon_modifiers = GetCurrentKeyModifiers ();
|
|
|
|
GdkModifierType modifiers = 0;
|
|
|
|
|
|
|
|
if (carbon_modifiers & alphaLock)
|
|
|
|
modifiers |= GDK_LOCK_MASK;
|
|
|
|
if (carbon_modifiers & shiftKey)
|
|
|
|
modifiers |= GDK_SHIFT_MASK;
|
|
|
|
if (carbon_modifiers & controlKey)
|
|
|
|
modifiers |= GDK_CONTROL_MASK;
|
|
|
|
if (carbon_modifiers & optionKey)
|
|
|
|
modifiers |= GDK_MOD1_MASK;
|
|
|
|
if (carbon_modifiers & cmdKey)
|
|
|
|
modifiers |= GDK_MOD2_MASK;
|
|
|
|
|
|
|
|
return modifiers;
|
|
|
|
}
|
2011-07-25 20:26:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GdkModifierType
|
|
|
|
_gdk_quartz_events_get_current_mouse_modifiers (void)
|
|
|
|
{
|
2020-06-20 18:16:18 +00:00
|
|
|
NSUInteger buttons = 0;
|
2019-03-15 19:35:57 +00:00
|
|
|
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
|
2011-11-08 20:41:19 +00:00
|
|
|
if (gdk_quartz_osx_version () >= GDK_OSX_SNOW_LEOPARD)
|
2020-06-20 18:16:18 +00:00
|
|
|
buttons = [NSClassFromString(@"NSEvent") pressedMouseButtons];
|
2019-03-15 19:35:57 +00:00
|
|
|
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
|
2011-11-08 20:41:19 +00:00
|
|
|
else
|
2019-03-15 19:35:57 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
|
2020-06-20 18:16:18 +00:00
|
|
|
buttons = GetCurrentButtonState ();
|
2019-03-15 19:35:57 +00:00
|
|
|
#endif
|
2020-06-20 18:16:18 +00:00
|
|
|
return get_mouse_button_modifiers_from_ns_buttons (buttons);
|
2011-07-25 20:26:52 +00:00
|
|
|
}
|
|
|
|
|
2011-08-13 22:30:59 +00:00
|
|
|
/* Detect window resizing */
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
test_resize (NSEvent *event, GdkWindow *toplevel, gint x, gint y)
|
|
|
|
{
|
|
|
|
GdkWindowImplQuartz *toplevel_impl;
|
|
|
|
gboolean lion;
|
2011-11-06 08:33:50 +00:00
|
|
|
|
2018-12-03 12:06:41 +00:00
|
|
|
/* Resizing from the resize indicator only begins if an GDK_QUARTZ_LEFT_MOUSE_BUTTON
|
2012-05-13 15:57:59 +00:00
|
|
|
* event is received in the resizing area.
|
2011-08-13 22:30:59 +00:00
|
|
|
*/
|
|
|
|
toplevel_impl = (GdkWindowImplQuartz *)toplevel->impl;
|
|
|
|
if ([toplevel_impl->toplevel showsResizeIndicator])
|
2018-12-03 12:06:41 +00:00
|
|
|
if ([event type] == GDK_QUARTZ_LEFT_MOUSE_DOWN &&
|
2012-05-13 15:57:59 +00:00
|
|
|
[toplevel_impl->toplevel showsResizeIndicator])
|
2011-08-13 22:30:59 +00:00
|
|
|
{
|
|
|
|
NSRect frame;
|
|
|
|
|
|
|
|
/* If the resize indicator is visible and the event
|
|
|
|
* is in the lower right 15x15 corner, we leave these
|
|
|
|
* events to Cocoa as to be handled as resize events.
|
|
|
|
* Applications may have widgets in this area. These
|
|
|
|
* will most likely be larger than 15x15 and for
|
|
|
|
* scroll bars there are also other means to move
|
|
|
|
* the scroll bar. Since the resize indicator is
|
|
|
|
* the only way of resizing windows on Mac OS, it
|
|
|
|
* is too important to not make functional.
|
|
|
|
*/
|
|
|
|
frame = [toplevel_impl->view bounds];
|
2011-11-06 08:33:50 +00:00
|
|
|
if (x > frame.size.width - GRIP_WIDTH &&
|
|
|
|
x < frame.size.width &&
|
|
|
|
y > frame.size.height - GRIP_HEIGHT &&
|
|
|
|
y < frame.size.height)
|
|
|
|
return TRUE;
|
2011-08-13 22:30:59 +00:00
|
|
|
}
|
2011-11-06 08:33:50 +00:00
|
|
|
|
2011-08-13 22:30:59 +00:00
|
|
|
/* If we're on Lion and within 5 pixels of an edge,
|
|
|
|
* then assume that the user wants to resize, and
|
|
|
|
* return NULL to let Quartz get on with it. We check
|
|
|
|
* the selector isRestorable to see if we're on 10.7.
|
|
|
|
* This extra check is in case the user starts
|
|
|
|
* dragging before GDK recognizes the grab.
|
2012-05-13 15:57:59 +00:00
|
|
|
*
|
|
|
|
* We perform this check for a button press of all buttons, because we
|
|
|
|
* do receive, for instance, a right mouse down event for a GDK window
|
|
|
|
* for x-coordinate range [-3, 0], but we do not want to forward this
|
|
|
|
* into GDK. Forwarding such events into GDK will confuse the pointer
|
|
|
|
* window finding code, because there are no GdkWindows present in
|
|
|
|
* the range [-3, 0].
|
2011-08-13 22:30:59 +00:00
|
|
|
*/
|
2011-11-06 08:33:50 +00:00
|
|
|
lion = gdk_quartz_osx_version () >= GDK_OSX_LION;
|
2012-05-13 15:57:59 +00:00
|
|
|
if (lion &&
|
2018-12-03 12:06:41 +00:00
|
|
|
([event type] == GDK_QUARTZ_LEFT_MOUSE_DOWN ||
|
|
|
|
[event type] == GDK_QUARTZ_RIGHT_MOUSE_DOWN ||
|
|
|
|
[event type] == GDK_QUARTZ_OTHER_MOUSE_DOWN))
|
2012-05-13 15:57:59 +00:00
|
|
|
{
|
|
|
|
if (x < GDK_LION_RESIZE ||
|
|
|
|
x > toplevel->width - GDK_LION_RESIZE ||
|
|
|
|
y > toplevel->height - GDK_LION_RESIZE)
|
|
|
|
return TRUE;
|
|
|
|
}
|
2011-11-06 08:33:50 +00:00
|
|
|
|
2011-08-13 22:30:59 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-12-03 12:06:41 +00:00
|
|
|
#if MAC_OS_X_VERSION_MIN_REQUIRED < 101200
|
|
|
|
#define GDK_QUARTZ_APP_KIT_DEFINED NSAppKitDefined
|
|
|
|
#define GDK_QUARTZ_APPLICATION_DEACTIVATED NSApplicationDeactivatedEventType
|
|
|
|
#else
|
|
|
|
#define GDK_QUARTZ_APP_KIT_DEFINED NSEventTypeAppKitDefined
|
|
|
|
#define GDK_QUARTZ_APPLICATION_DEACTIVATED NSEventSubtypeApplicationDeactivated
|
|
|
|
#endif
|
|
|
|
|
2005-11-22 10:03:32 +00:00
|
|
|
static gboolean
|
2009-01-16 11:21:46 +00:00
|
|
|
gdk_event_translate (GdkEvent *event,
|
|
|
|
NSEvent *nsevent)
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
2009-01-29 12:53:13 +00:00
|
|
|
NSEventType event_type;
|
2007-06-16 16:16:43 +00:00
|
|
|
NSWindow *nswindow;
|
2005-11-22 10:03:32 +00:00
|
|
|
GdkWindow *window;
|
|
|
|
int x, y;
|
2009-01-29 12:53:13 +00:00
|
|
|
int x_root, y_root;
|
2009-01-16 11:21:46 +00:00
|
|
|
gboolean return_val;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
2007-06-16 16:16:43 +00:00
|
|
|
/* There is no support for real desktop wide grabs, so we break
|
|
|
|
* grabs when the application loses focus (gets deactivated).
|
|
|
|
*/
|
2009-01-29 12:53:13 +00:00
|
|
|
event_type = [nsevent type];
|
2018-12-03 12:06:41 +00:00
|
|
|
if (event_type == GDK_QUARTZ_APP_KIT_DEFINED)
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
2018-12-03 12:06:41 +00:00
|
|
|
if ([nsevent subtype] == GDK_QUARTZ_APPLICATION_DEACTIVATED)
|
2012-02-19 15:02:09 +00:00
|
|
|
_gdk_quartz_events_break_all_grabs (get_time_from_ns_event (nsevent));
|
2007-06-16 16:16:43 +00:00
|
|
|
|
|
|
|
/* This could potentially be used to break grabs when clicking
|
|
|
|
* on the title. The subtype 20 is undocumented so it's probably
|
|
|
|
* not a good idea: else if (subtype == 20) break_all_grabs ();
|
|
|
|
*/
|
2009-01-29 13:05:54 +00:00
|
|
|
|
|
|
|
/* Leave all AppKit events to AppKit. */
|
|
|
|
return FALSE;
|
2007-06-16 16:16:43 +00:00
|
|
|
}
|
2005-11-22 10:03:32 +00:00
|
|
|
|
2008-05-12 11:23:28 +00:00
|
|
|
if (_gdk_default_filters)
|
|
|
|
{
|
2009-01-16 11:21:46 +00:00
|
|
|
/* Apply global filters */
|
|
|
|
GdkFilterReturn result;
|
2008-05-12 11:23:28 +00:00
|
|
|
|
2010-11-20 22:58:50 +00:00
|
|
|
result = gdk_event_apply_filters (nsevent, event, &_gdk_default_filters);
|
2009-01-16 11:21:46 +00:00
|
|
|
if (result != GDK_FILTER_CONTINUE)
|
|
|
|
{
|
|
|
|
return_val = (result == GDK_FILTER_TRANSLATE) ? TRUE : FALSE;
|
|
|
|
goto done;
|
|
|
|
}
|
2008-05-12 11:23:28 +00:00
|
|
|
}
|
|
|
|
|
2019-01-27 19:16:33 +00:00
|
|
|
/* We need to register the proximity event from any point on the screen
|
|
|
|
* to properly register the devices
|
|
|
|
*/
|
|
|
|
if (event_type == GDK_QUARTZ_EVENT_TABLET_PROXIMITY)
|
|
|
|
{
|
|
|
|
_gdk_quartz_device_manager_register_device_for_ns_event (gdk_display_get_device_manager (_gdk_display),
|
|
|
|
nsevent);
|
|
|
|
}
|
|
|
|
|
2009-01-21 18:09:34 +00:00
|
|
|
nswindow = [nsevent window];
|
|
|
|
|
2011-11-06 08:25:16 +00:00
|
|
|
/* Ignore events for windows not created by GDK. */
|
|
|
|
if (nswindow && ![[nswindow contentView] isKindOfClass:[GdkQuartzView class]])
|
2007-06-16 16:16:43 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2011-11-06 08:25:16 +00:00
|
|
|
/* Ignore events for ones with no windows */
|
|
|
|
if (!nswindow)
|
|
|
|
{
|
|
|
|
GdkWindow *toplevel = NULL;
|
|
|
|
|
2018-12-03 12:06:41 +00:00
|
|
|
if (event_type == GDK_QUARTZ_MOUSE_MOVED)
|
2011-11-06 08:25:16 +00:00
|
|
|
{
|
|
|
|
/* Motion events received after clicking the menu bar do not have the
|
|
|
|
* window field set. Instead of giving up on the event immediately,
|
|
|
|
* we first check whether this event is within our window bounds.
|
|
|
|
*/
|
|
|
|
NSPoint screen_point = [NSEvent mouseLocation];
|
|
|
|
gint x_tmp, y_tmp;
|
|
|
|
|
|
|
|
toplevel = find_toplevel_under_pointer (_gdk_display,
|
|
|
|
screen_point,
|
|
|
|
&x_tmp, &y_tmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!toplevel)
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2007-06-16 21:39:42 +00:00
|
|
|
/* Ignore events and break grabs while the window is being
|
|
|
|
* dragged. This is a workaround for the window getting events for
|
|
|
|
* the window title.
|
|
|
|
*/
|
2010-12-22 15:55:56 +00:00
|
|
|
if ([(GdkQuartzNSWindow *)nswindow isInMove])
|
2007-06-16 21:39:42 +00:00
|
|
|
{
|
2012-02-19 15:02:09 +00:00
|
|
|
_gdk_quartz_events_break_all_grabs (get_time_from_ns_event (nsevent));
|
2007-06-16 21:39:42 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2013-12-13 01:18:01 +00:00
|
|
|
/* Also when in a manual resize or move , we ignore events so that
|
|
|
|
* these are pushed to GdkQuartzNSWindow's sendEvent handler.
|
2012-02-19 15:08:26 +00:00
|
|
|
*/
|
2013-12-13 01:18:01 +00:00
|
|
|
if ([(GdkQuartzNSWindow *)nswindow isInManualResizeOrMove])
|
2012-02-19 15:08:26 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2007-06-17 18:41:36 +00:00
|
|
|
/* Find the right GDK window to send the event to, taking grabs and
|
2007-06-16 16:16:43 +00:00
|
|
|
* event masks into consideration.
|
|
|
|
*/
|
2009-01-29 12:53:13 +00:00
|
|
|
window = find_window_for_ns_event (nsevent, &x, &y, &x_root, &y_root);
|
2005-11-22 10:03:32 +00:00
|
|
|
if (!window)
|
|
|
|
return FALSE;
|
2011-11-06 08:33:50 +00:00
|
|
|
|
2011-08-13 22:30:59 +00:00
|
|
|
/* Quartz handles resizing on its own, so we want to stay out of the way. */
|
2011-11-06 08:33:50 +00:00
|
|
|
if (test_resize (nsevent, window, x, y))
|
2011-08-13 22:30:59 +00:00
|
|
|
return FALSE;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
2007-06-16 16:16:43 +00:00
|
|
|
/* Apply any window filters. */
|
2009-01-16 11:21:46 +00:00
|
|
|
if (GDK_IS_WINDOW (window))
|
|
|
|
{
|
|
|
|
GdkFilterReturn result;
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
if (window->filters)
|
2009-01-16 11:21:46 +00:00
|
|
|
{
|
|
|
|
g_object_ref (window);
|
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
result = gdk_event_apply_filters (nsevent, event, &window->filters);
|
2009-01-16 11:21:46 +00:00
|
|
|
|
|
|
|
g_object_unref (window);
|
|
|
|
|
|
|
|
if (result != GDK_FILTER_CONTINUE)
|
|
|
|
{
|
|
|
|
return_val = (result == GDK_FILTER_TRANSLATE) ? TRUE : FALSE;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-08-15 20:13:13 +00:00
|
|
|
|
2009-02-20 14:36:15 +00:00
|
|
|
/* If the app is not active leave the event to AppKit so the window gets
|
|
|
|
* focused correctly and don't do click-through (so we behave like most
|
|
|
|
* native apps). If the app is active, we focus the window and then handle
|
|
|
|
* the event, also to match native apps.
|
2007-06-17 14:29:21 +00:00
|
|
|
*/
|
2018-12-03 12:06:41 +00:00
|
|
|
if ((event_type == GDK_QUARTZ_RIGHT_MOUSE_DOWN ||
|
|
|
|
event_type == GDK_QUARTZ_OTHER_MOUSE_DOWN ||
|
|
|
|
event_type == GDK_QUARTZ_LEFT_MOUSE_DOWN))
|
2007-06-17 14:29:21 +00:00
|
|
|
{
|
2010-12-06 13:13:40 +00:00
|
|
|
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
|
2009-01-31 20:25:41 +00:00
|
|
|
|
|
|
|
if (![NSApp isActive])
|
2009-02-03 17:47:09 +00:00
|
|
|
{
|
|
|
|
[NSApp activateIgnoringOtherApps:YES];
|
|
|
|
return FALSE;
|
|
|
|
}
|
2009-01-31 20:32:11 +00:00
|
|
|
else if (![impl->toplevel isKeyWindow])
|
2009-02-20 14:36:15 +00:00
|
|
|
{
|
2010-05-25 22:38:44 +00:00
|
|
|
GdkDeviceGrabInfo *grab;
|
2018-12-03 12:24:03 +00:00
|
|
|
GdkSeat *seat = gdk_display_get_default_seat (_gdk_display);
|
2009-02-20 14:36:15 +00:00
|
|
|
|
2010-05-25 22:38:44 +00:00
|
|
|
grab = _gdk_display_get_last_device_grab (_gdk_display,
|
2018-12-03 12:24:03 +00:00
|
|
|
gdk_seat_get_pointer (seat));
|
2019-03-11 21:28:20 +00:00
|
|
|
if (!grab)
|
|
|
|
[impl->toplevel makeKeyWindow];
|
|
|
|
|
2009-02-20 14:36:15 +00:00
|
|
|
}
|
2007-06-17 14:29:21 +00:00
|
|
|
}
|
2018-12-14 23:57:24 +00:00
|
|
|
|
|
|
|
return_val = TRUE;
|
|
|
|
|
2009-01-29 12:53:13 +00:00
|
|
|
switch (event_type)
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
2018-12-03 12:06:41 +00:00
|
|
|
case GDK_QUARTZ_LEFT_MOUSE_DOWN:
|
|
|
|
case GDK_QUARTZ_RIGHT_MOUSE_DOWN:
|
|
|
|
case GDK_QUARTZ_OTHER_MOUSE_DOWN:
|
|
|
|
case GDK_QUARTZ_LEFT_MOUSE_UP:
|
|
|
|
case GDK_QUARTZ_RIGHT_MOUSE_UP:
|
|
|
|
case GDK_QUARTZ_OTHER_MOUSE_UP:
|
2009-01-29 12:53:13 +00:00
|
|
|
fill_button_event (window, event, nsevent, x, y, x_root, y_root);
|
2005-11-22 10:03:32 +00:00
|
|
|
break;
|
|
|
|
|
2018-12-03 12:06:41 +00:00
|
|
|
case GDK_QUARTZ_LEFT_MOUSE_DRAGGED:
|
|
|
|
case GDK_QUARTZ_RIGHT_MOUSE_DRAGGED:
|
|
|
|
case GDK_QUARTZ_OTHER_MOUSE_DRAGGED:
|
|
|
|
case GDK_QUARTZ_MOUSE_MOVED:
|
2009-01-29 12:53:13 +00:00
|
|
|
fill_motion_event (window, event, nsevent, x, y, x_root, y_root);
|
2005-11-22 10:03:32 +00:00
|
|
|
break;
|
|
|
|
|
2018-12-03 12:06:41 +00:00
|
|
|
case GDK_QUARTZ_SCROLL_WHEEL:
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
2012-01-23 23:41:49 +00:00
|
|
|
GdkScrollDirection direction;
|
|
|
|
float dx;
|
|
|
|
float dy;
|
2012-03-02 01:00:35 +00:00
|
|
|
#ifdef AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
|
2012-01-23 23:41:49 +00:00
|
|
|
if (gdk_quartz_osx_version() >= GDK_OSX_LION &&
|
|
|
|
[nsevent hasPreciseScrollingDeltas])
|
|
|
|
{
|
|
|
|
dx = [nsevent scrollingDeltaX];
|
|
|
|
dy = [nsevent scrollingDeltaY];
|
|
|
|
direction = GDK_SCROLL_SMOOTH;
|
|
|
|
|
|
|
|
fill_scroll_event (window, event, nsevent, x, y, x_root, y_root,
|
|
|
|
-dx, -dy, direction);
|
|
|
|
|
|
|
|
/* Fall through for scroll buttons emulation */
|
|
|
|
}
|
2012-03-02 01:00:35 +00:00
|
|
|
#endif
|
2012-01-23 23:41:49 +00:00
|
|
|
dx = [nsevent deltaX];
|
|
|
|
dy = [nsevent deltaY];
|
|
|
|
|
|
|
|
if (dy != 0.0)
|
2009-01-16 18:47:16 +00:00
|
|
|
{
|
|
|
|
if (dy < 0.0)
|
|
|
|
direction = GDK_SCROLL_DOWN;
|
|
|
|
else
|
|
|
|
direction = GDK_SCROLL_UP;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
2012-01-23 23:41:49 +00:00
|
|
|
dy = fabs (dy);
|
|
|
|
dx = 0.0;
|
2009-01-16 18:47:16 +00:00
|
|
|
}
|
2012-01-23 23:41:49 +00:00
|
|
|
else if (dx != 0.0)
|
2009-01-16 18:47:16 +00:00
|
|
|
{
|
|
|
|
if (dx < 0.0)
|
|
|
|
direction = GDK_SCROLL_RIGHT;
|
|
|
|
else
|
|
|
|
direction = GDK_SCROLL_LEFT;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
2012-01-23 23:41:49 +00:00
|
|
|
dx = fabs (dx);
|
|
|
|
dy = 0.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dx != 0.0 || dy != 0.0)
|
|
|
|
{
|
2012-09-03 23:56:46 +00:00
|
|
|
#ifdef AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
|
2012-10-25 17:58:47 +00:00
|
|
|
if (gdk_quartz_osx_version() >= GDK_OSX_LION &&
|
|
|
|
[nsevent hasPreciseScrollingDeltas])
|
2012-01-23 23:41:49 +00:00
|
|
|
{
|
|
|
|
GdkEvent *emulated_event;
|
|
|
|
|
|
|
|
emulated_event = gdk_event_new (GDK_SCROLL);
|
2016-05-10 19:16:45 +00:00
|
|
|
gdk_event_set_pointer_emulated (emulated_event, TRUE);
|
2012-01-23 23:41:49 +00:00
|
|
|
fill_scroll_event (window, emulated_event, nsevent,
|
|
|
|
x, y, x_root, y_root,
|
|
|
|
dx, dy, direction);
|
|
|
|
append_event (emulated_event, TRUE);
|
|
|
|
}
|
|
|
|
else
|
2012-09-03 23:56:46 +00:00
|
|
|
#endif
|
2012-01-23 23:41:49 +00:00
|
|
|
fill_scroll_event (window, event, nsevent,
|
|
|
|
x, y, x_root, y_root,
|
|
|
|
dx, dy, direction);
|
2009-01-16 18:47:16 +00:00
|
|
|
}
|
2005-11-22 10:03:32 +00:00
|
|
|
}
|
2007-06-17 14:29:21 +00:00
|
|
|
break;
|
2016-04-07 07:33:41 +00:00
|
|
|
#ifdef AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER
|
2016-01-07 14:51:31 +00:00
|
|
|
case NSEventTypeMagnify:
|
|
|
|
case NSEventTypeRotate:
|
|
|
|
/* Event handling requires [NSEvent phase] which was introduced in 10.7 */
|
2016-04-07 07:33:41 +00:00
|
|
|
/* However - Tests on 10.7 showed that phase property does not work */
|
|
|
|
if (gdk_quartz_osx_version () >= GDK_OSX_MOUNTAIN_LION)
|
2016-01-07 14:51:31 +00:00
|
|
|
fill_pinch_event (window, event, nsevent, x, y, x_root, y_root);
|
|
|
|
else
|
|
|
|
return_val = FALSE;
|
|
|
|
break;
|
|
|
|
#endif
|
2018-12-03 12:06:41 +00:00
|
|
|
case GDK_QUARTZ_MOUSE_EXITED:
|
2013-08-08 14:36:28 +00:00
|
|
|
if (WINDOW_IS_TOPLEVEL (window))
|
|
|
|
[[NSCursor arrowCursor] set];
|
|
|
|
/* fall through */
|
2018-12-03 12:06:41 +00:00
|
|
|
case GDK_QUARTZ_MOUSE_ENTERED:
|
2009-01-29 12:53:13 +00:00
|
|
|
return_val = synthesize_crossing_event (window, event, nsevent, x, y, x_root, y_root);
|
2009-01-16 19:57:43 +00:00
|
|
|
break;
|
|
|
|
|
2018-12-03 12:06:41 +00:00
|
|
|
case GDK_QUARTZ_KEY_DOWN:
|
|
|
|
case GDK_QUARTZ_KEY_UP:
|
|
|
|
case GDK_QUARTZ_FLAGS_CHANGED:
|
2006-07-07 20:19:22 +00:00
|
|
|
{
|
2006-07-20 08:06:54 +00:00
|
|
|
GdkEventType type;
|
|
|
|
|
2007-04-06 21:12:48 +00:00
|
|
|
type = _gdk_quartz_keys_event_type (nsevent);
|
2006-07-07 20:19:22 +00:00
|
|
|
if (type == GDK_NOTHING)
|
2009-01-16 11:21:46 +00:00
|
|
|
return_val = FALSE;
|
|
|
|
else
|
|
|
|
fill_key_event (window, event, nsevent, type);
|
2006-07-07 20:19:22 +00:00
|
|
|
}
|
2006-07-20 08:06:54 +00:00
|
|
|
break;
|
2007-06-17 14:29:21 +00:00
|
|
|
|
2005-11-22 10:03:32 +00:00
|
|
|
default:
|
2007-06-17 14:29:21 +00:00
|
|
|
/* Ignore everything elsee. */
|
2009-01-21 18:09:34 +00:00
|
|
|
return_val = FALSE;
|
2007-06-17 14:29:21 +00:00
|
|
|
break;
|
2005-11-22 10:03:32 +00:00
|
|
|
}
|
|
|
|
|
2009-01-16 11:21:46 +00:00
|
|
|
done:
|
|
|
|
if (return_val)
|
|
|
|
{
|
|
|
|
if (event->any.window)
|
|
|
|
g_object_ref (event->any.window);
|
|
|
|
if (((event->any.type == GDK_ENTER_NOTIFY) ||
|
|
|
|
(event->any.type == GDK_LEAVE_NOTIFY)) &&
|
|
|
|
(event->crossing.subwindow != NULL))
|
|
|
|
g_object_ref (event->crossing.subwindow);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Mark this event as having no resources to be freed */
|
|
|
|
event->any.window = NULL;
|
|
|
|
event->any.type = GDK_NOTHING;
|
|
|
|
}
|
|
|
|
|
|
|
|
return return_val;
|
2005-11-22 10:03:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-12-17 16:46:22 +00:00
|
|
|
_gdk_quartz_display_queue_events (GdkDisplay *display)
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
2009-01-16 11:21:46 +00:00
|
|
|
NSEvent *nsevent;
|
2006-12-28 09:04:48 +00:00
|
|
|
|
2009-01-16 11:21:46 +00:00
|
|
|
nsevent = _gdk_quartz_event_loop_get_pending ();
|
|
|
|
if (nsevent)
|
2006-07-19 17:06:40 +00:00
|
|
|
{
|
2009-01-16 11:21:46 +00:00
|
|
|
GdkEvent *event;
|
|
|
|
GList *node;
|
|
|
|
|
|
|
|
event = gdk_event_new (GDK_NOTHING);
|
|
|
|
|
|
|
|
event->any.window = NULL;
|
|
|
|
event->any.send_event = FALSE;
|
|
|
|
|
|
|
|
((GdkEventPrivate *)event)->flags |= GDK_EVENT_PENDING;
|
|
|
|
|
|
|
|
node = _gdk_event_queue_append (display, event);
|
|
|
|
|
|
|
|
if (gdk_event_translate (event, nsevent))
|
|
|
|
{
|
|
|
|
((GdkEventPrivate *)event)->flags &= ~GDK_EVENT_PENDING;
|
2009-01-24 08:43:55 +00:00
|
|
|
_gdk_windowing_got_event (display, node, event, 0);
|
2009-01-16 11:21:46 +00:00
|
|
|
}
|
|
|
|
else
|
2008-04-30 17:46:00 +00:00
|
|
|
{
|
2009-01-16 11:21:46 +00:00
|
|
|
_gdk_event_queue_remove_link (display, node);
|
|
|
|
g_list_free_1 (node);
|
|
|
|
gdk_event_free (event);
|
|
|
|
|
2012-07-28 12:40:04 +00:00
|
|
|
gdk_threads_leave ();
|
2009-01-16 11:21:46 +00:00
|
|
|
[NSApp sendEvent:nsevent];
|
2012-07-28 12:40:04 +00:00
|
|
|
gdk_threads_enter ();
|
2008-04-30 17:46:00 +00:00
|
|
|
}
|
2007-12-10 19:00:23 +00:00
|
|
|
|
2009-01-16 11:21:46 +00:00
|
|
|
_gdk_quartz_event_loop_release_event (nsevent);
|
2006-07-19 17:06:40 +00:00
|
|
|
}
|
2005-11-22 10:03:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-12-17 14:50:21 +00:00
|
|
|
_gdk_quartz_screen_broadcast_client_message (GdkScreen *screen,
|
|
|
|
GdkEvent *event)
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
2006-07-20 08:06:54 +00:00
|
|
|
/* Not supported. */
|
2005-11-22 10:03:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2010-12-17 14:50:21 +00:00
|
|
|
_gdk_quartz_screen_get_setting (GdkScreen *screen,
|
|
|
|
const gchar *name,
|
|
|
|
GValue *value)
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
2007-03-10 20:50:58 +00:00
|
|
|
if (strcmp (name, "gtk-double-click-time") == 0)
|
2006-07-24 12:31:17 +00:00
|
|
|
{
|
2008-05-26 18:51:35 +00:00
|
|
|
NSUserDefaults *defaults;
|
2006-07-24 12:31:17 +00:00
|
|
|
float t;
|
|
|
|
|
|
|
|
GDK_QUARTZ_ALLOC_POOL;
|
2008-05-26 18:51:35 +00:00
|
|
|
|
|
|
|
defaults = [NSUserDefaults standardUserDefaults];
|
2006-07-24 12:31:17 +00:00
|
|
|
|
|
|
|
t = [defaults floatForKey:@"com.apple.mouse.doubleClickThreshold"];
|
|
|
|
if (t == 0.0)
|
|
|
|
{
|
|
|
|
/* No user setting, use the default in OS X. */
|
|
|
|
t = 0.5;
|
|
|
|
}
|
|
|
|
|
|
|
|
GDK_QUARTZ_RELEASE_POOL;
|
|
|
|
|
|
|
|
g_value_set_int (value, t * 1000);
|
2008-05-26 18:51:35 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else if (strcmp (name, "gtk-font-name") == 0)
|
|
|
|
{
|
|
|
|
NSString *name;
|
|
|
|
char *str;
|
2014-08-24 12:08:57 +00:00
|
|
|
gint size;
|
2008-05-26 18:51:35 +00:00
|
|
|
|
|
|
|
GDK_QUARTZ_ALLOC_POOL;
|
|
|
|
|
|
|
|
name = [[NSFont systemFontOfSize:0] familyName];
|
2014-08-24 12:08:57 +00:00
|
|
|
size = (gint)[[NSFont userFontOfSize:0] pointSize];
|
2008-05-26 18:51:35 +00:00
|
|
|
|
|
|
|
/* Let's try to use the "views" font size (12pt) by default. This is
|
|
|
|
* used for lists/text/other "content" which is the largest parts of
|
|
|
|
* apps, using the "regular control" size (13pt) looks a bit out of
|
|
|
|
* place. We might have to tweak this.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* The size has to be hardcoded as there doesn't seem to be a way to
|
|
|
|
* get the views font size programmatically.
|
|
|
|
*/
|
2014-08-24 12:08:57 +00:00
|
|
|
str = g_strdup_printf ("%s %d", [name UTF8String], size);
|
2008-05-26 18:51:35 +00:00
|
|
|
g_value_set_string (value, str);
|
|
|
|
g_free (str);
|
|
|
|
|
|
|
|
GDK_QUARTZ_RELEASE_POOL;
|
|
|
|
|
2012-08-24 09:49:43 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else if (strcmp (name, "gtk-primary-button-warps-slider") == 0)
|
|
|
|
{
|
|
|
|
GDK_QUARTZ_ALLOC_POOL;
|
|
|
|
|
|
|
|
BOOL setting = [[NSUserDefaults standardUserDefaults] boolForKey:@"AppleScrollerPagingBehavior"];
|
|
|
|
|
|
|
|
/* If the Apple property is YES, it means "warp" */
|
|
|
|
g_value_set_boolean (value, setting == YES);
|
|
|
|
|
|
|
|
GDK_QUARTZ_RELEASE_POOL;
|
|
|
|
|
2006-07-24 12:31:17 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2013-11-15 12:50:37 +00:00
|
|
|
else if (strcmp (name, "gtk-shell-shows-desktop") == 0)
|
|
|
|
{
|
|
|
|
GDK_QUARTZ_ALLOC_POOL;
|
|
|
|
|
|
|
|
g_value_set_boolean (value, TRUE);
|
|
|
|
|
|
|
|
GDK_QUARTZ_RELEASE_POOL;
|
2013-11-16 15:05:04 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2005-11-22 10:03:32 +00:00
|
|
|
|
|
|
|
/* FIXME: Add more settings */
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
2008-05-06 21:00:06 +00:00
|
|
|
|
|
|
|
void
|
2010-12-17 17:25:47 +00:00
|
|
|
_gdk_quartz_display_event_data_copy (GdkDisplay *display,
|
|
|
|
const GdkEvent *src,
|
|
|
|
GdkEvent *dst)
|
2008-05-06 21:00:06 +00:00
|
|
|
{
|
|
|
|
GdkEventPrivate *priv_src = (GdkEventPrivate *) src;
|
2008-05-06 22:35:13 +00:00
|
|
|
GdkEventPrivate *priv_dst = (GdkEventPrivate *) dst;
|
2008-05-06 21:00:06 +00:00
|
|
|
|
|
|
|
if (priv_src->windowing_data)
|
|
|
|
{
|
|
|
|
priv_dst->windowing_data = priv_src->windowing_data;
|
|
|
|
[(NSEvent *)priv_dst->windowing_data retain];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-12-17 17:25:47 +00:00
|
|
|
_gdk_quartz_display_event_data_free (GdkDisplay *display,
|
|
|
|
GdkEvent *event)
|
2008-05-06 21:00:06 +00:00
|
|
|
{
|
|
|
|
GdkEventPrivate *priv = (GdkEventPrivate *) event;
|
|
|
|
|
|
|
|
if (priv->windowing_data)
|
|
|
|
{
|
|
|
|
[(NSEvent *)priv->windowing_data release];
|
|
|
|
priv->windowing_data = NULL;
|
|
|
|
}
|
|
|
|
}
|