diff --git a/gdk/quartz/gdkdisplay-quartz.c b/gdk/quartz/gdkdisplay-quartz.c index 1e9dfa08ea..357c3c0b54 100644 --- a/gdk/quartz/gdkdisplay-quartz.c +++ b/gdk/quartz/gdkdisplay-quartz.c @@ -123,10 +123,9 @@ _gdk_quartz_display_open (const gchar *display_name) _gdk_display->device_manager = _gdk_device_manager_new (_gdk_display); _gdk_screen = g_object_new (gdk_quartz_screen_get_type (), NULL); - _gdk_quartz_screen_init_visuals (_gdk_screen); - _gdk_windowing_window_init (); + _gdk_quartz_window_init_windowing (_gdk_display, _gdk_screen); _gdk_quartz_events_init (); @@ -190,6 +189,18 @@ gdk_quartz_display_beep (GdkDisplay *display) NSBeep(); } +static void +gdk_quartz_display_sync (GdkDisplay *display) +{ + /* Not supported. */ +} + +static void +gdk_quartz_display_flush (GdkDisplay *display) +{ + /* Not supported. */ +} + static gboolean gdk_quartz_display_supports_selection_notification (GdkDisplay *display) { @@ -318,8 +329,8 @@ gdk_quartz_display_class_init (GdkQuartzDisplayClass *class) display_class->get_screen = gdk_quartz_display_get_screen; display_class->get_default_screen = gdk_quartz_display_get_default_screen; display_class->beep = gdk_quartz_display_beep; - display_class->sync = _gdk_quartz_display_sync; - display_class->flush = _gdk_quartz_display_flush; + display_class->sync = gdk_quartz_display_sync; + display_class->flush = gdk_quartz_display_flush; display_class->queue_events = _gdk_quartz_display_queue_events; display_class->has_pending = _gdk_quartz_display_has_pending; display_class->get_default_group = gdk_quartz_display_get_default_group; diff --git a/gdk/quartz/gdkevents-quartz.c b/gdk/quartz/gdkevents-quartz.c index 227cdbdb94..348dff1954 100644 --- a/gdk/quartz/gdkevents-quartz.c +++ b/gdk/quartz/gdkevents-quartz.c @@ -1340,17 +1340,6 @@ _gdk_quartz_display_add_client_message_filter (GdkDisplay *display, /* Not supported. */ } -void -_gdk_quartz_display_sync (GdkDisplay *display) -{ - /* Not supported. */ -} - -void -_gdk_quartz_display_flush (GdkDisplay *display) -{ - /* Not supported. */ -} gboolean _gdk_quartz_display_send_client_message (GdkDisplay *display, diff --git a/gdk/quartz/gdkprivate-quartz.h b/gdk/quartz/gdkprivate-quartz.h index 43dd621e3b..b1ef443d00 100644 --- a/gdk/quartz/gdkprivate-quartz.h +++ b/gdk/quartz/gdkprivate-quartz.h @@ -46,52 +46,14 @@ extern GdkDragContext *_gdk_quartz_drag_source_context; #define GDK_WINDOW_IS_QUARTZ(win) (GDK_IS_WINDOW_IMPL_QUARTZ (((GdkWindow *)win)->impl)) /* Initialization */ -void _gdk_windowing_update_window_sizes (GdkScreen *screen); -void _gdk_windowing_window_init (void); +void _gdk_quartz_window_init_windowing (GdkDisplay *display, + GdkScreen *screen); void _gdk_quartz_events_init (void); -void _gdk_quartz_input_init (void); void _gdk_quartz_event_loop_init (void); -/* GC */ -typedef enum { - GDK_QUARTZ_CONTEXT_STROKE = 1 << 0, - GDK_QUARTZ_CONTEXT_FILL = 1 << 1, - GDK_QUARTZ_CONTEXT_TEXT = 1 << 2 -} GdkQuartzContextValuesMask; - /* Cursor */ NSCursor *_gdk_quartz_cursor_get_ns_cursor (GdkCursor *cursor); -/* Window */ -gboolean _gdk_quartz_window_is_ancestor (GdkWindow *ancestor, - GdkWindow *window); -void _gdk_quartz_window_gdk_xy_to_xy (gint gdk_x, - gint gdk_y, - gint *ns_x, - gint *ns_y); -void _gdk_quartz_window_xy_to_gdk_xy (gint ns_x, - gint ns_y, - gint *gdk_x, - gint *gdk_y); -void _gdk_quartz_window_nspoint_to_gdk_xy (NSPoint point, - gint *x, - gint *y); -GdkWindow *_gdk_quartz_window_find_child (GdkWindow *window, - gint x, - gint y, - gboolean get_toplevel); -void _gdk_quartz_window_attach_to_parent (GdkWindow *window); -void _gdk_quartz_window_detach_from_parent (GdkWindow *window); -void _gdk_quartz_window_did_become_main (GdkWindow *window); -void _gdk_quartz_window_did_resign_main (GdkWindow *window); -void _gdk_quartz_window_debug_highlight (GdkWindow *window, - gint number); - -void _gdk_quartz_window_set_needs_display_in_region (GdkWindow *window, - cairo_region_t *region); - -void _gdk_quartz_window_update_position (GdkWindow *window); - /* Events */ typedef enum { GDK_QUARTZ_EVENT_SUBTYPE_EVENTLOOP @@ -114,9 +76,6 @@ GdkEventType _gdk_quartz_keys_event_type (NSEvent *event); gboolean _gdk_quartz_keys_is_modifier (guint keycode); /* Geometry */ -void _gdk_quartz_window_scroll (GdkWindow *window, - gint dx, - gint dy); void _gdk_quartz_window_translate (GdkWindow *window, cairo_region_t *area, gint dx, @@ -124,17 +83,35 @@ void _gdk_quartz_window_translate (GdkWindow *window, gboolean _gdk_quartz_window_queue_antiexpose (GdkWindow *window, cairo_region_t *area); +/* Drag and Drop */ void _gdk_quartz_window_register_dnd (GdkWindow *window); GdkDragContext * _gdk_quartz_window_drag_begin (GdkWindow *window, GdkDevice *device, GList *targets); +/* Display */ -void _gdk_quartz_display_sync (GdkDisplay *display); -void _gdk_quartz_display_flush (GdkDisplay *display); +GdkDisplay * _gdk_quartz_display_open (const gchar *name); + +/* Display methods - events */ void _gdk_quartz_display_queue_events (GdkDisplay *display); gboolean _gdk_quartz_display_has_pending (GdkDisplay *display); +void _gdk_quartz_display_event_data_copy (GdkDisplay *display, + const GdkEvent *src, + GdkEvent *dst); +void _gdk_quartz_display_event_data_free (GdkDisplay *display, + GdkEvent *event); + +gboolean _gdk_quartz_display_send_client_message (GdkDisplay *display, + GdkEvent *event, + GdkNativeWindow winid); +void _gdk_quartz_display_add_client_message_filter (GdkDisplay *display, + GdkAtom message_type, + GdkFilterFunc func, + gpointer data); + +/* Display methods - cursor */ GdkCursor *_gdk_quartz_display_get_cursor_for_type (GdkDisplay *display, GdkCursorType type); GdkCursor *_gdk_quartz_display_get_cursor_for_name (GdkDisplay *display, @@ -151,13 +128,10 @@ void _gdk_quartz_display_get_default_cursor_size (GdkDisplay *display, void _gdk_quartz_display_get_maximal_cursor_size (GdkDisplay *display, guint *width, guint *height); + +/* Display methods - window */ void _gdk_quartz_display_before_process_all_updates (GdkDisplay *display); void _gdk_quartz_display_after_process_all_updates (GdkDisplay *display); -void _gdk_quartz_display_event_data_copy (GdkDisplay *display, - const GdkEvent *src, - GdkEvent *dst); -void _gdk_quartz_display_event_data_free (GdkDisplay *display, - GdkEvent *event); void _gdk_quartz_display_create_window_impl (GdkDisplay *display, GdkWindow *window, GdkWindow *real_parent, @@ -165,101 +139,17 @@ void _gdk_quartz_display_create_window_impl (GdkDisplay *display, GdkEventMask event_mask, GdkWindowAttr *attributes, gint attributes_mask); + +/* Display methods - keymap */ GdkKeymap * _gdk_quartz_display_get_keymap (GdkDisplay *display); - -GdkDisplay * _gdk_quartz_display_open (const gchar *name); - +/* Display methods - Drag and Drop */ GdkNativeWindow _gdk_quartz_display_get_drag_protocol (GdkDisplay *display, GdkNativeWindow xid, GdkDragProtocol *protocol, guint *version); - -gboolean _gdk_quartz_display_send_client_message (GdkDisplay *display, - GdkEvent *event, - GdkNativeWindow winid); -void _gdk_quartz_display_add_client_message_filter (GdkDisplay *display, - GdkAtom message_type, - GdkFilterFunc func, - gpointer data); - -GdkVisual * _gdk_quartz_screen_get_rgba_visual (GdkScreen *screen); -GdkVisual * _gdk_quartz_screen_get_system_visual (GdkScreen *screen); -gint _gdk_quartz_screen_visual_get_best_depth (GdkScreen *screen); -GdkVisualType _gdk_quartz_screen_visual_get_best_type (GdkScreen *screen); -GdkVisual * _gdk_quartz_screen_get_system_visual (GdkScreen *screen); -GdkVisual* _gdk_quartz_screen_visual_get_best (GdkScreen *screen); -GdkVisual* _gdk_quartz_screen_visual_get_best_with_depth (GdkScreen *screen, - gint depth); -GdkVisual* _gdk_quartz_screen_visual_get_best_with_type (GdkScreen *screen, - GdkVisualType visual_type); -GdkVisual* _gdk_quartz_screen_visual_get_best_with_both (GdkScreen *screen, - gint depth, - GdkVisualType visual_type); -void _gdk_quartz_screen_query_depths (GdkScreen *screen, - gint **depths, - gint *count); -void _gdk_quartz_screen_query_visual_types (GdkScreen *screen, - GdkVisualType **visual_types, - gint *count); -void _gdk_quartz_screen_init_visuals (GdkScreen *screen); -GList * _gdk_quartz_screen_list_visuals (GdkScreen *screen); - - -void _gdk_quartz_screen_broadcast_client_message (GdkScreen *screen, - GdkEvent *event); -gboolean _gdk_quartz_screen_get_setting (GdkScreen *screen, - const gchar *name, - GValue *value); - -GdkScreen *_gdk_quartz_screen_new (void); - -GdkAtom _gdk_quartz_display_manager_atom_intern (GdkDisplayManager *manager, - const gchar *atom_name, - gboolean copy_name); -gchar * _gdk_quartz_display_manager_get_atom_name (GdkDisplayManager *manager, - GdkAtom atom); - -void _gdk_quartz_display_manager_add_display (GdkDisplayManager *manager, - GdkDisplay *display); -void _gdk_quartz_display_manager_remove_display (GdkDisplayManager *manager, - GdkDisplay *display); - -void _gdk_quartz_window_sync_rendering (GdkWindow *window); -gboolean _gdk_quartz_window_simulate_key (GdkWindow *window, - gint x, - gint y, - guint keyval, - GdkModifierType modifiers, - GdkEventType key_pressrelease); -gboolean _gdk_quartz_window_simulate_button (GdkWindow *window, - gint x, - gint y, - guint button, - GdkModifierType modifiers, - GdkEventType button_pressrelease); - -gboolean _gdk_quartz_window_get_property (GdkWindow *window, - GdkAtom property, - GdkAtom type, - gulong offset, - gulong length, - gint pdelete, - GdkAtom *actual_property_type, - gint *actual_format_type, - gint *actual_length, - guchar **data); -void _gdk_quartz_window_change_property (GdkWindow *window, - GdkAtom property, - GdkAtom type, - gint format, - GdkPropMode mode, - const guchar *data, - gint nelements); -void _gdk_quartz_window_delete_property (GdkWindow *window, - GdkAtom property); - +/* Display methods - selection */ gboolean _gdk_quartz_display_set_selection_owner (GdkDisplay *display, GdkWindow *owner, GdkAtom selection, @@ -293,4 +183,120 @@ gchar * _gdk_quartz_display_utf8_to_string_target (GdkDisplay *disp const gchar *str); +/* Display manager */ +void _gdk_quartz_display_manager_add_display (GdkDisplayManager *manager, + GdkDisplay *display); +void _gdk_quartz_display_manager_remove_display (GdkDisplayManager *manager, + GdkDisplay *display); + +/* Display manager methods - events */ +GdkAtom _gdk_quartz_display_manager_atom_intern (GdkDisplayManager *manager, + const gchar *atom_name, + gboolean copy_name); +gchar * _gdk_quartz_display_manager_get_atom_name (GdkDisplayManager *manager, + GdkAtom atom); + +/* Screen */ +GdkScreen *_gdk_quartz_screen_new (void); +void _gdk_quartz_screen_update_window_sizes (GdkScreen *screen); + +/* Screen methods - visual */ +GdkVisual * _gdk_quartz_screen_get_rgba_visual (GdkScreen *screen); +GdkVisual * _gdk_quartz_screen_get_system_visual (GdkScreen *screen); +gint _gdk_quartz_screen_visual_get_best_depth (GdkScreen *screen); +GdkVisualType _gdk_quartz_screen_visual_get_best_type (GdkScreen *screen); +GdkVisual * _gdk_quartz_screen_get_system_visual (GdkScreen *screen); +GdkVisual* _gdk_quartz_screen_visual_get_best (GdkScreen *screen); +GdkVisual* _gdk_quartz_screen_visual_get_best_with_depth (GdkScreen *screen, + gint depth); +GdkVisual* _gdk_quartz_screen_visual_get_best_with_type (GdkScreen *screen, + GdkVisualType visual_type); +GdkVisual* _gdk_quartz_screen_visual_get_best_with_both (GdkScreen *screen, + gint depth, + GdkVisualType visual_type); +void _gdk_quartz_screen_query_depths (GdkScreen *screen, + gint **depths, + gint *count); +void _gdk_quartz_screen_query_visual_types (GdkScreen *screen, + GdkVisualType **visual_types, + gint *count); +void _gdk_quartz_screen_init_visuals (GdkScreen *screen); +GList * _gdk_quartz_screen_list_visuals (GdkScreen *screen); + +/* Screen methods - events */ +void _gdk_quartz_screen_broadcast_client_message (GdkScreen *screen, + GdkEvent *event); +gboolean _gdk_quartz_screen_get_setting (GdkScreen *screen, + const gchar *name, + GValue *value); + + +/* Window */ +gboolean _gdk_quartz_window_is_ancestor (GdkWindow *ancestor, + GdkWindow *window); +void _gdk_quartz_window_gdk_xy_to_xy (gint gdk_x, + gint gdk_y, + gint *ns_x, + gint *ns_y); +void _gdk_quartz_window_xy_to_gdk_xy (gint ns_x, + gint ns_y, + gint *gdk_x, + gint *gdk_y); +void _gdk_quartz_window_nspoint_to_gdk_xy (NSPoint point, + gint *x, + gint *y); +GdkWindow *_gdk_quartz_window_find_child (GdkWindow *window, + gint x, + gint y, + gboolean get_toplevel); +void _gdk_quartz_window_attach_to_parent (GdkWindow *window); +void _gdk_quartz_window_detach_from_parent (GdkWindow *window); +void _gdk_quartz_window_did_become_main (GdkWindow *window); +void _gdk_quartz_window_did_resign_main (GdkWindow *window); +void _gdk_quartz_window_debug_highlight (GdkWindow *window, + gint number); + +void _gdk_quartz_window_set_needs_display_in_region (GdkWindow *window, + cairo_region_t *region); + +void _gdk_quartz_window_update_position (GdkWindow *window); + + +/* Window methods - testing */ +void _gdk_quartz_window_sync_rendering (GdkWindow *window); +gboolean _gdk_quartz_window_simulate_key (GdkWindow *window, + gint x, + gint y, + guint keyval, + GdkModifierType modifiers, + GdkEventType key_pressrelease); +gboolean _gdk_quartz_window_simulate_button (GdkWindow *window, + gint x, + gint y, + guint button, + GdkModifierType modifiers, + GdkEventType button_pressrelease); + +/* Window methods - property */ +gboolean _gdk_quartz_window_get_property (GdkWindow *window, + GdkAtom property, + GdkAtom type, + gulong offset, + gulong length, + gint pdelete, + GdkAtom *actual_property_type, + gint *actual_format_type, + gint *actual_length, + guchar **data); +void _gdk_quartz_window_change_property (GdkWindow *window, + GdkAtom property, + GdkAtom type, + gint format, + GdkPropMode mode, + const guchar *data, + gint nelements); +void _gdk_quartz_window_delete_property (GdkWindow *window, + GdkAtom property); + + #endif /* __GDK_PRIVATE_QUARTZ_H__ */ diff --git a/gdk/quartz/gdkscreen-quartz.c b/gdk/quartz/gdkscreen-quartz.c index 192fd970bf..678a947243 100644 --- a/gdk/quartz/gdkscreen-quartz.c +++ b/gdk/quartz/gdkscreen-quartz.c @@ -184,6 +184,36 @@ gdk_quartz_screen_calculate_layout (GdkQuartzScreen *screen) GDK_QUARTZ_RELEASE_POOL; } +void +_gdk_quartz_screen_update_window_sizes (GdkScreen *screen) +{ + GList *windows, *list; + + /* The size of the root window is so that it can contain all + * monitors attached to this machine. The monitors are laid out + * within this root window. We calculate the size of the root window + * and the positions of the different monitors in gdkscreen-quartz.c. + * + * This data is updated when the monitor configuration is changed. + */ + + /* FIXME: At some point, fetch the root window from GdkScreen. But + * on OS X will we only have a single root window anyway. + */ + _gdk_root->x = 0; + _gdk_root->y = 0; + _gdk_root->abs_x = 0; + _gdk_root->abs_y = 0; + _gdk_root->width = gdk_screen_get_width (screen); + _gdk_root->height = gdk_screen_get_height (screen); + + windows = gdk_screen_get_toplevel_windows (screen); + + for (list = windows; list; list = list->next) + _gdk_quartz_window_update_position (list->data); + + g_list_free (windows); +} static void process_display_reconfiguration (GdkQuartzScreen *screen) @@ -195,7 +225,7 @@ process_display_reconfiguration (GdkQuartzScreen *screen) gdk_quartz_screen_calculate_layout (GDK_QUARTZ_SCREEN (screen)); - _gdk_windowing_update_window_sizes (GDK_SCREEN (screen)); + _gdk_quartz_screen_update_window_sizes (GDK_SCREEN (screen)); if (screen->emit_monitors_changed) { diff --git a/gdk/quartz/gdkwindow-quartz.c b/gdk/quartz/gdkwindow-quartz.c index bdcc5a81b1..a9655b2947 100644 --- a/gdk/quartz/gdkwindow-quartz.c +++ b/gdk/quartz/gdkwindow-quartz.c @@ -1043,48 +1043,22 @@ _gdk_quartz_window_update_position (GdkWindow *window) } void -_gdk_windowing_update_window_sizes (GdkScreen *screen) -{ - GList *windows, *list; - - /* The size of the root window is so that it can contain all - * monitors attached to this machine. The monitors are laid out - * within this root window. We calculate the size of the root window - * and the positions of the different monitors in gdkscreen-quartz.c. - * - * This data is updated when the monitor configuration is changed. - */ - _gdk_root->x = 0; - _gdk_root->y = 0; - _gdk_root->abs_x = 0; - _gdk_root->abs_y = 0; - _gdk_root->width = gdk_screen_get_width (screen); - _gdk_root->height = gdk_screen_get_height (screen); - - windows = gdk_screen_get_toplevel_windows (screen); - - for (list = windows; list; list = list->next) - _gdk_quartz_window_update_position (list->data); - - g_list_free (windows); -} - -void -_gdk_windowing_window_init (void) +_gdk_quartz_window_init_windowing (GdkDisplay *display, + GdkScreen *screen) { GdkWindowImplQuartz *impl; g_assert (_gdk_root == NULL); - _gdk_root = _gdk_display_create_window (_gdk_display); + _gdk_root = _gdk_display_create_window (display); _gdk_root->impl = g_object_new (_gdk_root_window_impl_quartz_get_type (), NULL); _gdk_root->impl_window = _gdk_root; - _gdk_root->visual = gdk_screen_get_system_visual (_gdk_screen); + _gdk_root->visual = gdk_screen_get_system_visual (screen); impl = GDK_WINDOW_IMPL_QUARTZ (_gdk_root->impl); - _gdk_windowing_update_window_sizes (_gdk_screen); + _gdk_quartz_screen_update_window_sizes (screen); _gdk_root->state = 0; /* We don't want GDK_WINDOW_STATE_WITHDRAWN here */ _gdk_root->window_type = GDK_WINDOW_ROOT;