mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-28 22:41:43 +00:00
Merge branch 'wip/chergert/gdk-macos-fixes' into 'master'
various build fixes for GDK/GTK on macos See merge request GNOME/gtk!2680
This commit is contained in:
commit
035e303f83
@ -30,19 +30,6 @@
|
||||
#include "gdkmacosdisplay-private.h"
|
||||
#include "gdkmacossurface-private.h"
|
||||
|
||||
/* Text Input Client */
|
||||
#define TIC_MARKED_TEXT "tic-marked-text"
|
||||
#define TIC_SELECTED_POS "tic-selected-pos"
|
||||
#define TIC_SELECTED_LEN "tic-selected-len"
|
||||
#define TIC_INSERT_TEXT "tic-insert-text"
|
||||
#define TIC_IN_KEY_DOWN "tic-in-key-down"
|
||||
|
||||
/* GtkIMContext */
|
||||
#define GIC_CURSOR_RECT "gic-cursor-rect"
|
||||
#define GIC_FILTER_KEY "gic-filter-key"
|
||||
#define GIC_FILTER_PASSTHRU 0
|
||||
#define GIC_FILTER_FILTERED 1
|
||||
|
||||
@implementation GdkMacosBaseView
|
||||
|
||||
-(id)initWithFrame:(NSRect)frameRect
|
||||
|
@ -28,6 +28,7 @@
|
||||
#import "GdkMacosWindow.h"
|
||||
|
||||
#include "gdkmacosdisplay-private.h"
|
||||
#include "gdkmacosmonitor-private.h"
|
||||
#include "gdkmacossurface-private.h"
|
||||
#include "gdkmacospopupsurface-private.h"
|
||||
#include "gdkmacostoplevelsurface-private.h"
|
||||
@ -352,7 +353,7 @@
|
||||
monitor = _gdk_macos_display_get_monitor_at_display_coords ([self gdkDisplay],
|
||||
currentLocation.x,
|
||||
currentLocation.y);
|
||||
gdk_macos_monitor_get_geometry (monitor, &geometry);
|
||||
gdk_monitor_get_geometry (monitor, &geometry);
|
||||
gdk_macos_monitor_get_workarea (monitor, &workarea);
|
||||
_edge_snapping_set_monitor (&self->snapping, &geometry, &workarea);
|
||||
|
||||
|
@ -28,8 +28,9 @@
|
||||
|
||||
#include "gdkmacoscursor-private.h"
|
||||
#include "gdkmacosdevice.h"
|
||||
#include "gdkmacosdisplay-private.h"
|
||||
#include "gdkmacosdevice-private.h"
|
||||
#include "gdkmacosdisplay-private.h"
|
||||
#include "gdkmacossurface-private.h"
|
||||
|
||||
struct _GdkMacosDevice
|
||||
{
|
||||
|
@ -30,6 +30,19 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* Text Input Client */
|
||||
#define TIC_MARKED_TEXT "tic-marked-text"
|
||||
#define TIC_SELECTED_POS "tic-selected-pos"
|
||||
#define TIC_SELECTED_LEN "tic-selected-len"
|
||||
#define TIC_INSERT_TEXT "tic-insert-text"
|
||||
#define TIC_IN_KEY_DOWN "tic-in-key-down"
|
||||
|
||||
/* GtkIMContext */
|
||||
#define GIC_CURSOR_RECT "gic-cursor-rect"
|
||||
#define GIC_FILTER_KEY "gic-filter-key"
|
||||
#define GIC_FILTER_PASSTHRU 0
|
||||
#define GIC_FILTER_FILTERED 1
|
||||
|
||||
struct _GdkMacosDisplay
|
||||
{
|
||||
GdkDisplay parent_instance;
|
||||
@ -148,6 +161,7 @@ void _gdk_macos_display_send_button_event (GdkMacosDisp
|
||||
void _gdk_macos_display_warp_pointer (GdkMacosDisplay *self,
|
||||
int x,
|
||||
int y);
|
||||
NSEvent *_gdk_macos_display_get_nsevent (GdkEvent *event);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -242,7 +242,6 @@ fill_button_event (GdkMacosDisplay *display,
|
||||
GDK_SURFACE (surface),
|
||||
gdk_seat_get_pointer (seat),
|
||||
NULL,
|
||||
NULL,
|
||||
get_time_from_ns_event (nsevent),
|
||||
state,
|
||||
get_mouse_button_from_ns_event (nsevent),
|
||||
@ -283,7 +282,6 @@ synthesize_crossing_event (GdkMacosDisplay *display,
|
||||
return gdk_crossing_event_new (event_type,
|
||||
GDK_SURFACE (surface),
|
||||
gdk_seat_get_pointer (seat),
|
||||
NULL,
|
||||
get_time_from_ns_event (nsevent),
|
||||
state,
|
||||
x,
|
||||
@ -410,7 +408,6 @@ fill_key_event (GdkMacosDisplay *display,
|
||||
return gdk_key_event_new (type,
|
||||
GDK_SURFACE (surface),
|
||||
gdk_seat_get_keyboard (seat),
|
||||
NULL,
|
||||
get_time_from_ns_event (nsevent),
|
||||
[nsevent keyCode],
|
||||
state,
|
||||
@ -526,7 +523,6 @@ fill_pinch_event (GdkMacosDisplay *display,
|
||||
|
||||
return gdk_touchpad_event_new_pinch (GDK_SURFACE (surface),
|
||||
gdk_seat_get_pointer (seat),
|
||||
NULL,
|
||||
get_time_from_ns_event (nsevent),
|
||||
get_keyboard_modifiers_from_ns_event (nsevent),
|
||||
phase,
|
||||
@ -570,7 +566,6 @@ fill_motion_event (GdkMacosDisplay *display,
|
||||
return gdk_motion_event_new (GDK_SURFACE (surface),
|
||||
gdk_seat_get_pointer (seat),
|
||||
NULL,
|
||||
NULL,
|
||||
get_time_from_ns_event (nsevent),
|
||||
state,
|
||||
x,
|
||||
@ -609,21 +604,13 @@ fill_scroll_event (GdkMacosDisplay *self,
|
||||
double sx;
|
||||
double sy;
|
||||
|
||||
/*
|
||||
* TODO: We probably need another event type for the
|
||||
* high precision scroll events since sx and dy
|
||||
* are in a unit we don't quite support. For now,
|
||||
* to slow it down multiply by .1.
|
||||
*/
|
||||
|
||||
sx = [nsevent scrollingDeltaX] * .1;
|
||||
sy = [nsevent scrollingDeltaY] * .1;
|
||||
sx = [nsevent scrollingDeltaX];
|
||||
sy = [nsevent scrollingDeltaY];
|
||||
|
||||
if (sx != 0.0 || dx != 0.0)
|
||||
ret = gdk_scroll_event_new (GDK_SURFACE (surface),
|
||||
pointer,
|
||||
NULL,
|
||||
NULL,
|
||||
get_time_from_ns_event (nsevent),
|
||||
state,
|
||||
-sx,
|
||||
@ -661,7 +648,6 @@ fill_scroll_event (GdkMacosDisplay *self,
|
||||
emulated = gdk_scroll_event_new_discrete (GDK_SURFACE (surface),
|
||||
pointer,
|
||||
NULL,
|
||||
NULL,
|
||||
get_time_from_ns_event (nsevent),
|
||||
state,
|
||||
direction,
|
||||
@ -675,7 +661,6 @@ fill_scroll_event (GdkMacosDisplay *self,
|
||||
ret = gdk_scroll_event_new (GDK_SURFACE (surface),
|
||||
pointer,
|
||||
NULL,
|
||||
NULL,
|
||||
get_time_from_ns_event (nsevent),
|
||||
state,
|
||||
dx,
|
||||
@ -1188,7 +1173,6 @@ _gdk_macos_display_synthesize_motion (GdkMacosDisplay *self,
|
||||
event = gdk_motion_event_new (GDK_SURFACE (surface),
|
||||
gdk_seat_get_pointer (seat),
|
||||
NULL,
|
||||
NULL,
|
||||
get_time_from_ns_event ([NSApp currentEvent]),
|
||||
state,
|
||||
x,
|
||||
|
@ -74,7 +74,17 @@
|
||||
|
||||
G_DEFINE_TYPE (GdkMacosDisplay, gdk_macos_display, GDK_TYPE_DISPLAY)
|
||||
|
||||
#define EVENT_MAP_MAX_SIZE 10
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GList link;
|
||||
GdkEvent *gdk_event;
|
||||
NSEvent *nsevent;
|
||||
} GdkToNSEventMap;
|
||||
|
||||
static GSource *event_source;
|
||||
static GQueue event_map = G_QUEUE_INIT;
|
||||
|
||||
static GdkMacosMonitor *
|
||||
get_monitor (GdkMacosDisplay *self,
|
||||
@ -387,6 +397,28 @@ gdk_macos_display_notify_startup_complete (GdkDisplay *display,
|
||||
/* Not Supported */
|
||||
}
|
||||
|
||||
static void
|
||||
push_nsevent (GdkEvent *gdk_event,
|
||||
NSEvent *nsevent)
|
||||
{
|
||||
GdkToNSEventMap *map = g_slice_new0 (GdkToNSEventMap);
|
||||
|
||||
map->link.data = map;
|
||||
map->gdk_event = gdk_event_ref (gdk_event);
|
||||
map->nsevent = g_steal_pointer (&nsevent);
|
||||
|
||||
g_queue_push_tail_link (&event_map, &map->link);
|
||||
|
||||
if (event_map.length > EVENT_MAP_MAX_SIZE)
|
||||
{
|
||||
map = g_queue_pop_head_link (&event_map)->data;
|
||||
|
||||
gdk_event_unref (map->gdk_event);
|
||||
[map->nsevent release];
|
||||
g_slice_free (GdkToNSEventMap, map);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_macos_display_queue_events (GdkDisplay *display)
|
||||
{
|
||||
@ -400,14 +432,18 @@ gdk_macos_display_queue_events (GdkDisplay *display)
|
||||
GdkEvent *event = _gdk_macos_display_translate (self, nsevent);
|
||||
|
||||
if (event != NULL)
|
||||
_gdk_windowing_got_event (GDK_DISPLAY (self),
|
||||
_gdk_event_queue_append (GDK_DISPLAY (self), event),
|
||||
event,
|
||||
0);
|
||||
{
|
||||
push_nsevent (event, nsevent);
|
||||
_gdk_windowing_got_event (GDK_DISPLAY (self),
|
||||
_gdk_event_queue_append (GDK_DISPLAY (self), event),
|
||||
event,
|
||||
0);
|
||||
}
|
||||
else
|
||||
[NSApp sendEvent:nsevent];
|
||||
|
||||
[nsevent release];
|
||||
{
|
||||
[NSApp sendEvent:nsevent];
|
||||
[nsevent release];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -467,7 +503,7 @@ _gdk_macos_display_surface_became_key (GdkMacosDisplay *self,
|
||||
|
||||
seat = gdk_display_get_default_seat (GDK_DISPLAY (self));
|
||||
keyboard = gdk_seat_get_keyboard (seat);
|
||||
event = gdk_focus_event_new (GDK_SURFACE (surface), keyboard, NULL, TRUE);
|
||||
event = gdk_focus_event_new (GDK_SURFACE (surface), keyboard, TRUE);
|
||||
_gdk_event_queue_append (GDK_DISPLAY (self), event);
|
||||
|
||||
/* We just became the active window. Unlike X11, Mac OS X does
|
||||
@ -493,7 +529,7 @@ _gdk_macos_display_surface_resigned_key (GdkMacosDisplay *self,
|
||||
|
||||
seat = gdk_display_get_default_seat (GDK_DISPLAY (self));
|
||||
keyboard = gdk_seat_get_keyboard (seat);
|
||||
event = gdk_focus_event_new (GDK_SURFACE (surface), keyboard, NULL, FALSE);
|
||||
event = gdk_focus_event_new (GDK_SURFACE (surface), keyboard, FALSE);
|
||||
_gdk_event_queue_append (GDK_DISPLAY (self), event);
|
||||
}
|
||||
|
||||
@ -861,7 +897,6 @@ _gdk_macos_display_break_all_grabs (GdkMacosDisplay *self,
|
||||
|
||||
event = gdk_grab_broken_event_new (grab->surface,
|
||||
device,
|
||||
NULL,
|
||||
grab->surface,
|
||||
TRUE);
|
||||
node = _gdk_event_queue_append (GDK_DISPLAY (self), event);
|
||||
@ -1069,3 +1104,17 @@ _gdk_macos_display_warp_pointer (GdkMacosDisplay *self,
|
||||
|
||||
CGWarpMouseCursorPosition ((CGPoint) { x, y });
|
||||
}
|
||||
|
||||
NSEvent *
|
||||
_gdk_macos_display_get_nsevent (GdkEvent *event)
|
||||
{
|
||||
for (const GList *iter = event_map.head; iter; iter = iter->next)
|
||||
{
|
||||
const GdkToNSEventMap *map = iter->data;
|
||||
|
||||
if (map->gdk_event == event)
|
||||
return map->nsevent;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ G_BEGIN_DECLS
|
||||
GdkMacosKeymap *_gdk_macos_keymap_new (GdkMacosDisplay *display);
|
||||
GdkEventType _gdk_macos_keymap_get_event_type (NSEvent *event);
|
||||
gboolean _gdk_macos_keymap_is_modifier (guint keycode);
|
||||
gunichar _gdk_macos_keymap_get_equivalent (guint key);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -696,3 +696,150 @@ _gdk_macos_keymap_is_modifier (guint keycode)
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Code for key code conversion
|
||||
*
|
||||
* Copyright (C) 2009 Paul Davis
|
||||
*/
|
||||
gunichar
|
||||
_gdk_macos_keymap_get_equivalent (guint key)
|
||||
{
|
||||
if (key >= GDK_KEY_A && key <= GDK_KEY_Z)
|
||||
return key + (GDK_KEY_a - GDK_KEY_A);
|
||||
|
||||
if (key >= GDK_KEY_space && key <= GDK_KEY_asciitilde)
|
||||
return key;
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case GDK_KEY_BackSpace:
|
||||
return NSBackspaceCharacter;
|
||||
case GDK_KEY_Delete:
|
||||
return NSDeleteFunctionKey;
|
||||
case GDK_KEY_Pause:
|
||||
return NSPauseFunctionKey;
|
||||
case GDK_KEY_Scroll_Lock:
|
||||
return NSScrollLockFunctionKey;
|
||||
case GDK_KEY_Sys_Req:
|
||||
return NSSysReqFunctionKey;
|
||||
case GDK_KEY_Home:
|
||||
return NSHomeFunctionKey;
|
||||
case GDK_KEY_Left:
|
||||
case GDK_KEY_leftarrow:
|
||||
return NSLeftArrowFunctionKey;
|
||||
case GDK_KEY_Up:
|
||||
case GDK_KEY_uparrow:
|
||||
return NSUpArrowFunctionKey;
|
||||
case GDK_KEY_Right:
|
||||
case GDK_KEY_rightarrow:
|
||||
return NSRightArrowFunctionKey;
|
||||
case GDK_KEY_Down:
|
||||
case GDK_KEY_downarrow:
|
||||
return NSDownArrowFunctionKey;
|
||||
case GDK_KEY_Page_Up:
|
||||
return NSPageUpFunctionKey;
|
||||
case GDK_KEY_Page_Down:
|
||||
return NSPageDownFunctionKey;
|
||||
case GDK_KEY_End:
|
||||
return NSEndFunctionKey;
|
||||
case GDK_KEY_Begin:
|
||||
return NSBeginFunctionKey;
|
||||
case GDK_KEY_Select:
|
||||
return NSSelectFunctionKey;
|
||||
case GDK_KEY_Print:
|
||||
return NSPrintFunctionKey;
|
||||
case GDK_KEY_Execute:
|
||||
return NSExecuteFunctionKey;
|
||||
case GDK_KEY_Insert:
|
||||
return NSInsertFunctionKey;
|
||||
case GDK_KEY_Undo:
|
||||
return NSUndoFunctionKey;
|
||||
case GDK_KEY_Redo:
|
||||
return NSRedoFunctionKey;
|
||||
case GDK_KEY_Menu:
|
||||
return NSMenuFunctionKey;
|
||||
case GDK_KEY_Find:
|
||||
return NSFindFunctionKey;
|
||||
case GDK_KEY_Help:
|
||||
return NSHelpFunctionKey;
|
||||
case GDK_KEY_Break:
|
||||
return NSBreakFunctionKey;
|
||||
case GDK_KEY_Mode_switch:
|
||||
return NSModeSwitchFunctionKey;
|
||||
case GDK_KEY_F1:
|
||||
return NSF1FunctionKey;
|
||||
case GDK_KEY_F2:
|
||||
return NSF2FunctionKey;
|
||||
case GDK_KEY_F3:
|
||||
return NSF3FunctionKey;
|
||||
case GDK_KEY_F4:
|
||||
return NSF4FunctionKey;
|
||||
case GDK_KEY_F5:
|
||||
return NSF5FunctionKey;
|
||||
case GDK_KEY_F6:
|
||||
return NSF6FunctionKey;
|
||||
case GDK_KEY_F7:
|
||||
return NSF7FunctionKey;
|
||||
case GDK_KEY_F8:
|
||||
return NSF8FunctionKey;
|
||||
case GDK_KEY_F9:
|
||||
return NSF9FunctionKey;
|
||||
case GDK_KEY_F10:
|
||||
return NSF10FunctionKey;
|
||||
case GDK_KEY_F11:
|
||||
return NSF11FunctionKey;
|
||||
case GDK_KEY_F12:
|
||||
return NSF12FunctionKey;
|
||||
case GDK_KEY_F13:
|
||||
return NSF13FunctionKey;
|
||||
case GDK_KEY_F14:
|
||||
return NSF14FunctionKey;
|
||||
case GDK_KEY_F15:
|
||||
return NSF15FunctionKey;
|
||||
case GDK_KEY_F16:
|
||||
return NSF16FunctionKey;
|
||||
case GDK_KEY_F17:
|
||||
return NSF17FunctionKey;
|
||||
case GDK_KEY_F18:
|
||||
return NSF18FunctionKey;
|
||||
case GDK_KEY_F19:
|
||||
return NSF19FunctionKey;
|
||||
case GDK_KEY_F20:
|
||||
return NSF20FunctionKey;
|
||||
case GDK_KEY_F21:
|
||||
return NSF21FunctionKey;
|
||||
case GDK_KEY_F22:
|
||||
return NSF22FunctionKey;
|
||||
case GDK_KEY_F23:
|
||||
return NSF23FunctionKey;
|
||||
case GDK_KEY_F24:
|
||||
return NSF24FunctionKey;
|
||||
case GDK_KEY_F25:
|
||||
return NSF25FunctionKey;
|
||||
case GDK_KEY_F26:
|
||||
return NSF26FunctionKey;
|
||||
case GDK_KEY_F27:
|
||||
return NSF27FunctionKey;
|
||||
case GDK_KEY_F28:
|
||||
return NSF28FunctionKey;
|
||||
case GDK_KEY_F29:
|
||||
return NSF29FunctionKey;
|
||||
case GDK_KEY_F30:
|
||||
return NSF30FunctionKey;
|
||||
case GDK_KEY_F31:
|
||||
return NSF31FunctionKey;
|
||||
case GDK_KEY_F32:
|
||||
return NSF32FunctionKey;
|
||||
case GDK_KEY_F33:
|
||||
return NSF33FunctionKey;
|
||||
case GDK_KEY_F34:
|
||||
return NSF34FunctionKey;
|
||||
case GDK_KEY_F35:
|
||||
return NSF35FunctionKey;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return '\0';
|
||||
}
|
||||
|
@ -36,10 +36,13 @@ typedef struct _GdkMacosMonitorClass GdkMacosMonitorClass;
|
||||
#define GDK_IS_MACOS_MONITOR(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_MACOS_MONITOR))
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gdk_macos_monitor_get_type (void);
|
||||
|
||||
void gdk_macos_monitor_get_workarea (GdkMonitor *monitor,
|
||||
GdkRectangle *geometry);
|
||||
GType gdk_macos_monitor_get_type (void);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_macos_monitor_get_geometry (GdkMonitor *self,
|
||||
GdkRectangle *geometry);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_macos_monitor_get_workarea (GdkMonitor *self,
|
||||
GdkRectangle *geometry);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "gdkpopupprivate.h"
|
||||
|
||||
#include "gdkmacosdisplay-private.h"
|
||||
#include "gdkmacosmonitor.h"
|
||||
#include "gdkmacospopupsurface-private.h"
|
||||
#include "gdkmacosutils-private.h"
|
||||
|
||||
@ -60,7 +61,7 @@ gdk_macos_popup_surface_layout (GdkMacosPopupSurface *self,
|
||||
self->layout = gdk_popup_layout_ref (layout);
|
||||
}
|
||||
|
||||
monitor = gdk_surface_get_layout_monitor (surface, layout,
|
||||
monitor = gdk_surface_get_layout_monitor (GDK_SURFACE (self), layout,
|
||||
gdk_macos_monitor_get_workarea);
|
||||
gdk_macos_monitor_get_workarea (monitor, &bounds);
|
||||
|
||||
|
@ -84,7 +84,7 @@ _gdk_macos_surface_reposition_children (GdkMacosSurface *self)
|
||||
_gdk_macos_popup_surface_reposition (GDK_MACOS_POPUP_SURFACE (child));
|
||||
}
|
||||
|
||||
if (GDK_IS_POPUP (self) || self->did_initial_present)
|
||||
if (GDK_IS_POPUP (self))
|
||||
g_signal_emit_by_name (self, "popup-layout-changed");
|
||||
}
|
||||
|
||||
@ -820,7 +820,6 @@ _gdk_macos_surface_synthesize_null_key (GdkMacosSurface *self)
|
||||
event = gdk_key_event_new (GDK_KEY_PRESS,
|
||||
GDK_SURFACE (self),
|
||||
gdk_seat_get_keyboard (seat),
|
||||
NULL,
|
||||
GDK_CURRENT_TIME,
|
||||
0,
|
||||
0,
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "gdktoplevelprivate.h"
|
||||
|
||||
#include "gdkmacosdisplay-private.h"
|
||||
#include "gdkmacosmonitor-private.h"
|
||||
#include "gdkmacostoplevelsurface-private.h"
|
||||
#include "gdkmacosutils-private.h"
|
||||
|
||||
@ -95,6 +96,7 @@ static gboolean
|
||||
_gdk_macos_toplevel_surface_present (GdkToplevel *toplevel,
|
||||
GdkToplevelLayout *layout)
|
||||
{
|
||||
GdkSurface *surface = GDK_SURFACE (toplevel);
|
||||
GdkMacosToplevelSurface *self = (GdkMacosToplevelSurface *)toplevel;
|
||||
NSWindow *nswindow = _gdk_macos_surface_get_native (GDK_MACOS_SURFACE (self));
|
||||
GdkDisplay *display = gdk_surface_get_display (surface);
|
||||
@ -190,10 +192,11 @@ _gdk_macos_toplevel_surface_present (GdkToplevel *toplevel,
|
||||
(GDK_MACOS_SURFACE (self)->shadow_left ||
|
||||
GDK_MACOS_SURFACE (self)->shadow_top))
|
||||
{
|
||||
GdkMonitor *monitor = _gdk_macos_surface_get_best_monitor (GDK_MACOS_SURFACE (self));
|
||||
int x = GDK_SURFACE (self)->x;
|
||||
int y = GDK_SURFACE (self)->y;
|
||||
|
||||
monitor = _gdk_macos_surface_get_best_monitor (GDK_MACOS_SURFACE (self));
|
||||
|
||||
if (monitor != NULL)
|
||||
{
|
||||
GdkRectangle visible;
|
||||
|
@ -43,6 +43,7 @@ gdk_macos_frameworks = [
|
||||
'Carbon',
|
||||
'CoreVideo',
|
||||
'CoreServices',
|
||||
'Foundation',
|
||||
'OpenGL',
|
||||
'QuartzCore',
|
||||
]
|
||||
|
@ -227,7 +227,7 @@ libgdk_c_args = [
|
||||
|
||||
gdk_backends = []
|
||||
gdk_backends_gen_headers = [] # non-public generated headers
|
||||
foreach backend : ['broadway', 'quartz', 'wayland', 'win32', 'x11', 'macos']
|
||||
foreach backend : ['broadway', 'wayland', 'win32', 'x11', 'macos']
|
||||
if get_variable('@0@_enabled'.format(backend))
|
||||
subdir(backend)
|
||||
gdk_deps += get_variable('gdk_@0@_deps'.format(backend))
|
||||
|
@ -72,7 +72,7 @@ for f in funcs:
|
||||
file_output += ['*tp++ = {0}();'.format(f)]
|
||||
file_output += ['#endif']
|
||||
elif f.startswith('gdk_quartz'):
|
||||
file_output += ['#ifdef GDK_WINDOWING_QUARTZ']
|
||||
file_output += ['#ifdef GDK_WINDOWING_MACOS']
|
||||
file_output += ['*tp++ = {0}();'.format(f)]
|
||||
file_output += ['#endif']
|
||||
elif f.startswith('gsk_vulkan'):
|
||||
|
@ -706,7 +706,7 @@ static gboolean
|
||||
append_keyval_symbol (guint accelerator_key,
|
||||
GString *gstring)
|
||||
{
|
||||
#ifdef GDK_WINDOWING_QUARTZ
|
||||
#ifdef GDK_WINDOWING_MACOS
|
||||
switch (accelerator_key)
|
||||
{
|
||||
case GDK_KEY_Return:
|
||||
@ -777,7 +777,7 @@ append_keyval_symbol (guint accelerator_key,
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
#else /* !GDK_WINDOWING_QUARTZ */
|
||||
#else /* !GDK_WINDOWING_MACOS */
|
||||
return FALSE;
|
||||
#endif
|
||||
}
|
||||
@ -785,7 +785,7 @@ append_keyval_symbol (guint accelerator_key,
|
||||
static void
|
||||
append_separator (GString *string)
|
||||
{
|
||||
#ifndef GDK_WINDOWING_QUARTZ
|
||||
#ifndef GDK_WINDOWING_MACOS
|
||||
g_string_append (string, "+");
|
||||
#else
|
||||
/* no separator on quartz */
|
||||
@ -825,7 +825,7 @@ gtk_accelerator_print_label (GString *gstring,
|
||||
|
||||
if (accelerator_mods & GDK_SHIFT_MASK)
|
||||
{
|
||||
#ifndef GDK_WINDOWING_QUARTZ
|
||||
#ifndef GDK_WINDOWING_MACOS
|
||||
/* This is the text that should appear next to menu accelerators
|
||||
* that use the shift key. If the text on this key isn't typically
|
||||
* translated on keyboards used for your language, don't translate
|
||||
@ -844,7 +844,7 @@ gtk_accelerator_print_label (GString *gstring,
|
||||
if (seen_mod)
|
||||
append_separator (gstring);
|
||||
|
||||
#ifndef GDK_WINDOWING_QUARTZ
|
||||
#ifndef GDK_WINDOWING_MACOS
|
||||
/* This is the text that should appear next to menu accelerators
|
||||
* that use the control key. If the text on this key isn't typically
|
||||
* translated on keyboards used for your language, don't translate
|
||||
@ -863,7 +863,7 @@ gtk_accelerator_print_label (GString *gstring,
|
||||
if (seen_mod)
|
||||
append_separator (gstring);
|
||||
|
||||
#ifndef GDK_WINDOWING_QUARTZ
|
||||
#ifndef GDK_WINDOWING_MACOS
|
||||
/* This is the text that should appear next to menu accelerators
|
||||
* that use the alt key. If the text on this key isn't typically
|
||||
* translated on keyboards used for your language, don't translate
|
||||
@ -910,7 +910,7 @@ gtk_accelerator_print_label (GString *gstring,
|
||||
if (seen_mod)
|
||||
append_separator (gstring);
|
||||
|
||||
#ifndef GDK_WINDOWING_QUARTZ
|
||||
#ifndef GDK_WINDOWING_MACOS
|
||||
/* This is the text that should appear next to menu accelerators
|
||||
* that use the meta key. If the text on this key isn't typically
|
||||
* translated on keyboards used for your language, don't translate
|
||||
|
@ -23,10 +23,10 @@
|
||||
#include "gtkapplicationprivate.h"
|
||||
#include "gtkmenutrackerprivate.h"
|
||||
#include "gtkicontheme.h"
|
||||
#include "gtktoolbarprivate.h"
|
||||
#include "gtkquartz.h"
|
||||
|
||||
#include <gdk/quartz/gdkquartz.h>
|
||||
#include <gdk/macos/gdkmacos.h>
|
||||
#include <gdk/macos/gdkmacoskeymap-private.h>
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@ -98,12 +98,13 @@ tracker_item_changed (GObject *object,
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void
|
||||
icon_loaded (GObject *object,
|
||||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkIconPaintable *icon = GTK_ICON (object);
|
||||
GtkIconPaintable *icon = GTK_ICON_PAINTABLE (object);
|
||||
GNSMenuItem *item = user_data;
|
||||
GError *error = NULL;
|
||||
GdkPixbuf *pixbuf;
|
||||
@ -154,6 +155,7 @@ icon_loaded (GObject *object,
|
||||
g_error_free (error);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@implementation GNSMenuItem
|
||||
|
||||
@ -229,7 +231,7 @@ icon_loaded (GObject *object,
|
||||
|
||||
- (void)didChangeLabel
|
||||
{
|
||||
char *label = _gtk_toolbar_elide_underscores (gtk_menu_tracker_item_get_label (trackerItem));
|
||||
const char *label = gtk_menu_tracker_item_get_label (trackerItem);
|
||||
|
||||
NSString *title = [NSString stringWithUTF8String:label ? : ""];
|
||||
|
||||
@ -254,12 +256,11 @@ icon_loaded (GObject *object,
|
||||
}
|
||||
|
||||
[self setTitle:title];
|
||||
|
||||
g_free (label);
|
||||
}
|
||||
|
||||
- (void)didChangeIcon
|
||||
{
|
||||
#if 0
|
||||
GIcon *icon = gtk_menu_tracker_item_get_icon (trackerItem);
|
||||
|
||||
if (cancellable != NULL)
|
||||
@ -311,6 +312,7 @@ icon_loaded (GObject *object,
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
[self setImage:nil];
|
||||
}
|
||||
@ -322,7 +324,7 @@ icon_loaded (GObject *object,
|
||||
|
||||
- (void)didChangeToggled
|
||||
{
|
||||
[self setState:gtk_menu_tracker_item_get_toggled (trackerItem) ? NSOnState : NSOffState];
|
||||
[self setState:gtk_menu_tracker_item_get_toggled (trackerItem) ? NSControlStateValueOn : NSControlStateValueOff];
|
||||
}
|
||||
|
||||
- (void)didChangeAccel
|
||||
@ -338,18 +340,18 @@ icon_loaded (GObject *object,
|
||||
|
||||
gtk_accelerator_parse (accel, &key, &mask);
|
||||
|
||||
character = gdk_quartz_get_key_equivalent (key);
|
||||
character = _gdk_macos_keymap_get_equivalent (key);
|
||||
[self setKeyEquivalent:[NSString stringWithCharacters:&character length:1]];
|
||||
|
||||
modifiers = 0;
|
||||
if (mask & GDK_SHIFT_MASK)
|
||||
modifiers |= NSShiftKeyMask;
|
||||
modifiers |= NSEventModifierFlagShift;
|
||||
if (mask & GDK_CONTROL_MASK)
|
||||
modifiers |= NSControlKeyMask;
|
||||
modifiers |= NSEventModifierFlagControl;
|
||||
if (mask & GDK_ALT_MASK)
|
||||
modifiers |= NSAlternateKeyMask;
|
||||
modifiers |= NSEventModifierFlagOption;
|
||||
if (mask & GDK_META_MASK)
|
||||
modifiers |= NSCommandKeyMask;
|
||||
modifiers |= NSEventModifierFlagCommand;
|
||||
[self setKeyEquivalentModifierMask:modifiers];
|
||||
}
|
||||
else
|
||||
|
@ -147,6 +147,29 @@ static GActionEntry gtk_application_impl_quartz_actions[] = {
|
||||
{ "show-all", gtk_application_impl_quartz_show_all }
|
||||
};
|
||||
|
||||
static void
|
||||
gtk_application_impl_quartz_set_app_menu (GtkApplicationImpl *impl,
|
||||
GMenuModel *app_menu)
|
||||
{
|
||||
GtkApplicationImplQuartz *quartz = (GtkApplicationImplQuartz *) impl;
|
||||
|
||||
/* If there are any items at all, then the first one is the app menu */
|
||||
if (g_menu_model_get_n_items (G_MENU_MODEL (quartz->combined)))
|
||||
g_menu_remove (quartz->combined, 0);
|
||||
|
||||
if (app_menu)
|
||||
g_menu_prepend_submenu (quartz->combined, "Application", app_menu);
|
||||
else
|
||||
{
|
||||
GMenu *empty;
|
||||
|
||||
/* We must preserve the rule that index 0 is the app menu */
|
||||
empty = g_menu_new ();
|
||||
g_menu_prepend_submenu (quartz->combined, "Application", G_MENU_MODEL (empty));
|
||||
g_object_unref (empty);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_application_impl_quartz_startup (GtkApplicationImpl *impl,
|
||||
gboolean register_session)
|
||||
@ -165,7 +188,7 @@ gtk_application_impl_quartz_startup (GtkApplicationImpl *impl,
|
||||
[NSApp setDelegate: quartz->delegate];
|
||||
}
|
||||
|
||||
quartz->muxer = gtk_action_muxer_new ();
|
||||
quartz->muxer = gtk_action_muxer_new (NULL);
|
||||
gtk_action_muxer_set_parent (quartz->muxer, gtk_application_get_action_muxer (impl->application));
|
||||
|
||||
/* Add the default accels */
|
||||
@ -182,7 +205,7 @@ gtk_application_impl_quartz_startup (GtkApplicationImpl *impl,
|
||||
g_object_unref (gtkinternal);
|
||||
|
||||
/* now setup the menu */
|
||||
app_menu = gtk_application_get_app_menu (impl->application);
|
||||
app_menu = g_object_get_data (G_OBJECT (impl), "APP_MENU");
|
||||
if (app_menu == NULL)
|
||||
{
|
||||
GtkBuilder *builder;
|
||||
@ -193,11 +216,12 @@ gtk_application_impl_quartz_startup (GtkApplicationImpl *impl,
|
||||
* app menu at index 0 in 'combined'.
|
||||
*/
|
||||
builder = gtk_builder_new_from_resource ("/org/gtk/libgtk/ui/gtkapplication-quartz.ui");
|
||||
gtk_application_set_app_menu (impl->application, G_MENU_MODEL (gtk_builder_get_object (builder, "app-menu")));
|
||||
app_menu = G_MENU (gtk_builder_get_object (builder, "app-menu"));
|
||||
g_object_set_data_full (G_OBJECT (impl), "APP_DATA", g_object_ref (app_menu), g_object_unref);
|
||||
g_object_unref (builder);
|
||||
}
|
||||
else
|
||||
gtk_application_impl_set_app_menu (impl, app_menu);
|
||||
gtk_application_impl_quartz_set_app_menu (impl, app_menu);
|
||||
|
||||
/* This may or may not add an item to 'combined' */
|
||||
gtk_application_impl_set_menubar (impl, gtk_application_get_menubar (impl->application));
|
||||
@ -238,29 +262,6 @@ gtk_application_impl_quartz_active_window_changed (GtkApplicationImpl *impl,
|
||||
gtk_action_muxer_insert (quartz->muxer, "win", G_ACTION_GROUP (window));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_application_impl_quartz_set_app_menu (GtkApplicationImpl *impl,
|
||||
GMenuModel *app_menu)
|
||||
{
|
||||
GtkApplicationImplQuartz *quartz = (GtkApplicationImplQuartz *) impl;
|
||||
|
||||
/* If there are any items at all, then the first one is the app menu */
|
||||
if (g_menu_model_get_n_items (G_MENU_MODEL (quartz->combined)))
|
||||
g_menu_remove (quartz->combined, 0);
|
||||
|
||||
if (app_menu)
|
||||
g_menu_prepend_submenu (quartz->combined, "Application", app_menu);
|
||||
else
|
||||
{
|
||||
GMenu *empty;
|
||||
|
||||
/* We must preserve the rule that index 0 is the app menu */
|
||||
empty = g_menu_new ();
|
||||
g_menu_prepend_submenu (quartz->combined, "Application", G_MENU_MODEL (empty));
|
||||
g_object_unref (empty);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_application_impl_quartz_set_menubar (GtkApplicationImpl *impl,
|
||||
GMenuModel *menubar)
|
||||
|
@ -29,8 +29,8 @@
|
||||
#include <gdk/wayland/gdkwayland.h>
|
||||
#endif
|
||||
|
||||
#ifdef GDK_WINDOWING_QUARTZ
|
||||
#include <gdk/quartz/gdkquartz.h>
|
||||
#ifdef GDK_WINDOWING_MACOS
|
||||
#include <gdk/macos/gdkmacos.h>
|
||||
#endif
|
||||
|
||||
G_DEFINE_TYPE (GtkApplicationImpl, gtk_application_impl, G_TYPE_OBJECT)
|
||||
@ -172,8 +172,8 @@ gtk_application_impl_new (GtkApplication *application,
|
||||
impl_type = gtk_application_impl_wayland_get_type ();
|
||||
#endif
|
||||
|
||||
#ifdef GDK_WINDOWING_QUARTZ
|
||||
if (GDK_IS_QUARTZ_DISPLAY (display))
|
||||
#ifdef GDK_WINDOWING_MACOS
|
||||
if (GDK_IS_MACOS_DISPLAY (display))
|
||||
impl_type = gtk_application_impl_quartz_get_type ();
|
||||
#endif
|
||||
|
||||
|
@ -705,7 +705,7 @@ gtk_file_chooser_native_show (GtkNativeDialog *native)
|
||||
self->mode = MODE_WIN32;
|
||||
#endif
|
||||
|
||||
#ifdef GDK_WINDOWING_QUARTZ
|
||||
#ifdef GDK_WINDOWING_MACOS
|
||||
if (gtk_file_chooser_native_quartz_show (self))
|
||||
self->mode = MODE_QUARTZ;
|
||||
#endif
|
||||
@ -734,7 +734,7 @@ gtk_file_chooser_native_hide (GtkNativeDialog *native)
|
||||
#endif
|
||||
break;
|
||||
case MODE_QUARTZ:
|
||||
#ifdef GDK_WINDOWING_QUARTZ
|
||||
#ifdef GDK_WINDOWING_MACOS
|
||||
gtk_file_chooser_native_quartz_hide (self);
|
||||
#endif
|
||||
break;
|
||||
|
@ -36,9 +36,11 @@
|
||||
#include "gtkstylecontext.h"
|
||||
#include "gtkheaderbar.h"
|
||||
#include "gtklabel.h"
|
||||
#include "gtknative.h"
|
||||
#include "gtkfilefilterprivate.h"
|
||||
|
||||
#include "quartz/gdkquartz.h"
|
||||
#include "macos/gdkmacos.h"
|
||||
#include "macos/gdkmacossurface-private.h"
|
||||
|
||||
typedef struct {
|
||||
GtkFileChooserNative *self;
|
||||
@ -180,7 +182,7 @@ chooser_set_current_name (FileChooserQuartzData *data,
|
||||
static void
|
||||
filechooser_quartz_data_free (FileChooserQuartzData *data)
|
||||
{
|
||||
|
||||
|
||||
if (data->filters)
|
||||
{
|
||||
[data->filters release];
|
||||
@ -190,7 +192,7 @@ filechooser_quartz_data_free (FileChooserQuartzData *data)
|
||||
{
|
||||
[data->filter_names release];
|
||||
}
|
||||
|
||||
|
||||
g_clear_object (&data->current_folder);
|
||||
g_clear_object (&data->current_file);
|
||||
g_free (data->current_name);
|
||||
@ -343,7 +345,7 @@ filechooser_quartz_launch (FileChooserQuartzData *data)
|
||||
}
|
||||
data->response = GTK_RESPONSE_CANCEL;
|
||||
|
||||
|
||||
|
||||
void (^handler)(NSInteger ret) = ^(NSInteger result) {
|
||||
|
||||
if (result == NSFileHandlingPanelOKButton)
|
||||
@ -412,7 +414,7 @@ strip_mnemonic (const char *s)
|
||||
{
|
||||
return g_strdup (s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
file_filter_to_quartz (GtkFileFilter *file_filter,
|
||||
@ -467,7 +469,7 @@ gtk_file_chooser_native_quartz_show (GtkFileChooserNative *self)
|
||||
data->filter_names = [NSMutableArray arrayWithCapacity:n_filters];
|
||||
[data->filter_names retain];
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
for (i = 0; i < n_filters; i++)
|
||||
{
|
||||
GtkFileFilter *filter = g_list_model_get_item (filters, i);
|
||||
if (!file_filter_to_quartz (filter, data->filters, data->filter_names))
|
||||
@ -492,7 +494,7 @@ gtk_file_chooser_native_quartz_show (GtkFileChooserNative *self)
|
||||
|
||||
data->create_folders = gtk_file_chooser_get_create_folders (GTK_FILE_CHOOSER (self));
|
||||
|
||||
// shortcut_folder_uris support seems difficult if not impossible
|
||||
// shortcut_folder_uris support seems difficult if not impossible
|
||||
|
||||
// mnemonics are not supported on macOS, so remove the underscores
|
||||
data->accept_label = strip_mnemonic (self->accept_label);
|
||||
@ -516,7 +518,7 @@ gtk_file_chooser_native_quartz_show (GtkFileChooserNative *self)
|
||||
if (transient_for)
|
||||
{
|
||||
gtk_widget_realize (GTK_WIDGET (transient_for));
|
||||
data->parent = gdk_quartz_surface_get_nswindow (gtk_native_get_surface (GTK_NATIVE (transient_for)));
|
||||
data->parent = _gdk_macos_surface_get_native (gtk_native_get_surface (GTK_NATIVE (transient_for)));
|
||||
|
||||
if (gtk_native_dialog_get_modal (GTK_NATIVE_DIALOG (self)))
|
||||
data->modal = TRUE;
|
||||
|
@ -625,7 +625,7 @@ gtk_file_filter_get_attributes (GtkFileFilter *filter)
|
||||
return (const char **)filter->attributes;
|
||||
}
|
||||
|
||||
#ifdef GDK_WINDOWING_QUARTZ
|
||||
#ifdef GDK_WINDOWING_MACOS
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include <gtk/gtkfilefilter.h>
|
||||
#include <gdk/gdkconfig.h>
|
||||
|
||||
#ifdef GDK_WINDOWING_QUARTZ
|
||||
#ifdef GDK_WINDOWING_MACOS
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
@ -30,7 +30,7 @@ G_BEGIN_DECLS
|
||||
|
||||
char ** _gtk_file_filter_get_as_patterns (GtkFileFilter *filter);
|
||||
|
||||
#ifdef GDK_WINDOWING_QUARTZ
|
||||
#ifdef GDK_WINDOWING_MACOS
|
||||
NSArray * _gtk_file_filter_get_as_pattern_nsstrings (GtkFileFilter *filter);
|
||||
#endif
|
||||
|
||||
|
@ -25,10 +25,13 @@
|
||||
#include "gtk/gtkintl.h"
|
||||
#include "gtk/gtkimmoduleprivate.h"
|
||||
|
||||
#include "gdk/quartz/gdkquartz.h"
|
||||
#include "gdk/quartz/GdkQuartzView.h"
|
||||
#include "gdk/macos/gdkmacos.h"
|
||||
#include "gdk/macos/gdkmacosdisplay-private.h"
|
||||
#include "gdk/macos/gdkmacossurface-private.h"
|
||||
|
||||
#define GTK_IM_CONTEXT_TYPE_QUARTZ (type_quartz)
|
||||
#import "gdk/macos/GdkMacosBaseView.h"
|
||||
|
||||
#define GTK_IM_CONTEXT_TYPE_QUARTZ (gtk_im_context_quartz_get_type())
|
||||
#define GTK_IM_CONTEXT_QUARTZ(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_IM_CONTEXT_TYPE_QUARTZ, GtkIMContextQuartz))
|
||||
#define GTK_IM_CONTEXT_QUARTZ_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_IM_CONTEXT_TYPE_QUARTZ, GtkIMContextQuartzClass))
|
||||
|
||||
@ -65,7 +68,7 @@ quartz_get_preedit_string (GtkIMContext *context,
|
||||
{
|
||||
GtkIMContextQuartz *qc = GTK_IM_CONTEXT_QUARTZ (context);
|
||||
|
||||
GTK_NOTE (MISC, g_print ("quartz_get_preedit_string\n"));
|
||||
GTK_NOTE (MODULES, g_print ("quartz_get_preedit_string\n"));
|
||||
|
||||
if (str)
|
||||
*str = qc->preedit_str ? g_strdup (qc->preedit_str) : g_strdup ("");
|
||||
@ -120,7 +123,7 @@ output_result (GtkIMContext *context,
|
||||
marked_str = g_strdup (g_object_get_data (G_OBJECT (surface), TIC_MARKED_TEXT));
|
||||
if (fixed_str)
|
||||
{
|
||||
GTK_NOTE (MISC, g_print ("tic-insert-text: %s\n", fixed_str));
|
||||
GTK_NOTE (MODULES, g_print ("tic-insert-text: %s\n", fixed_str));
|
||||
g_free (qc->preedit_str);
|
||||
qc->preedit_str = NULL;
|
||||
g_object_set_data (G_OBJECT (surface), TIC_INSERT_TEXT, NULL);
|
||||
@ -130,7 +133,7 @@ output_result (GtkIMContext *context,
|
||||
unsigned int filtered =
|
||||
GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (surface),
|
||||
GIC_FILTER_KEY));
|
||||
GTK_NOTE (MISC, g_print ("filtered, %d\n", filtered));
|
||||
GTK_NOTE (MODULES, g_print ("filtered, %d\n", filtered));
|
||||
if (filtered)
|
||||
retval = TRUE;
|
||||
else
|
||||
@ -138,7 +141,7 @@ output_result (GtkIMContext *context,
|
||||
}
|
||||
if (marked_str)
|
||||
{
|
||||
GTK_NOTE (MISC, g_print ("tic-marked-text: %s\n", marked_str));
|
||||
GTK_NOTE (MODULES, g_print ("tic-marked-text: %s\n", marked_str));
|
||||
qc->cursor_index =
|
||||
GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (surface),
|
||||
TIC_SELECTED_POS));
|
||||
@ -166,52 +169,55 @@ quartz_filter_keypress (GtkIMContext *context,
|
||||
GdkEvent *event)
|
||||
{
|
||||
GtkIMContextQuartz *qc = GTK_IM_CONTEXT_QUARTZ (context);
|
||||
GdkEventType event_type;
|
||||
gboolean retval;
|
||||
NSView *nsview;
|
||||
GdkSurface *surface;
|
||||
guint keyval;
|
||||
guint keycode;
|
||||
|
||||
GTK_NOTE (MISC, g_print ("quartz_filter_keypress\n"));
|
||||
GTK_NOTE (MODULES, g_print ("quartz_filter_keypress\n"));
|
||||
|
||||
if (!GDK_IS_QUARTZ_SURFACE (qc->client_surface))
|
||||
if (!GDK_IS_MACOS_SURFACE (qc->client_surface))
|
||||
return FALSE;
|
||||
|
||||
nsview = gdk_quartz_surface_get_nsview (qc->client_surface);
|
||||
surface = (GdkSurface *)[ (GdkQuartzView *)nsview gdkSurface];
|
||||
GTK_NOTE (MISC, g_print ("client_surface: %p, win: %p, nsview: %p\n",
|
||||
qc->client_surface, surface, nsview));
|
||||
event_type = gdk_event_get_event_type (event);
|
||||
keyval = gdk_key_event_get_keyval (event);
|
||||
keycode = gdk_key_event_get_keycode (event);
|
||||
|
||||
NSEvent *nsevent = gdk_quartz_event_get_nsevent ((GdkEvent *)event);
|
||||
NSEvent *nsevent = _gdk_macos_display_get_nsevent ((GdkEvent *)event);
|
||||
|
||||
if (!nsevent)
|
||||
{
|
||||
if (event->hardware_keycode == 0 && event->keyval == 0xffffff)
|
||||
if (keycode == 0 && keyval == 0xffffff)
|
||||
/* update text input changes by mouse events */
|
||||
return output_result (context, surface);
|
||||
return output_result (context, qc->client_surface);
|
||||
else
|
||||
return gtk_im_context_filter_keypress (qc->helper, event);
|
||||
}
|
||||
|
||||
if (event->type == GDK_KEY_RELEASE)
|
||||
if (event_type == GDK_KEY_RELEASE)
|
||||
return FALSE;
|
||||
|
||||
if (event->hardware_keycode == 55) /* Command */
|
||||
if (keycode == 55) /* Command */
|
||||
return FALSE;
|
||||
|
||||
NSEventType etype = [nsevent type];
|
||||
if (etype == NSKeyDown)
|
||||
if (etype == NSEventTypeKeyDown)
|
||||
{
|
||||
g_object_set_data (G_OBJECT (surface), TIC_IN_KEY_DOWN,
|
||||
GUINT_TO_POINTER (TRUE));
|
||||
[nsview keyDown: nsevent];
|
||||
NSView *nsview = _gdk_macos_surface_get_view (GDK_MACOS_SURFACE (qc->client_surface));
|
||||
g_object_set_data (G_OBJECT (qc->client_surface),
|
||||
TIC_IN_KEY_DOWN,
|
||||
GUINT_TO_POINTER (TRUE));
|
||||
[nsview keyDown: nsevent];
|
||||
}
|
||||
/* JIS_Eisu || JIS_Kana */
|
||||
if (event->hardware_keycode == 102 || event->hardware_keycode == 104)
|
||||
if (keycode == 102 || keycode == 104)
|
||||
return FALSE;
|
||||
|
||||
retval = output_result(context, surface);
|
||||
g_object_set_data (G_OBJECT (surface), TIC_IN_KEY_DOWN,
|
||||
GUINT_TO_POINTER (FALSE));
|
||||
GTK_NOTE (MISC, g_print ("quartz_filter_keypress done\n"));
|
||||
retval = output_result(context, qc->client_surface);
|
||||
g_object_set_data (G_OBJECT (qc->client_surface),
|
||||
TIC_IN_KEY_DOWN,
|
||||
GUINT_TO_POINTER (FALSE));
|
||||
GTK_NOTE (MODULES, g_print ("quartz_filter_keypress done\n"));
|
||||
|
||||
return retval;
|
||||
}
|
||||
@ -224,15 +230,15 @@ discard_preedit (GtkIMContext *context)
|
||||
if (!qc->client_surface)
|
||||
return;
|
||||
|
||||
if (!GDK_IS_QUARTZ_SURFACE (qc->client_surface))
|
||||
if (!GDK_IS_MACOS_SURFACE (qc->client_surface))
|
||||
return;
|
||||
|
||||
NSView *nsview = gdk_quartz_surface_get_nsview (qc->client_surface);
|
||||
NSView *nsview = _gdk_macos_surface_get_view (GDK_MACOS_SURFACE (qc->client_surface));
|
||||
if (!nsview)
|
||||
return;
|
||||
|
||||
/* reset any partial input for this NSView */
|
||||
[(GdkQuartzView *)nsview unmarkText];
|
||||
[(GdkMacosBaseView *)nsview unmarkText];
|
||||
NSInputManager *currentInputManager = [NSInputManager currentInputManager];
|
||||
[currentInputManager markedTextAbandoned:nsview];
|
||||
|
||||
@ -249,24 +255,33 @@ discard_preedit (GtkIMContext *context)
|
||||
static void
|
||||
quartz_reset (GtkIMContext *context)
|
||||
{
|
||||
GTK_NOTE (MISC, g_print ("quartz_reset\n"));
|
||||
GTK_NOTE (MODULES, g_print ("quartz_reset\n"));
|
||||
discard_preedit (context);
|
||||
}
|
||||
|
||||
static void
|
||||
quartz_set_client_surface (GtkIMContext *context, GtkWidget *widget)
|
||||
quartz_set_client_surface (GtkIMContext *context,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
GtkIMContextQuartz *qc = GTK_IM_CONTEXT_QUARTZ (context);
|
||||
|
||||
GTK_NOTE (MISC, g_print ("quartz_set_client_surface: %p\n", widget));
|
||||
GTK_NOTE (MODULES, g_print ("quartz_set_client_surface: %p\n", widget));
|
||||
|
||||
qc->client_surface = gtk_widget_get_parent_surface (widget);
|
||||
qc->client_surface = NULL;
|
||||
|
||||
if (widget != NULL)
|
||||
{
|
||||
GtkNative *native = gtk_widget_get_native (widget);
|
||||
|
||||
if (native != NULL)
|
||||
qc->client_surface = gtk_native_get_surface (native);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
quartz_focus_in (GtkIMContext *context)
|
||||
{
|
||||
GTK_NOTE (MISC, g_print ("quartz_focus_in\n"));
|
||||
GTK_NOTE (MODULES, g_print ("quartz_focus_in\n"));
|
||||
|
||||
GtkIMContextQuartz *qc = GTK_IM_CONTEXT_QUARTZ (context);
|
||||
qc->focused = TRUE;
|
||||
@ -275,7 +290,7 @@ quartz_focus_in (GtkIMContext *context)
|
||||
static void
|
||||
quartz_focus_out (GtkIMContext *context)
|
||||
{
|
||||
GTK_NOTE (MISC, g_print ("quartz_focus_out\n"));
|
||||
GTK_NOTE (MODULES, g_print ("quartz_focus_out\n"));
|
||||
|
||||
GtkIMContextQuartz *qc = GTK_IM_CONTEXT_QUARTZ (context);
|
||||
qc->focused = FALSE;
|
||||
@ -289,10 +304,8 @@ quartz_set_cursor_location (GtkIMContext *context, GdkRectangle *area)
|
||||
{
|
||||
GtkIMContextQuartz *qc = GTK_IM_CONTEXT_QUARTZ (context);
|
||||
int x, y;
|
||||
NSView *nsview;
|
||||
GdkSurface *surface;
|
||||
|
||||
GTK_NOTE (MISC, g_print ("quartz_set_cursor_location\n"));
|
||||
GTK_NOTE (MODULES, g_print ("quartz_set_cursor_location\n"));
|
||||
|
||||
if (!qc->client_surface)
|
||||
return;
|
||||
@ -310,18 +323,16 @@ quartz_set_cursor_location (GtkIMContext *context, GdkRectangle *area)
|
||||
qc->cursor_rect->x = area->x + x;
|
||||
qc->cursor_rect->y = area->y + y;
|
||||
|
||||
if (!GDK_IS_QUARTZ_SURFACE (qc->client_surface))
|
||||
if (!GDK_IS_MACOS_SURFACE (qc->client_surface))
|
||||
return;
|
||||
|
||||
nsview = gdk_quartz_surface_get_nsview (qc->client_surface);
|
||||
surface = (GdkSurface *)[ (GdkQuartzView*)nsview gdkSurface];
|
||||
g_object_set_data (G_OBJECT (surface), GIC_CURSOR_RECT, qc->cursor_rect);
|
||||
g_object_set_data (G_OBJECT (qc->client_surface), GIC_CURSOR_RECT, qc->cursor_rect);
|
||||
}
|
||||
|
||||
static void
|
||||
quartz_set_use_preedit (GtkIMContext *context, gboolean use_preedit)
|
||||
{
|
||||
GTK_NOTE (MISC, g_print ("quartz_set_use_preedit: %d\n", use_preedit));
|
||||
GTK_NOTE (MODULES, g_print ("quartz_set_use_preedit: %d\n", use_preedit));
|
||||
}
|
||||
|
||||
static void
|
||||
@ -333,7 +344,7 @@ commit_cb (GtkIMContext *context, const char *str, GtkIMContextQuartz *qc)
|
||||
static void
|
||||
imquartz_finalize (GObject *obj)
|
||||
{
|
||||
GTK_NOTE (MISC, g_print ("imquartz_finalize\n"));
|
||||
GTK_NOTE (MODULES, g_print ("imquartz_finalize\n"));
|
||||
|
||||
GtkIMContextQuartz *qc = GTK_IM_CONTEXT_QUARTZ (obj);
|
||||
g_free (qc->preedit_str);
|
||||
@ -344,13 +355,13 @@ imquartz_finalize (GObject *obj)
|
||||
g_signal_handlers_disconnect_by_func (qc->helper, (gpointer)commit_cb, qc);
|
||||
g_object_unref (qc->helper);
|
||||
|
||||
gtk_im_context_quartz_parent_class->finalize (obj);
|
||||
G_OBJECT_CLASS (gtk_im_context_quartz_parent_class)->finalize (obj);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_im_context_quartz_class_init (GtkIMContextQuartzClass *class)
|
||||
{
|
||||
GTK_NOTE (MISC, g_print ("gtk_im_context_quartz_class_init\n"));
|
||||
GTK_NOTE (MODULES, g_print ("gtk_im_context_quartz_class_init\n"));
|
||||
|
||||
GtkIMContextClass *klass = GTK_IM_CONTEXT_CLASS (class);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
||||
@ -370,7 +381,7 @@ gtk_im_context_quartz_class_init (GtkIMContextQuartzClass *class)
|
||||
static void
|
||||
gtk_im_context_quartz_init (GtkIMContextQuartz *qc)
|
||||
{
|
||||
GTK_NOTE (MISC, g_print ("gtk_im_context_quartz_init\n"));
|
||||
GTK_NOTE (MODULES, g_print ("gtk_im_context_quartz_init\n"));
|
||||
|
||||
qc->preedit_str = g_strdup ("");
|
||||
qc->cursor_index = 0;
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
GType gtk_im_context_quartz_get_type (void) G_GNUC_CONST;
|
||||
GType gtk_im_context_quartz_get_type (void) G_GNUC_CONST;
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
||||
* file for a list of people on the GTK+ Team. See the ChangeLog
|
||||
* files for a list of changes. These files are distributed with
|
||||
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
||||
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
@ -58,8 +58,8 @@
|
||||
#include "gtkimcontextime.h"
|
||||
#endif
|
||||
|
||||
#ifdef GDK_WINDOWING_QUARTZ
|
||||
#include "quartz/gdkquartz.h"
|
||||
#ifdef GDK_WINDOWING_MACOS
|
||||
#include "macos/gdkmacos.h"
|
||||
#include "gtkimcontextquartz.h"
|
||||
#endif
|
||||
|
||||
@ -73,10 +73,10 @@
|
||||
/**
|
||||
* _gtk_im_module_create:
|
||||
* @context_id: the context ID for the context type to create
|
||||
*
|
||||
*
|
||||
* Create an IM context of a type specified by the string
|
||||
* ID @context_id.
|
||||
*
|
||||
*
|
||||
* Returns: a newly created input context of or @context_id, or
|
||||
* if that could not be created, a newly created GtkIMContextSimple.
|
||||
*/
|
||||
@ -132,8 +132,8 @@ match_backend (GdkDisplay *display,
|
||||
#endif
|
||||
|
||||
if (g_strcmp0 (context_id, "quartz") == 0)
|
||||
#ifdef GDK_WINDOWING_QUARTZ
|
||||
return GDK_IS_QUARTZ_DISPLAY (display);
|
||||
#ifdef GDK_WINDOWING_MACOS
|
||||
return GDK_IS_MACOS_DISPLAY (display);
|
||||
#else
|
||||
return FALSE;
|
||||
#endif
|
||||
@ -175,9 +175,9 @@ lookup_immodule (GdkDisplay *display,
|
||||
* _gtk_im_module_get_default_context_id:
|
||||
* @display: The display to look up the module for
|
||||
*
|
||||
* Return the context_id of the best IM context type
|
||||
* Return the context_id of the best IM context type
|
||||
* for the given window.
|
||||
*
|
||||
*
|
||||
* Returns: the context ID (will never be %NULL)
|
||||
*/
|
||||
const char *
|
||||
@ -270,7 +270,7 @@ gtk_im_modules_init (void)
|
||||
#ifdef GDK_WINDOWING_WIN32
|
||||
g_type_ensure (gtk_im_context_ime_get_type ());
|
||||
#endif
|
||||
#ifdef GDK_WINDOWING_QUARTZ
|
||||
#ifdef GDK_WINDOWING_MACOS
|
||||
g_type_ensure (gtk_im_context_quartz_get_type ());
|
||||
#endif
|
||||
|
||||
|
@ -33,7 +33,7 @@
|
||||
#include "gtkresources.h"
|
||||
|
||||
|
||||
#if !defined G_OS_WIN32 && !(defined GDK_WINDOWING_QUARTZ && defined QUARTZ_RELOCATION)
|
||||
#if !defined G_OS_WIN32 && !(defined GDK_WINDOWING_MACOS && defined QUARTZ_RELOCATION)
|
||||
|
||||
const char *
|
||||
_gtk_get_datadir (void)
|
||||
|
214
gtk/gtkquartz.c
214
gtk/gtkquartz.c
@ -19,12 +19,12 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkquartz.h"
|
||||
#include <gdk/quartz/gdkquartz.h>
|
||||
|
||||
#include <gdk/macos/gdkmacos.h>
|
||||
|
||||
static gboolean
|
||||
_cairo_surface_extents (cairo_surface_t *surface,
|
||||
GdkRectangle *extents)
|
||||
GdkRectangle *extents)
|
||||
{
|
||||
double x1, x2, y1, y2;
|
||||
cairo_t *cr;
|
||||
@ -59,7 +59,9 @@ _cairo_surface_extents (cairo_surface_t *surface,
|
||||
}
|
||||
|
||||
static void
|
||||
_data_provider_release_cairo_surface (void* info, const void* data, size_t size)
|
||||
_data_provider_release_cairo_surface (void *info,
|
||||
const void *data,
|
||||
size_t size)
|
||||
{
|
||||
cairo_surface_destroy ((cairo_surface_t *)info);
|
||||
}
|
||||
@ -121,212 +123,6 @@ _gtk_quartz_create_image_from_surface (cairo_surface_t *surface)
|
||||
return nsimage;
|
||||
}
|
||||
|
||||
NSSet *
|
||||
_gtk_quartz_target_list_to_pasteboard_types (GtkTargetList *target_list)
|
||||
{
|
||||
NSMutableSet *set = [[NSMutableSet alloc] init];
|
||||
GList *list;
|
||||
|
||||
for (list = target_list->list; list; list = list->next)
|
||||
{
|
||||
GtkTargetPair *pair = list->data;
|
||||
g_return_val_if_fail (pair->flags < 16, NULL);
|
||||
[set addObject:gdk_quartz_atom_to_pasteboard_type_libgtk_only (pair->target)];
|
||||
}
|
||||
|
||||
return set;
|
||||
}
|
||||
|
||||
NSSet *
|
||||
_gtk_quartz_target_entries_to_pasteboard_types (const GtkTargetEntry *targets,
|
||||
guint n_targets)
|
||||
{
|
||||
NSMutableSet *set = [[NSMutableSet alloc] init];
|
||||
int i;
|
||||
|
||||
for (i = 0; i < n_targets; i++)
|
||||
{
|
||||
[set addObject:gdk_quartz_target_to_pasteboard_type_libgtk_only (targets[i].target)];
|
||||
}
|
||||
|
||||
return set;
|
||||
}
|
||||
|
||||
GList *
|
||||
_gtk_quartz_pasteboard_types_to_atom_list (NSArray *array)
|
||||
{
|
||||
GList *result = NULL;
|
||||
int i;
|
||||
int count;
|
||||
|
||||
count = [array count];
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
GdkAtom atom = gdk_quartz_pasteboard_type_to_atom_libgtk_only ([array objectAtIndex:i]);
|
||||
|
||||
result = g_list_prepend (result, GDK_ATOM_TO_POINTER (atom));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
GtkSelectionData *
|
||||
_gtk_quartz_get_selection_data_from_pasteboard (NSPasteboard *pasteboard,
|
||||
GdkAtom target,
|
||||
GdkAtom selection)
|
||||
{
|
||||
GtkSelectionData *selection_data = NULL;
|
||||
|
||||
selection_data = g_slice_new0 (GtkSelectionData);
|
||||
selection_data->selection = selection;
|
||||
selection_data->target = target;
|
||||
if (!selection_data->display)
|
||||
selection_data->display = gdk_display_get_default ();
|
||||
if (target == g_intern_static_string ("UTF8_STRING"))
|
||||
{
|
||||
NSString *s = [pasteboard stringForType:NSStringPboardType];
|
||||
|
||||
if (s)
|
||||
{
|
||||
const char *utf8_string = [s UTF8String];
|
||||
|
||||
gtk_selection_data_set (selection_data,
|
||||
target, 8,
|
||||
(guchar *)utf8_string, strlen (utf8_string));
|
||||
}
|
||||
}
|
||||
else if (target == g_intern_static_string ("application/x-color"))
|
||||
{
|
||||
NSColor *nscolor = [[NSColor colorFromPasteboard:pasteboard]
|
||||
colorUsingColorSpaceName:NSDeviceRGBColorSpace];
|
||||
|
||||
guint16 color[4];
|
||||
|
||||
selection_data->target = target;
|
||||
|
||||
color[0] = 0xffff * [nscolor redComponent];
|
||||
color[1] = 0xffff * [nscolor greenComponent];
|
||||
color[2] = 0xffff * [nscolor blueComponent];
|
||||
color[3] = 0xffff * [nscolor alphaComponent];
|
||||
|
||||
gtk_selection_data_set (selection_data, target, 16, (guchar *)color, 8);
|
||||
}
|
||||
else if (target == g_intern_static_string ("text/uri-list"))
|
||||
{
|
||||
if ([[pasteboard types] containsObject:NSFilenamesPboardType])
|
||||
{
|
||||
char **uris;
|
||||
NSArray *files = [pasteboard propertyListForType:NSFilenamesPboardType];
|
||||
int n_files = [files count];
|
||||
int i;
|
||||
|
||||
selection_data->target = g_intern_static_string ("text/uri-list");
|
||||
|
||||
uris = (char **) g_malloc (sizeof (char *) * (n_files + 1));
|
||||
for (i = 0; i < n_files; ++i)
|
||||
{
|
||||
NSString* uriString = [files objectAtIndex:i];
|
||||
uriString = [@"file://" stringByAppendingString:uriString];
|
||||
uriString = [uriString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
||||
uris[i] = (char *) [uriString cStringUsingEncoding:NSUTF8StringEncoding];
|
||||
}
|
||||
uris[i] = NULL;
|
||||
|
||||
gtk_selection_data_set_uris (selection_data, uris);
|
||||
g_free (uris);
|
||||
}
|
||||
else if ([[pasteboard types] containsObject:NSURLPboardType])
|
||||
{
|
||||
char *uris[2];
|
||||
NSURL *url = [NSURL URLFromPasteboard:pasteboard];
|
||||
|
||||
selection_data->target = g_intern_static_string ("text/uri-list");
|
||||
|
||||
uris[0] = (char *) [[url description] UTF8String];
|
||||
|
||||
uris[1] = NULL;
|
||||
gtk_selection_data_set_uris (selection_data, uris);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NSData *data;
|
||||
const char *name;
|
||||
|
||||
name = (const char *)target;
|
||||
|
||||
if (strcmp (name, "image/tiff") == 0)
|
||||
data = [pasteboard dataForType:NSTIFFPboardType];
|
||||
else
|
||||
data = [pasteboard dataForType:[NSString stringWithUTF8String:name]];
|
||||
|
||||
if (data)
|
||||
{
|
||||
gtk_selection_data_set (selection_data,
|
||||
target, 8,
|
||||
[data bytes], [data length]);
|
||||
}
|
||||
}
|
||||
|
||||
return selection_data;
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_quartz_set_selection_data_for_pasteboard (NSPasteboard *pasteboard,
|
||||
GtkSelectionData *selection_data)
|
||||
{
|
||||
NSString *type;
|
||||
GdkDisplay *display;
|
||||
int format;
|
||||
const guchar *data;
|
||||
NSUInteger length;
|
||||
|
||||
display = gtk_selection_data_get_display (selection_data);
|
||||
format = gtk_selection_data_get_format (selection_data);
|
||||
data = gtk_selection_data_get_data (selection_data);
|
||||
length = gtk_selection_data_get_length (selection_data);
|
||||
|
||||
type = gdk_quartz_atom_to_pasteboard_type_libgtk_only (gtk_selection_data_get_target (selection_data));
|
||||
|
||||
if ([type isEqualTo:NSStringPboardType])
|
||||
[pasteboard setString:[NSString stringWithUTF8String:(const char *)data]
|
||||
forType:type];
|
||||
else if ([type isEqualTo:NSColorPboardType])
|
||||
{
|
||||
guint16 *color = (guint16 *)data;
|
||||
float red, green, blue, alpha;
|
||||
NSColor *nscolor;
|
||||
|
||||
red = (float)color[0] / 0xffff;
|
||||
green = (float)color[1] / 0xffff;
|
||||
blue = (float)color[2] / 0xffff;
|
||||
alpha = (float)color[3] / 0xffff;
|
||||
|
||||
nscolor = [NSColor colorWithDeviceRed:red green:green blue:blue alpha:alpha];
|
||||
[nscolor writeToPasteboard:pasteboard];
|
||||
}
|
||||
else if ([type isEqualTo:NSURLPboardType])
|
||||
{
|
||||
char **uris;
|
||||
|
||||
uris = gtk_selection_data_get_uris (selection_data);
|
||||
if (uris != NULL)
|
||||
{
|
||||
NSURL *url;
|
||||
|
||||
url = [NSURL URLWithString:[NSString stringWithUTF8String:uris[0]]];
|
||||
[url writeToPasteboard:pasteboard];
|
||||
}
|
||||
g_strfreev (uris);
|
||||
}
|
||||
else
|
||||
[pasteboard setData:[NSData dataWithBytesNoCopy:(void *)data
|
||||
length:length
|
||||
freeWhenDone:NO]
|
||||
forType:type];
|
||||
}
|
||||
|
||||
#ifdef QUARTZ_RELOCATION
|
||||
|
||||
/* Bundle-based functions for various directories. These almost work
|
||||
|
@ -20,31 +20,18 @@
|
||||
#define __GTK_QUARTZ_H__
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#include <gtk/gtkselection.h>
|
||||
|
||||
#include <cairo.h>
|
||||
#include <glib.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
NSSet *_gtk_quartz_target_list_to_pasteboard_types (GtkTargetList *target_list);
|
||||
NSSet *_gtk_quartz_target_entries_to_pasteboard_types (const GtkTargetEntry *targets,
|
||||
guint n_targets);
|
||||
|
||||
GList *_gtk_quartz_pasteboard_types_to_atom_list (NSArray *array);
|
||||
|
||||
GtkSelectionData *_gtk_quartz_get_selection_data_from_pasteboard (NSPasteboard *pasteboard,
|
||||
GdkAtom target,
|
||||
GdkAtom selection);
|
||||
|
||||
void _gtk_quartz_set_selection_data_for_pasteboard (NSPasteboard *pasteboard,
|
||||
GtkSelectionData *selection_data);
|
||||
|
||||
NSImage *_gtk_quartz_create_image_from_surface (cairo_surface_t *surface);
|
||||
void _gtk_clipboard_handle_event (GdkEventOwnerChange *event);
|
||||
void _gtk_clipboard_store_all (void);
|
||||
const char * _gtk_get_datadir (void);
|
||||
const char * _gtk_get_libdir (void);
|
||||
const char * _gtk_get_localedir (void);
|
||||
const char * _gtk_get_sysconfdir (void);
|
||||
const char * _gtk_get_data_prefix (void);
|
||||
NSImage *_gtk_quartz_create_image_from_surface (cairo_surface_t *surface);
|
||||
const char *_gtk_get_datadir (void);
|
||||
const char *_gtk_get_libdir (void);
|
||||
const char *_gtk_get_localedir (void);
|
||||
const char *_gtk_get_sysconfdir (void);
|
||||
const char *_gtk_get_data_prefix (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -2196,7 +2196,7 @@ gtk_range_scroll_controller_scroll (GtkEventControllerScroll *scroll,
|
||||
gboolean handled;
|
||||
GtkOrientation move_orientation;
|
||||
|
||||
#ifdef GDK_WINDOWING_QUARTZ
|
||||
#ifdef GDK_WINDOWING_MACOS
|
||||
scroll_unit = 1;
|
||||
#else
|
||||
scroll_unit = gtk_adjustment_get_page_increment (priv->adjustment);
|
||||
|
@ -1188,7 +1188,7 @@ get_scroll_unit (GtkScrolledWindow *sw,
|
||||
{
|
||||
double scroll_unit;
|
||||
|
||||
#ifndef GDK_WINDOWING_QUARTZ
|
||||
#ifndef GDK_WINDOWING_MACOS
|
||||
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (sw);
|
||||
GtkScrollbar *scrollbar;
|
||||
GtkAdjustment *adj;
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "gtksearchenginequartz.h"
|
||||
#include "gtkintl.h"
|
||||
|
||||
#include <gdk/gdk.h> /* for GDK_WINDOWING_QUARTZ */
|
||||
#include <gdk/gdk.h> /* for GDK_WINDOWING_MACOS */
|
||||
|
||||
#if defined(HAVE_TRACKER3)
|
||||
#include "gtksearchenginetracker3.h"
|
||||
@ -340,7 +340,7 @@ _gtk_search_engine_new (void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef GDK_WINDOWING_QUARTZ
|
||||
#ifdef GDK_WINDOWING_MACOS
|
||||
engine->priv->native = _gtk_search_engine_quartz_new ();
|
||||
if (engine->priv->native)
|
||||
{
|
||||
|
@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
#include <Cocoa/Cocoa.h>
|
||||
#include <quartz/gdkquartz.h>
|
||||
#include <macos/gdkmacos.h>
|
||||
|
||||
#include "gtksearchenginequartz.h"
|
||||
|
||||
@ -262,7 +262,7 @@ _gtk_search_engine_quartz_init (GtkSearchEngineQuartz *engine)
|
||||
GtkSearchEngine *
|
||||
_gtk_search_engine_quartz_new (void)
|
||||
{
|
||||
#ifdef GDK_WINDOWING_QUARTZ
|
||||
#ifdef GDK_WINDOWING_MACOS
|
||||
return g_object_new (GTK_TYPE_SEARCH_ENGINE_QUARTZ, NULL);
|
||||
#else
|
||||
return NULL;
|
||||
|
@ -49,15 +49,15 @@
|
||||
#include "broadway/gdkbroadway.h"
|
||||
#endif
|
||||
|
||||
#ifdef GDK_WINDOWING_QUARTZ
|
||||
#include "quartz/gdkquartz.h"
|
||||
#ifdef GDK_WINDOWING_MACOS
|
||||
#include "macos/gdkmacos.h"
|
||||
#endif
|
||||
|
||||
#ifdef GDK_WINDOWING_WIN32
|
||||
#include "win32/gdkwin32.h"
|
||||
#endif
|
||||
|
||||
#ifdef GDK_WINDOWING_QUARTZ
|
||||
#ifdef GDK_WINDOWING_MACOS
|
||||
#define PRINT_PREVIEW_COMMAND "open -b com.apple.Preview %f"
|
||||
#else
|
||||
#define PRINT_PREVIEW_COMMAND "evince --unlink-tempfile --preview --print-settings %s %f"
|
||||
@ -1095,10 +1095,9 @@ gtk_settings_create_for_display (GdkDisplay *display)
|
||||
{
|
||||
GtkSettings *settings;
|
||||
|
||||
#ifdef GDK_WINDOWING_QUARTZ
|
||||
if (GDK_IS_QUARTZ_DISPLAY (display))
|
||||
#ifdef GDK_WINDOWING_MACOS
|
||||
if (GDK_IS_MACOS_DISPLAY (display))
|
||||
settings = g_object_new (GTK_TYPE_SETTINGS,
|
||||
"gtk-key-theme-name", "Mac",
|
||||
"gtk-shell-shows-app-menu", TRUE,
|
||||
"gtk-shell-shows-menubar", TRUE,
|
||||
NULL);
|
||||
|
@ -44,8 +44,8 @@
|
||||
#include "win32/gdkwin32.h"
|
||||
#endif
|
||||
|
||||
#ifdef GDK_WINDOWING_QUARTZ
|
||||
#include "quartz/gdkquartz.h"
|
||||
#ifdef GDK_WINDOWING_MACOS
|
||||
#include "macos/gdkmacos.h"
|
||||
#endif
|
||||
|
||||
#ifdef GDK_WINDOWING_WAYLAND
|
||||
@ -134,9 +134,9 @@ init_version (GtkInspectorGeneral *gen)
|
||||
backend = "Windows";
|
||||
else
|
||||
#endif
|
||||
#ifdef GDK_WINDOWING_QUARTZ
|
||||
if (GDK_IS_QUARTZ_DISPLAY (gen->display))
|
||||
backend = "Quartz";
|
||||
#ifdef GDK_WINDOWING_MACOS
|
||||
if (GDK_IS_MACOS_DISPLAY (gen->display))
|
||||
backend = "MacOS";
|
||||
else
|
||||
#endif
|
||||
backend = "Unknown";
|
||||
@ -565,7 +565,7 @@ populate_monitor (gpointer item,
|
||||
gtk_widget_add_css_class (GTK_WIDGET (list), "rich-list");
|
||||
gtk_list_box_set_selection_mode (list, GTK_SELECTION_NONE);
|
||||
|
||||
/* XXX: add monitor # here when porting to listview */
|
||||
/* XXX: add monitor # here when porting to listview */
|
||||
name = g_strdup_printf ("Monitor %d", 1);
|
||||
manufacturer = gdk_monitor_get_manufacturer (monitor);
|
||||
model = gdk_monitor_get_model (monitor);
|
||||
|
@ -487,7 +487,7 @@ static char *
|
||||
get_data_path (const char *subdir)
|
||||
{
|
||||
char *base_datadir, *full_datadir;
|
||||
#if defined (GDK_WINDOWING_WIN32) || defined (GDK_WINDOWING_QUARTZ)
|
||||
#if defined (GDK_WINDOWING_WIN32) || defined (GDK_WINDOWING_MACOS)
|
||||
base_datadir = g_strdup (_gtk_get_datadir ());
|
||||
#else
|
||||
base_datadir = g_strdup (GTK_DATADIR);
|
||||
|
@ -806,21 +806,21 @@ if win32_enabled
|
||||
gtk_sources += ['gtkmountoperation-stub.c']
|
||||
endif
|
||||
|
||||
if quartz_enabled
|
||||
if macos_enabled
|
||||
gtk_sources += files([
|
||||
'gtksearchenginequartz.c',
|
||||
'gtkmountoperation-stub.c',
|
||||
'gtkapplication-quartz.c',
|
||||
'gtkapplication-quartz-menu.c',
|
||||
'gtkfilechoosernativequartz.c',
|
||||
'gtkimcontextquartz.c',
|
||||
'gtkquartz.c',
|
||||
])
|
||||
gtk_sources += ['gtkimcontextquartz.c']
|
||||
|
||||
gtk_cargs += ['-xobjective-c'] # FIXME? maybe add_languages() instead?
|
||||
endif
|
||||
|
||||
if not (x11_enabled or win32_enabled or quartz_enabled)
|
||||
if not (x11_enabled or win32_enabled or macos_enabled)
|
||||
gtk_sources += ['gtkmountoperation-stub.c', ]
|
||||
endif
|
||||
|
||||
@ -1041,6 +1041,14 @@ if x11_enabled or wayland_enabled
|
||||
gtk_deps += pangoft_dep
|
||||
endif
|
||||
|
||||
if macos_enabled
|
||||
gtk_macos_frameworks = [
|
||||
'AppKit',
|
||||
'Foundation',
|
||||
]
|
||||
gtk_deps += [dependency('appleframeworks', modules: gtk_macos_frameworks)]
|
||||
endif
|
||||
|
||||
gtk_deps += cloudproviders_dep
|
||||
|
||||
if os_unix
|
||||
|
@ -113,7 +113,6 @@ os_unix = not os_win32
|
||||
if os_darwin
|
||||
wayland_enabled = false
|
||||
else
|
||||
quartz_enabled = false
|
||||
macos_enabled = false
|
||||
endif
|
||||
|
||||
@ -418,7 +417,7 @@ pc_gdk_extra_libs = []
|
||||
cairo_backends = []
|
||||
foreach backend: [ ['cairo-xlib', cairo_req, x11_enabled],
|
||||
['cairo-win32', cairo_req, win32_enabled],
|
||||
['cairo-quartz', cairo_req, quartz_enabled],
|
||||
['cairo-quartz', cairo_req, macos_enabled],
|
||||
['cairo', cairo_req, broadway_enabled or wayland_enabled], ]
|
||||
backend_enabled = backend.get(2)
|
||||
cairo_backend_req = backend.get(1)
|
||||
@ -591,7 +590,7 @@ if broadway_enabled
|
||||
backend_immodules += ['broadway']
|
||||
endif
|
||||
|
||||
if quartz_enabled
|
||||
if macos_enabled
|
||||
pc_gdk_extra_libs += ['-framework Cocoa', '-framework Carbon']
|
||||
backend_immodules += ['quartz']
|
||||
endif
|
||||
@ -814,7 +813,7 @@ pkgs = [ 'gtk4.pc' ]
|
||||
|
||||
pkg_targets = ''
|
||||
display_backends = []
|
||||
foreach backend: [ 'broadway', 'quartz', 'macos', 'wayland', 'win32', 'x11', ]
|
||||
foreach backend: [ 'broadway', 'macos', 'wayland', 'win32', 'x11', ]
|
||||
if get_variable('@0@_enabled'.format(backend))
|
||||
pkgs += ['gtk4-@0@.pc'.format(backend)]
|
||||
pkg_targets += ' ' + backend
|
||||
|
Loading…
Reference in New Issue
Block a user