Commit f30ed5dd authored by John Ralls's avatar John Ralls

Fix Cocoa style and event constants for MacOS X 10.12 and later.

parent 941f3c38
......@@ -120,6 +120,13 @@
inMove = YES;
}
#ifdef AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER
#define NSLeftMouseUp NSEventTypeLeftMouseUp
#define NSLeftMouseDragged NSEventTypeLeftMouseDragged
#define NSMouseEntered NSEventTypeMouseEntered
#endif
-(void)sendEvent:(NSEvent *)event
{
switch ([event type])
......@@ -255,7 +262,11 @@
}
-(id)initWithContentRect:(NSRect)contentRect
#if MAC_OS_X_VERSION_MIN_REQUIRED < 101200
styleMask:(NSUInteger)styleMask
#else
styleMask:(NSWindowStyleMask)styleMask
#endif
backing:(NSBackingStoreType)backingType
defer:(BOOL)flag
screen:(NSScreen *)screen
......@@ -805,17 +816,27 @@ update_context_from_dragging_info (id <NSDraggingInfo> sender)
}
#ifdef AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
#if MAC_OS_X_VERSION_MIN_REQUIRED < 101200
typedef enum
{
GDK_QUARTZ_FULL_SCREEN_MASK = NSFullScreenWindowMask,
} GdkQuartzFullScreen;
#else
typedef enum
{
GDK_QUARTZ_FULL_SCREEN_MASK = NSWindowStyleMaskFullScreen,
} GdkQuartzFullScreen;
#endif
- (void)setStyleMask:(NSUInteger)styleMask
{
gboolean was_fullscreen;
gboolean is_fullscreen;
was_fullscreen = (([self styleMask] & NSFullScreenWindowMask) != 0);
was_fullscreen = (([self styleMask] & GDK_QUARTZ_FULL_SCREEN_MASK) != 0);
[super setStyleMask:styleMask];
is_fullscreen = (([self styleMask] & NSFullScreenWindowMask) != 0);
is_fullscreen = (([self styleMask] & GDK_QUARTZ_FULL_SCREEN_MASK) != 0);
if (was_fullscreen != is_fullscreen)
_gdk_quartz_window_update_fullscreen_state ([[self contentView] gdkWindow]);
......
......@@ -292,13 +292,19 @@ select_thread_func (void *arg)
}
}
#if MAC_OS_X_VERSION_MIN_REQUIRED < 101200
#define GDK_QUARTZ_APPLICATION_DEFINED NSApplicationDefined
#else
#define GDK_QUARTZ_APPLICATION_DEFINED NSEventTypeApplicationDefined
#endif
static void
got_fd_activity (void *info)
{
NSEvent *event;
/* Post a message so we'll break out of the message loop */
event = [NSEvent otherEventWithType: NSApplicationDefined
event = [NSEvent otherEventWithType: GDK_QUARTZ_APPLICATION_DEFINED
location: NSZeroPoint
modifierFlags: 0
timestamp: 0
......@@ -714,6 +720,12 @@ static GSourceFuncs event_funcs = {
********* Our Poll Function *********
************************************************************/
#if MAC_OS_X_VERSION_MIN_REQUIRED < 101200
#define GDK_QUARTZ_EVENT_MASK_ANY NSAnyEventMask
#else
#define GDK_QUARTZ_EVENT_MASK_ANY NSEventMaskAny
#endif
static gint
poll_func (GPollFD *ufds,
guint nfds,
......@@ -739,7 +751,7 @@ poll_func (GPollFD *ufds,
limit_date = [NSDate dateWithTimeIntervalSinceNow:timeout_/1000.0];
getting_events++;
event = [NSApp nextEventMatchingMask: NSAnyEventMask
event = [NSApp nextEventMatchingMask: GDK_QUARTZ_EVENT_MASK_ANY
untilDate: limit_date
inMode: NSDefaultRunLoopMode
dequeue: YES];
......@@ -758,7 +770,7 @@ poll_func (GPollFD *ufds,
n_ready = select_thread_collect_poll (ufds, nfds);
if (event &&
[event type] == NSApplicationDefined &&
[event type] == GDK_QUARTZ_APPLICATION_DEFINED &&
[event subtype] == GDK_QUARTZ_EVENT_SUBTYPE_EVENTLOOP)
{
/* Just used to wake us up; if an event and a FD arrived at the same
......
......@@ -35,6 +35,7 @@
#include "gdkquartzdisplay.h"
#include "gdkprivate-quartz.h"
#include "gdkquartzdevicemanager-core.h"
#include "gdkquartzkeys.h"
#define GRIP_WIDTH 15
#define GRIP_HEIGHT 15
......@@ -270,15 +271,15 @@ get_keyboard_modifiers_from_ns_flags (NSUInteger nsflags)
{
GdkModifierType modifiers = 0;
if (nsflags & NSAlphaShiftKeyMask)
if (nsflags & GDK_QUARTZ_ALPHA_SHIFT_KEY_MASK)
modifiers |= GDK_LOCK_MASK;
if (nsflags & NSShiftKeyMask)
if (nsflags & GDK_QUARTZ_SHIFT_KEY_MASK)
modifiers |= GDK_SHIFT_MASK;
if (nsflags & NSControlKeyMask)
if (nsflags & GDK_QUARTZ_CONTROL_KEY_MASK)
modifiers |= GDK_CONTROL_MASK;
if (nsflags & NSAlternateKeyMask)
if (nsflags & GDK_QUARTZ_ALTERNATE_KEY_MASK)
modifiers |= GDK_MOD1_MASK;
if (nsflags & NSCommandKeyMask)
if (nsflags & GDK_QUARTZ_COMMAND_KEY_MASK)
modifiers |= GDK_MOD2_MASK;
return modifiers;
......@@ -296,31 +297,31 @@ get_event_mask_from_ns_event (NSEvent *nsevent)
{
switch ([nsevent type])
{
case NSLeftMouseDown:
case NSRightMouseDown:
case NSOtherMouseDown:
case GDK_QUARTZ_LEFT_MOUSE_DOWN:
case GDK_QUARTZ_RIGHT_MOUSE_DOWN:
case GDK_QUARTZ_OTHER_MOUSE_DOWN:
return GDK_BUTTON_PRESS_MASK;
case NSLeftMouseUp:
case NSRightMouseUp:
case NSOtherMouseUp:
case GDK_QUARTZ_LEFT_MOUSE_UP:
case GDK_QUARTZ_RIGHT_MOUSE_UP:
case GDK_QUARTZ_OTHER_MOUSE_UP:
return GDK_BUTTON_RELEASE_MASK;
case NSMouseMoved:
case GDK_QUARTZ_MOUSE_MOVED:
return GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK;
case NSScrollWheel:
case GDK_QUARTZ_SCROLL_WHEEL:
/* 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.
*/
return GDK_SCROLL_MASK | GDK_BUTTON_PRESS_MASK;
case NSLeftMouseDragged:
case GDK_QUARTZ_LEFT_MOUSE_DRAGGED:
return (GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_MOTION_MASK | GDK_BUTTON1_MOTION_MASK |
GDK_BUTTON1_MASK);
case NSRightMouseDragged:
case GDK_QUARTZ_RIGHT_MOUSE_DRAGGED:
return (GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_MOTION_MASK | GDK_BUTTON3_MOTION_MASK |
GDK_BUTTON3_MASK);
case NSOtherMouseDragged:
case GDK_QUARTZ_OTHER_MOUSE_DRAGGED:
{
GdkEventMask mask;
......@@ -337,9 +338,9 @@ get_event_mask_from_ns_event (NSEvent *nsevent)
case NSEventTypeMagnify:
case NSEventTypeRotate:
return GDK_TOUCHPAD_GESTURE_MASK;
case NSKeyDown:
case NSKeyUp:
case NSFlagsChanged:
case GDK_QUARTZ_KEY_DOWN:
case GDK_QUARTZ_KEY_UP:
case GDK_QUARTZ_FLAGS_CHANGED:
{
switch (_gdk_quartz_keys_event_type (nsevent))
{
......@@ -355,10 +356,10 @@ get_event_mask_from_ns_event (NSEvent *nsevent)
}
break;
case NSMouseEntered:
case GDK_QUARTZ_MOUSE_ENTERED:
return GDK_ENTER_NOTIFY_MASK;
case NSMouseExited:
case GDK_QUARTZ_MOUSE_EXITED:
return GDK_LEAVE_NOTIFY_MASK;
default:
......@@ -393,9 +394,9 @@ is_mouse_button_press_event (NSEventType type)
{
switch (type)
{
case NSLeftMouseDown:
case NSRightMouseDown:
case NSOtherMouseDown:
case GDK_QUARTZ_LEFT_MOUSE_DOWN:
case GDK_QUARTZ_RIGHT_MOUSE_DOWN:
case GDK_QUARTZ_OTHER_MOUSE_DOWN:
return TRUE;
default:
return FALSE;
......@@ -755,7 +756,7 @@ find_toplevel_for_mouse_event (NSEvent *nsevent,
* gdk gets confused about getting e.g. button presses with no
* window (the title bar is not known to it).
*/
if (event_type != NSMouseMoved)
if (event_type != GDK_QUARTZ_MOUSE_MOVED)
if (*y < 0)
return NULL;
......@@ -810,23 +811,23 @@ find_window_for_ns_event (NSEvent *nsevent,
switch (event_type)
{
case NSLeftMouseDown:
case NSRightMouseDown:
case NSOtherMouseDown:
case NSLeftMouseUp:
case NSRightMouseUp:
case NSOtherMouseUp:
case NSMouseMoved:
case NSScrollWheel:
case NSLeftMouseDragged:
case NSRightMouseDragged:
case NSOtherMouseDragged:
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:
case NSEventTypeMagnify:
case NSEventTypeRotate:
return find_toplevel_for_mouse_event (nsevent, x, y);
case NSMouseEntered:
case NSMouseExited:
case GDK_QUARTZ_MOUSE_ENTERED:
case GDK_QUARTZ_MOUSE_EXITED:
/* Only handle our own entered/exited events, not the ones for the
* titlebar buttons.
*/
......@@ -835,9 +836,9 @@ find_window_for_ns_event (NSEvent *nsevent,
else
return NULL;
case NSKeyDown:
case NSKeyUp:
case NSFlagsChanged:
case GDK_QUARTZ_KEY_DOWN:
case GDK_QUARTZ_KEY_UP:
case GDK_QUARTZ_FLAGS_CHANGED:
return find_toplevel_for_keyboard_event (nsevent);
default:
......@@ -1008,16 +1009,16 @@ fill_button_event (GdkWindow *window,
switch ([nsevent type])
{
case NSLeftMouseDown:
case NSRightMouseDown:
case NSOtherMouseDown:
case GDK_QUARTZ_LEFT_MOUSE_DOWN:
case GDK_QUARTZ_RIGHT_MOUSE_DOWN:
case GDK_QUARTZ_OTHER_MOUSE_DOWN:
type = GDK_BUTTON_PRESS;
state &= ~get_mouse_button_modifiers_from_ns_event (nsevent);
break;
case NSLeftMouseUp:
case NSRightMouseUp:
case NSOtherMouseUp:
case GDK_QUARTZ_LEFT_MOUSE_UP:
case GDK_QUARTZ_RIGHT_MOUSE_UP:
case GDK_QUARTZ_OTHER_MOUSE_UP:
type = GDK_BUTTON_RELEASE;
state |= get_mouse_button_modifiers_from_ns_event (nsevent);
break;
......@@ -1119,7 +1120,7 @@ fill_key_event (GdkWindow *window,
event->key.state = get_keyboard_modifiers_from_ns_event (nsevent);
event->key.hardware_keycode = [nsevent keyCode];
gdk_event_set_scancode (event, [nsevent keyCode]);
event->key.group = ([nsevent modifierFlags] & NSAlternateKeyMask) ? 1 : 0;
event->key.group = ([nsevent modifierFlags] & GDK_QUARTZ_ALTERNATE_KEY_MASK) ? 1 : 0;
event->key.keyval = GDK_KEY_VoidSymbol;
gdk_event_set_device (event, gdk_seat_get_keyboard (seat));
......@@ -1239,7 +1240,7 @@ synthesize_crossing_event (GdkWindow *window,
{
switch ([nsevent type])
{
case NSMouseEntered:
case GDK_QUARTZ_MOUSE_ENTERED:
/* 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.
......@@ -1255,7 +1256,7 @@ synthesize_crossing_event (GdkWindow *window,
GDK_NOTIFY_NONLINEAR);
return TRUE;
case NSMouseExited:
case GDK_QUARTZ_MOUSE_EXITED:
/* See above */
if (!(window->event_mask & GDK_LEAVE_NOTIFY_MASK))
return FALSE;
......@@ -1342,12 +1343,12 @@ test_resize (NSEvent *event, GdkWindow *toplevel, gint x, gint y)
GdkWindowImplQuartz *toplevel_impl;
gboolean lion;
/* Resizing from the resize indicator only begins if an NSLeftMouseButton
/* Resizing from the resize indicator only begins if an GDK_QUARTZ_LEFT_MOUSE_BUTTON
* event is received in the resizing area.
*/
toplevel_impl = (GdkWindowImplQuartz *)toplevel->impl;
if ([toplevel_impl->toplevel showsResizeIndicator])
if ([event type] == NSLeftMouseDown &&
if ([event type] == GDK_QUARTZ_LEFT_MOUSE_DOWN &&
[toplevel_impl->toplevel showsResizeIndicator])
{
NSRect frame;
......@@ -1386,9 +1387,9 @@ test_resize (NSEvent *event, GdkWindow *toplevel, gint x, gint y)
*/
lion = gdk_quartz_osx_version () >= GDK_OSX_LION;
if (lion &&
([event type] == NSLeftMouseDown ||
[event type] == NSRightMouseDown ||
[event type] == NSOtherMouseDown))
([event type] == GDK_QUARTZ_LEFT_MOUSE_DOWN ||
[event type] == GDK_QUARTZ_RIGHT_MOUSE_DOWN ||
[event type] == GDK_QUARTZ_OTHER_MOUSE_DOWN))
{
if (x < GDK_LION_RESIZE ||
x > toplevel->width - GDK_LION_RESIZE ||
......@@ -1399,6 +1400,14 @@ test_resize (NSEvent *event, GdkWindow *toplevel, gint x, gint y)
return FALSE;
}
#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
static gboolean
gdk_event_translate (GdkEvent *event,
NSEvent *nsevent)
......@@ -1414,9 +1423,9 @@ gdk_event_translate (GdkEvent *event,
* grabs when the application loses focus (gets deactivated).
*/
event_type = [nsevent type];
if (event_type == NSAppKitDefined)
if (event_type == GDK_QUARTZ_APP_KIT_DEFINED)
{
if ([nsevent subtype] == NSApplicationDeactivatedEventType)
if ([nsevent subtype] == GDK_QUARTZ_APPLICATION_DEACTIVATED)
_gdk_quartz_events_break_all_grabs (get_time_from_ns_event (nsevent));
/* This could potentially be used to break grabs when clicking
......@@ -1452,7 +1461,7 @@ gdk_event_translate (GdkEvent *event,
{
GdkWindow *toplevel = NULL;
if (event_type == NSMouseMoved)
if (event_type == GDK_QUARTZ_MOUSE_MOVED)
{
/* Motion events received after clicking the menu bar do not have the
* window field set. Instead of giving up on the event immediately,
......@@ -1523,9 +1532,9 @@ gdk_event_translate (GdkEvent *event,
* native apps). If the app is active, we focus the window and then handle
* the event, also to match native apps.
*/
if ((event_type == NSRightMouseDown ||
event_type == NSOtherMouseDown ||
event_type == NSLeftMouseDown))
if ((event_type == GDK_QUARTZ_RIGHT_MOUSE_DOWN ||
event_type == GDK_QUARTZ_OTHER_MOUSE_DOWN ||
event_type == GDK_QUARTZ_LEFT_MOUSE_DOWN))
{
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
......@@ -1546,23 +1555,23 @@ gdk_event_translate (GdkEvent *event,
}
switch (event_type)
{
case NSLeftMouseDown:
case NSRightMouseDown:
case NSOtherMouseDown:
case NSLeftMouseUp:
case NSRightMouseUp:
case NSOtherMouseUp:
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:
fill_button_event (window, event, nsevent, x, y, x_root, y_root);
break;
case NSLeftMouseDragged:
case NSRightMouseDragged:
case NSOtherMouseDragged:
case NSMouseMoved:
case GDK_QUARTZ_LEFT_MOUSE_DRAGGED:
case GDK_QUARTZ_RIGHT_MOUSE_DRAGGED:
case GDK_QUARTZ_OTHER_MOUSE_DRAGGED:
case GDK_QUARTZ_MOUSE_MOVED:
fill_motion_event (window, event, nsevent, x, y, x_root, y_root);
break;
case NSScrollWheel:
case GDK_QUARTZ_SCROLL_WHEEL:
{
GdkScrollDirection direction;
float dx;
......@@ -1639,17 +1648,17 @@ gdk_event_translate (GdkEvent *event,
return_val = FALSE;
break;
#endif
case NSMouseExited:
case GDK_QUARTZ_MOUSE_EXITED:
if (WINDOW_IS_TOPLEVEL (window))
[[NSCursor arrowCursor] set];
/* fall through */
case NSMouseEntered:
case GDK_QUARTZ_MOUSE_ENTERED:
return_val = synthesize_crossing_event (window, event, nsevent, x, y, x_root, y_root);
break;
case NSKeyDown:
case NSKeyUp:
case NSFlagsChanged:
case GDK_QUARTZ_KEY_DOWN:
case GDK_QUARTZ_KEY_UP:
case GDK_QUARTZ_FLAGS_CHANGED:
{
GdkEventType type;
......
......@@ -124,15 +124,15 @@ const static struct {
guint keyval;
unsigned int modmask; /* So we can tell when a mod key is pressed/released */
} modifier_keys[] = {
{ 54, GDK_KEY_Meta_R, NSCommandKeyMask },
{ 55, GDK_KEY_Meta_L, NSCommandKeyMask },
{ 56, GDK_KEY_Shift_L, NSShiftKeyMask },
{ 57, GDK_KEY_Caps_Lock, NSAlphaShiftKeyMask },
{ 58, GDK_KEY_Alt_L, NSAlternateKeyMask },
{ 59, GDK_KEY_Control_L, NSControlKeyMask },
{ 60, GDK_KEY_Shift_R, NSShiftKeyMask },
{ 61, GDK_KEY_Alt_R, NSAlternateKeyMask },
{ 62, GDK_KEY_Control_R, NSControlKeyMask }
{ 54, GDK_KEY_Meta_R, GDK_QUARTZ_COMMAND_KEY_MASK },
{ 55, GDK_KEY_Meta_L, GDK_QUARTZ_COMMAND_KEY_MASK },
{ 56, GDK_KEY_Shift_L, GDK_QUARTZ_SHIFT_KEY_MASK },
{ 57, GDK_KEY_Caps_Lock, GDK_QUARTZ_ALPHA_SHIFT_KEY_MASK },
{ 58, GDK_KEY_Alt_L, GDK_QUARTZ_ALTERNATE_KEY_MASK },
{ 59, GDK_KEY_Control_L, GDK_QUARTZ_CONTROL_KEY_MASK },
{ 60, GDK_KEY_Shift_R, GDK_QUARTZ_SHIFT_KEY_MASK },
{ 61, GDK_KEY_Alt_R, GDK_QUARTZ_ALTERNATE_KEY_MASK },
{ 62, GDK_KEY_Control_R, GDK_QUARTZ_CONTROL_KEY_MASK }
};
const static struct {
......@@ -783,11 +783,11 @@ _gdk_quartz_keys_event_type (NSEvent *event)
switch ([event type])
{
case NSKeyDown:
case GDK_QUARTZ_KEY_DOWN:
return GDK_KEY_PRESS;
case NSKeyUp:
case GDK_QUARTZ_KEY_UP:
return GDK_KEY_RELEASE;
case NSFlagsChanged:
case GDK_QUARTZ_FLAGS_CHANGED:
break;
default:
g_assert_not_reached ();
......
......@@ -45,6 +45,79 @@ typedef struct _GdkQuartzKeymapClass GdkQuartzKeymapClass;
GDK_AVAILABLE_IN_ALL
GType gdk_quartz_keymap_get_type (void);
#if MAC_OS_X_VERSION_MIN_REQUIRED < 101200
typedef enum
{
GDK_QUARTZ_FLAGS_CHANGED = NSFlagsChanged,
GDK_QUARTZ_KEY_UP = NSKeyUp,
GDK_QUARTZ_KEY_DOWN = NSKeyDown,
GDK_QUARTZ_MOUSE_ENTERED = NSMouseEntered,
GDK_QUARTZ_MOUSE_EXITED = NSMouseExited,
GDK_QUARTZ_SCROLL_WHEEL = NSScrollWheel,
GDK_QUARTZ_MOUSE_MOVED = NSMouseMoved,
GDK_QUARTZ_OTHER_MOUSE_DRAGGED = NSOtherMouseDragged,
GDK_QUARTZ_RIGHT_MOUSE_DRAGGED = NSRightMouseDragged,
GDK_QUARTZ_LEFT_MOUSE_DRAGGED = NSLeftMouseDragged,
GDK_QUARTZ_OTHER_MOUSE_UP = NSOtherMouseUp,
GDK_QUARTZ_RIGHT_MOUSE_UP = NSRightMouseUp,
GDK_QUARTZ_LEFT_MOUSE_UP = NSLeftMouseUp,
GDK_QUARTZ_OTHER_MOUSE_DOWN = NSOtherMouseDown,
GDK_QUARTZ_RIGHT_MOUSE_DOWN = NSRightMouseDown,
GDK_QUARTZ_LEFT_MOUSE_DOWN = NSLeftMouseDown,
} GdkQuartzEventType;
typedef enum
{
GDK_QUARTZ_ALTERNATE_KEY_MASK = NSAlternateKeyMask,
GDK_QUARTZ_CONTROL_KEY_MASK = NSControlKeyMask,
GDK_QUARTZ_SHIFT_KEY_MASK = NSShiftKeyMask,
GDK_QUARTZ_ALPHA_SHIFT_KEY_MASK = NSAlphaShiftKeyMask,
GDK_QUARTZ_COMMAND_KEY_MASK = NSCommandKeyMask,
GDK_QUARTZ_ANY_EVENT_MASK = NSAnyEventMask,
} GdkQuartzEventModifierFlags;
typedef enum
{
GDK_QUARTZ_EVENT_MASK_ANY = NSAnyEventMask,
} GdkQuartzEventMask;
#else
typedef enum
{
GDK_QUARTZ_FLAGS_CHANGED = NSEventTypeFlagsChanged,
GDK_QUARTZ_KEY_UP = NSEventTypeKeyUp,
GDK_QUARTZ_KEY_DOWN = NSEventTypeKeyDown,
GDK_QUARTZ_MOUSE_ENTERED = NSEventTypeMouseEntered,
GDK_QUARTZ_MOUSE_EXITED = NSEventTypeMouseExited,
GDK_QUARTZ_SCROLL_WHEEL = NSEventTypeScrollWheel,
GDK_QUARTZ_MOUSE_MOVED = NSEventTypeMouseMoved,
GDK_QUARTZ_OTHER_MOUSE_DRAGGED = NSEventTypeOtherMouseDragged,
GDK_QUARTZ_RIGHT_MOUSE_DRAGGED = NSEventTypeRightMouseDragged,
GDK_QUARTZ_LEFT_MOUSE_DRAGGED = NSEventTypeLeftMouseDragged,
GDK_QUARTZ_OTHER_MOUSE_UP = NSEventTypeOtherMouseUp,
GDK_QUARTZ_RIGHT_MOUSE_UP = NSEventTypeRightMouseUp,
GDK_QUARTZ_LEFT_MOUSE_UP = NSEventTypeLeftMouseUp,
GDK_QUARTZ_OTHER_MOUSE_DOWN = NSEventTypeOtherMouseDown,
GDK_QUARTZ_RIGHT_MOUSE_DOWN = NSEventTypeRightMouseDown,
GDK_QUARTZ_LEFT_MOUSE_DOWN = NSEventTypeLeftMouseDown,
} GdkQuartzEventType;
typedef enum
{
GDK_QUARTZ_ALTERNATE_KEY_MASK = NSEventModifierFlagOption,
GDK_QUARTZ_CONTROL_KEY_MASK = NSEventModifierFlagControl,
GDK_QUARTZ_SHIFT_KEY_MASK = NSEventModifierFlagShift,
GDK_QUARTZ_ALPHA_SHIFT_KEY_MASK = NSEventModifierFlagCapsLock,
GDK_QUARTZ_COMMAND_KEY_MASK = NSEventModifierFlagCommand,
} GdkQuartzEventModifierFlags;
typedef enum
{
GDK_QUARTZ_EVENT_MASK_ANY = NSEventMaskAny,
} GdkQuartzEventMask;
#endif
G_END_DECLS
#endif /* __GDK_QUARTZ_KEYS_H__ */
......@@ -172,16 +172,28 @@ _gdk_quartz_display_text_property_to_utf8_list (GdkDisplay *display,
}
}
#if MAC_OS_X_VERSION_MIN_REQUIRED < 101400
#define GDK_QUARTZ_URL_PBOARD_TYPE NSURLPboardType
#define GDK_QUARTZ_COLOR_PBOARD_TYPE NSColorPboardType
#define GDK_QUARTZ_STRING_PBOARD_TYPE NSStringPboardType
#define GDK_QUARTZ_TIFF_PBOARD_TYPE NSTIFFPboardType
#else
#define GDK_QUARTZ_URL_PBOARD_TYPE NSPasteboardTypeURL
#define GDK_QUARTZ_COLOR_PBOARD_TYPE NSPasteboardTypeColor
#define GDK_QUARTZ_STRING_PBOARD_TYPE NSPasteboardTypeString
#define GDK_QUARTZ_TIFF_PBOARD_TYPE NSPasteboardTypeTIFF
#endif
GdkAtom
gdk_quartz_pasteboard_type_to_atom_libgtk_only (NSString *type)
{
if ([type isEqualToString:NSStringPboardType])
if ([type isEqualToString:GDK_QUARTZ_STRING_PBOARD_TYPE])
return gdk_atom_intern_static_string ("UTF8_STRING");
else if ([type isEqualToString:NSTIFFPboardType])
else if ([type isEqualToString:GDK_QUARTZ_TIFF_PBOARD_TYPE])
return gdk_atom_intern_static_string ("image/tiff");
else if ([type isEqualToString:NSColorPboardType])
else if ([type isEqualToString:GDK_QUARTZ_COLOR_PBOARD_TYPE])
return gdk_atom_intern_static_string ("application/x-color");
else if ([type isEqualToString:NSURLPboardType])
else if ([type isEqualToString:GDK_QUARTZ_URL_PBOARD_TYPE])
return gdk_atom_intern_static_string ("text/uri-list");
else
return gdk_atom_intern ([type UTF8String], FALSE);
......@@ -191,13 +203,13 @@ NSString *
gdk_quartz_target_to_pasteboard_type_libgtk_only (const char *target)
{
if (strcmp (target, "UTF8_STRING") == 0)
return NSStringPboardType;
return GDK_QUARTZ_STRING_PBOARD_TYPE;
else if (strcmp (target, "image/tiff") == 0)
return NSTIFFPboardType;
return GDK_QUARTZ_TIFF_PBOARD_TYPE;
else if (strcmp (target, "application/x-color") == 0)
return NSColorPboardType;
return GDK_QUARTZ_COLOR_PBOARD_TYPE;
else if (strcmp (target, "text/uri-list") == 0)
return NSURLPboardType;
return GDK_QUARTZ_URL_PBOARD_TYPE;
else
return [NSString stringWithUTF8String:target];
}
......
......@@ -52,6 +52,27 @@ typedef struct
GdkWMDecoration decor;
} FullscreenSavedGeometry;
#if MAC_OS_X_VERSION_MIN_REQUIRED < 101200
typedef enum
{
GDK_QUARTZ_BORDERLESS_WINDOW = NSBorderlessWindowMask,
GDK_QUARTZ_CLOSABLE_WINDOW = NSClosableWindowMask,
GDK_QUARTZ_FULLSCREEN_WINDOW = NSFullScreenWindowMask,
GDK_QUARTZ_MINIATURIZABLE_WINDOW = NSMiniaturizableWindowMask,
GDK_QUARTZ_RESIZABLE_WINDOW = NSResizableWindowMask,
GDK_QUARTZ_TITLED_WINDOW = NSTitledWindowMask,
} GdkQuartzWindowMask;
#else
typedef enum
{
GDK_QUARTZ_BORDERLESS_WINDOW = NSWindowStyleMaskBorderless,
GDK_QUARTZ_CLOSABLE_WINDOW = NSWindowStyleMaskClosable,
GDK_QUARTZ_FULLSCREEN_WINDOW = NSWindowStyleMaskFullScreen,
GDK_QUARTZ_MINIATURIZABLE_WINDOW = NSWindowStyleMaskMiniaturizable,
GDK_QUARTZ_RESIZABLE_WINDOW = NSWindowStyleMaskResizable,
GDK_QUARTZ_TITLED_WINDOW = NSWindowStyleMaskTitled,
} GdkQuartzWindowMask;
#endif
#ifndef AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
static FullscreenSavedGeometry *get_fullscreen_geometry (GdkWindow *window);
......@@ -509,7 +530,11 @@ _gdk_quartz_window_debug_highlight (GdkWindow *window, gint number)
[debug_window[number] close];
debug_window[number] = [[NSWindow alloc] initWithContentRect:rect
styleMask:NSBorderlessWindowMask
#if MAC_OS_X_VERSION_MIN_REQUIRED < 101200
styleMask:(NSUInteger)GDK_QUARTZ_BORDERLESS_WINDOW
#else
styleMask:(NSWindowStyleMask)GDK_QUARTZ_BORDERLESS_WINDOW
#endif
backing:NSBackingStoreBuffered
defer:NO];
......@@ -836,14 +861,14 @@ _gdk_quartz_display_create_window_impl (GdkDisplay *display,
((attributes_mask & GDK_WA_TYPE_HINT) &&
attributes->type_hint == GDK_WINDOW_TYPE_HINT_SPLASHSCREEN))
{
style_mask = NSBorderlessWindowMask;
style_mask = GDK_QUARTZ_BORDERLESS_WINDOW;
}
else
{
style_mask = (NSTitledWindowMask |
NSClosableWindowMask |
NSMiniaturizableWindowMask |
NSResizableWindowMask);
style_mask = (GDK_QUARTZ_TITLED_WINDOW |
GDK_QUARTZ_CLOSABLE_WINDOW |
GDK_QUARTZ_MINIATURIZABLE_WINDOW |
GDK_QUARTZ_RESIZABLE_WINDOW);
}
impl->toplevel = [[GdkQuartzNSWindow alloc] initWithContentRect:content_rect
......@@ -1583,7 +1608,7 @@ gdk_window_quartz_get_geometry (GdkWindow *window,
* windows with borders and the root relative coordinates
* otherwise.
*/
if ([impl->toplevel styleMask] == NSBorderlessWindowMask)
if ([impl->toplevel styleMask] == GDK_QUARTZ_BORDERLESS_WINDOW)
{
_gdk_quartz_window_xy_to_gdk_xy (ns_rect.origin.x,
ns_rect.origin.y + ns_rect.size.height,
......@@ -2310,13 +2335,14 @@ gdk_quartz_window_set_decorations (GdkWindow *window,
if (decorations == 0 || GDK_WINDOW_TYPE (window) == GDK_WINDOW_TEMP ||
impl->type_hint == GDK_WINDOW_TYPE_HINT_SPLASHSCREEN )
{
new_mask = NSBorderlessWindowMask;
new_mask = GDK_QUARTZ_BORDERLESS_WINDOW;
}
else
{
/* FIXME: Honor other GDK_DECOR_* flags. */
new_mask = (NSTitledWindowMask | NSClosableWindowMask |
NSMiniaturizableWindowMask | NSResizableWindowMask);
new_mask = (GDK_QUARTZ_TITLED_WINDOW | GDK_QUARTZ_CLOSABLE_WINDOW |
GDK_QUARTZ_MINIATURIZABLE_WINDOW |
GDK_QUARTZ_RESIZABLE_WINDOW);
}
GDK_QUARTZ_ALLOC_POOL;
......@@ -2334,14 +2360,14 @@ gdk_quartz_window_set_decorations (GdkWindow *window,
/* Properly update the size of the window when the titlebar is
* added or removed.
*/
if (old_mask == NSBorderlessWindowMask &&
new_mask != NSBorderlessWindowMask)
if (old_mask == GDK_QUARTZ_BORDERLESS_WINDOW &&
new_mask != GDK_QUARTZ_BORDERLESS_WINDOW)
{
rect = [NSWindow frameRectForContentRect:rect styleMask:new_mask];
}
else if (old_mask != NSBorderlessWindowMask &&
new_mask == NSBorderlessWindowMask)
else if (old_mask != GDK_QUARTZ_BORDERLESS_WINDOW &&
new_mask == GDK_QUARTZ_BORDERLESS_WINDOW)
{
rect = [NSWindow contentRectForFrameRect:rect styleMask:old_mask];
}
......@@ -2357,13 +2383,14 @@ gdk_quartz_window_set_decorations (GdkWindow *window,
[(id<CanSetStyleMask>)impl->toplevel setStyleMask:new_mask];
/* It appears that unsetting and then resetting NSTitledWindowMask
* does not reset the title in the title bar as might be expected.
/* It appears that unsetting and then resetting
* GDK_QUARTZ_TITLED_WINDOW does not reset the title in the
* title bar as might be expected.
*
* In theory we only need to set this if new_mask includes
* NSTitledWindowMask. This behaved extremely oddly when
* GDK_QUARTZ_TITLED_WINDOW. This behaved extremely oddly when