From 806d5939e34422e65e5a28451bc98124253e070f Mon Sep 17 00:00:00 2001 From: Giovanni Campagna Date: Fri, 30 Aug 2013 18:03:30 +0200 Subject: [PATCH] wayland: split headers and distribute structure definitions Instead of having all structures in one huge headers, move them in the appropriate place, and create one header for surface state. https://bugzilla.gnome.org/show_bug.cgi?id=707128 --- src/Makefile.am | 2 + src/core/window-private.h | 10 +- src/wayland/meta-wayland-data-device.c | 1 + src/wayland/meta-wayland-keyboard.c | 2 +- src/wayland/meta-wayland-keyboard.h | 73 +++++++- src/wayland/meta-wayland-pointer.c | 1 + src/wayland/meta-wayland-pointer.h | 46 ++++- src/wayland/meta-wayland-private.h | 242 +------------------------ src/wayland/meta-wayland-seat.h | 59 +++++- src/wayland/meta-wayland-stage.c | 1 + src/wayland/meta-wayland-surface.h | 90 +++++++++ src/wayland/meta-wayland-types.h | 40 ++++ 12 files changed, 315 insertions(+), 252 deletions(-) create mode 100644 src/wayland/meta-wayland-surface.h create mode 100644 src/wayland/meta-wayland-types.h diff --git a/src/Makefile.am b/src/Makefile.am index a2648f8d5..0a7bc3704 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -196,6 +196,8 @@ libmutter_wayland_la_SOURCES += \ wayland/meta-wayland-seat.h \ wayland/meta-wayland-stage.h \ wayland/meta-wayland-stage.c \ + wayland/meta-wayland-surface.h \ + wayland/meta-wayland-types.h \ wayland/meta-weston-launch.c \ wayland/meta-weston-launch.h diff --git a/src/core/window-private.h b/src/core/window-private.h index c54036bed..f7769d091 100644 --- a/src/core/window-private.h +++ b/src/core/window-private.h @@ -44,15 +44,7 @@ #include #include #include -#include "meta-wayland-private.h" - -/* XXX: We should find a nicer approach to deal with the - * circular dependency we have with the current headers - * (meta-wayland-private.h which typedefs MetaWaylandSurface - * also includes window-private.h) */ -#ifndef HAVE_META_WAYLAND_SURFACE_TYPE -typedef struct _MetaWaylandSurface MetaWaylandSurface; -#endif +#include "meta-wayland-types.h" typedef struct _MetaWindowQueue MetaWindowQueue; diff --git a/src/wayland/meta-wayland-data-device.c b/src/wayland/meta-wayland-data-device.c index d976352df..f578f00f6 100644 --- a/src/wayland/meta-wayland-data-device.c +++ b/src/wayland/meta-wayland-data-device.c @@ -33,6 +33,7 @@ #include "meta-wayland-data-device.h" #include "meta-wayland-seat.h" #include "meta-wayland-pointer.h" +#include "meta-wayland-private.h" static void data_offer_accept (struct wl_client *client, diff --git a/src/wayland/meta-wayland-keyboard.c b/src/wayland/meta-wayland-keyboard.c index ef7c2071f..466b4386d 100644 --- a/src/wayland/meta-wayland-keyboard.c +++ b/src/wayland/meta-wayland-keyboard.c @@ -58,7 +58,7 @@ #include #include -#include "meta-wayland-keyboard.h" +#include "meta-wayland-private.h" static MetaWaylandSeat * meta_wayland_keyboard_get_seat (MetaWaylandKeyboard *keyboard) diff --git a/src/wayland/meta-wayland-keyboard.h b/src/wayland/meta-wayland-keyboard.h index 57d7a878b..4ea124dc8 100644 --- a/src/wayland/meta-wayland-keyboard.h +++ b/src/wayland/meta-wayland-keyboard.h @@ -48,7 +48,78 @@ #include #include -#include "meta-wayland-seat.h" +struct _MetaWaylandKeyboardGrabInterface +{ + void (*key) (MetaWaylandKeyboardGrab * grab, uint32_t time, + uint32_t key, uint32_t state); + void (*modifiers) (MetaWaylandKeyboardGrab * grab, uint32_t serial, + uint32_t mods_depressed, uint32_t mods_latched, + uint32_t mods_locked, uint32_t group); +}; + +struct _MetaWaylandKeyboardGrab +{ + const MetaWaylandKeyboardGrabInterface *interface; + MetaWaylandKeyboard *keyboard; + MetaWaylandSurface *focus; + uint32_t key; +}; + +typedef struct +{ + struct xkb_keymap *keymap; + int keymap_fd; + size_t keymap_size; + char *keymap_area; + xkb_mod_index_t shift_mod; + xkb_mod_index_t caps_mod; + xkb_mod_index_t ctrl_mod; + xkb_mod_index_t alt_mod; + xkb_mod_index_t mod2_mod; + xkb_mod_index_t mod3_mod; + xkb_mod_index_t super_mod; + xkb_mod_index_t mod5_mod; +} MetaWaylandXkbInfo; + +typedef struct +{ + uint32_t mods_depressed; + uint32_t mods_latched; + uint32_t mods_locked; + uint32_t group; +} MetaWaylandXkbState; + +struct _MetaWaylandKeyboard +{ + struct wl_list resource_list; + MetaWaylandSurface *focus; + struct wl_resource *focus_resource; + struct wl_listener focus_listener; + uint32_t focus_serial; + struct wl_signal focus_signal; + + MetaWaylandKeyboardGrab *grab; + MetaWaylandKeyboardGrab default_grab; + uint32_t grab_key; + uint32_t grab_serial; + uint32_t grab_time; + + struct wl_array keys; + + MetaWaylandXkbState modifier_state; + + struct wl_display *display; + + struct xkb_context *xkb_context; + struct xkb_state *xkb_state; + gboolean is_evdev; + + MetaWaylandXkbInfo xkb_info; + struct xkb_rule_names xkb_names; + + MetaWaylandKeyboardGrab input_method_grab; + struct wl_resource *input_method_resource; +}; gboolean meta_wayland_keyboard_init (MetaWaylandKeyboard *keyboard, diff --git a/src/wayland/meta-wayland-pointer.c b/src/wayland/meta-wayland-pointer.c index f6c23d049..aaa003e56 100644 --- a/src/wayland/meta-wayland-pointer.c +++ b/src/wayland/meta-wayland-pointer.c @@ -44,6 +44,7 @@ #include "config.h" #include "meta-wayland-pointer.h" +#include "meta-wayland-private.h" #include diff --git a/src/wayland/meta-wayland-pointer.h b/src/wayland/meta-wayland-pointer.h index 491cdbcc7..7ab3bd3c3 100644 --- a/src/wayland/meta-wayland-pointer.h +++ b/src/wayland/meta-wayland-pointer.h @@ -22,7 +22,51 @@ #include -#include "meta-wayland-seat.h" +#include + +#include "meta-wayland-types.h" + +struct _MetaWaylandPointerGrabInterface +{ + void (*focus) (MetaWaylandPointerGrab * grab, + MetaWaylandSurface * surface, wl_fixed_t x, wl_fixed_t y); + void (*motion) (MetaWaylandPointerGrab * grab, + uint32_t time, wl_fixed_t x, wl_fixed_t y); + void (*button) (MetaWaylandPointerGrab * grab, + uint32_t time, uint32_t button, uint32_t state); +}; + +struct _MetaWaylandPointerGrab +{ + const MetaWaylandPointerGrabInterface *interface; + MetaWaylandPointer *pointer; + MetaWaylandSurface *focus; + wl_fixed_t x, y; +}; + +struct _MetaWaylandPointer +{ + struct wl_list resource_list; + MetaWaylandSurface *focus; + struct wl_resource *focus_resource; + struct wl_listener focus_listener; + guint32 focus_serial; + struct wl_signal focus_signal; + + MetaWaylandPointerGrab *grab; + MetaWaylandPointerGrab default_grab; + wl_fixed_t grab_x, grab_y; + guint32 grab_button; + guint32 grab_serial; + guint32 grab_time; + + wl_fixed_t x, y; + MetaWaylandSurface *current; + struct wl_listener current_listener; + wl_fixed_t current_x, current_y; + + guint32 button_count; +}; void meta_wayland_pointer_init (MetaWaylandPointer *pointer); diff --git a/src/wayland/meta-wayland-private.h b/src/wayland/meta-wayland-private.h index 7ee11a1b9..ebc066b60 100644 --- a/src/wayland/meta-wayland-private.h +++ b/src/wayland/meta-wayland-private.h @@ -31,33 +31,9 @@ #include "meta-weston-launch.h" #include -typedef struct _MetaWaylandCompositor MetaWaylandCompositor; - -typedef struct _MetaWaylandSeat MetaWaylandSeat; -typedef struct _MetaWaylandPointer MetaWaylandPointer; -typedef struct _MetaWaylandPointerGrab MetaWaylandPointerGrab; -typedef struct _MetaWaylandPointerGrabInterface MetaWaylandPointerGrabInterface; -typedef struct _MetaWaylandKeyboard MetaWaylandKeyboard; -typedef struct _MetaWaylandKeyboardGrab MetaWaylandKeyboardGrab; -typedef struct _MetaWaylandKeyboardGrabInterface MetaWaylandKeyboardGrabInterface; -typedef struct _MetaWaylandDataOffer MetaWaylandDataOffer; -typedef struct _MetaWaylandDataSource MetaWaylandDataSource; - -typedef struct -{ - struct wl_resource *resource; - struct wl_signal destroy_signal; - struct wl_listener destroy_listener; - - int32_t width, height; - uint32_t busy_count; -} MetaWaylandBuffer; - -typedef struct -{ - MetaWaylandBuffer *buffer; - struct wl_listener destroy_listener; -} MetaWaylandBufferReference; +#include "meta-wayland-types.h" +#include "meta-wayland-surface.h" +#include "meta-wayland-seat.h" typedef struct { @@ -65,49 +41,6 @@ typedef struct cairo_region_t *region; } MetaWaylandRegion; -struct _MetaWaylandSurface -{ - struct wl_resource *resource; - MetaWaylandCompositor *compositor; - guint32 xid; - int x; - int y; - MetaWaylandBufferReference buffer_ref; - MetaWindow *window; - gboolean has_shell_surface; - - /* All the pending state, that wl_surface.commit will apply. */ - struct - { - /* wl_surface.attach */ - gboolean newly_attached; - MetaWaylandBuffer *buffer; - struct wl_listener buffer_destroy_listener; - int32_t sx; - int32_t sy; - - /* wl_surface.damage */ - cairo_region_t *damage; - - cairo_region_t *input_region; - cairo_region_t *opaque_region; - - /* wl_surface.frame */ - struct wl_list frame_callback_list; - } pending; -}; - -#ifndef HAVE_META_WAYLAND_SURFACE_TYPE -typedef struct _MetaWaylandSurface MetaWaylandSurface; -#endif - -typedef struct -{ - MetaWaylandSurface *surface; - struct wl_resource *resource; - struct wl_listener surface_destroy_listener; -} MetaWaylandSurfaceExtension; - typedef struct { GSource source; @@ -158,175 +91,6 @@ struct _MetaWaylandCompositor guint32 implicit_grab_button; }; -struct _MetaWaylandPointerGrabInterface -{ - void (*focus) (MetaWaylandPointerGrab * grab, - MetaWaylandSurface * surface, wl_fixed_t x, wl_fixed_t y); - void (*motion) (MetaWaylandPointerGrab * grab, - uint32_t time, wl_fixed_t x, wl_fixed_t y); - void (*button) (MetaWaylandPointerGrab * grab, - uint32_t time, uint32_t button, uint32_t state); -}; - -struct _MetaWaylandPointerGrab -{ - const MetaWaylandPointerGrabInterface *interface; - MetaWaylandPointer *pointer; - MetaWaylandSurface *focus; - wl_fixed_t x, y; -}; - -struct _MetaWaylandPointer -{ - struct wl_list resource_list; - MetaWaylandSurface *focus; - struct wl_resource *focus_resource; - struct wl_listener focus_listener; - guint32 focus_serial; - struct wl_signal focus_signal; - - MetaWaylandPointerGrab *grab; - MetaWaylandPointerGrab default_grab; - wl_fixed_t grab_x, grab_y; - guint32 grab_button; - guint32 grab_serial; - guint32 grab_time; - - wl_fixed_t x, y; - MetaWaylandSurface *current; - struct wl_listener current_listener; - wl_fixed_t current_x, current_y; - - guint32 button_count; -}; - -struct _MetaWaylandKeyboardGrabInterface -{ - void (*key) (MetaWaylandKeyboardGrab * grab, uint32_t time, - uint32_t key, uint32_t state); - void (*modifiers) (MetaWaylandKeyboardGrab * grab, uint32_t serial, - uint32_t mods_depressed, uint32_t mods_latched, - uint32_t mods_locked, uint32_t group); -}; - -struct _MetaWaylandKeyboardGrab -{ - const MetaWaylandKeyboardGrabInterface *interface; - MetaWaylandKeyboard *keyboard; - MetaWaylandSurface *focus; - uint32_t key; -}; - -typedef struct -{ - struct xkb_keymap *keymap; - int keymap_fd; - size_t keymap_size; - char *keymap_area; - xkb_mod_index_t shift_mod; - xkb_mod_index_t caps_mod; - xkb_mod_index_t ctrl_mod; - xkb_mod_index_t alt_mod; - xkb_mod_index_t mod2_mod; - xkb_mod_index_t mod3_mod; - xkb_mod_index_t super_mod; - xkb_mod_index_t mod5_mod; -} MetaWaylandXkbInfo; - -typedef struct -{ - uint32_t mods_depressed; - uint32_t mods_latched; - uint32_t mods_locked; - uint32_t group; -} MetaWaylandXkbState; - -struct _MetaWaylandKeyboard -{ - struct wl_list resource_list; - MetaWaylandSurface *focus; - struct wl_resource *focus_resource; - struct wl_listener focus_listener; - uint32_t focus_serial; - struct wl_signal focus_signal; - - MetaWaylandKeyboardGrab *grab; - MetaWaylandKeyboardGrab default_grab; - uint32_t grab_key; - uint32_t grab_serial; - uint32_t grab_time; - - struct wl_array keys; - - MetaWaylandXkbState modifier_state; - - struct wl_display *display; - - struct xkb_context *xkb_context; - struct xkb_state *xkb_state; - gboolean is_evdev; - - MetaWaylandXkbInfo xkb_info; - struct xkb_rule_names xkb_names; - - MetaWaylandKeyboardGrab input_method_grab; - struct wl_resource *input_method_resource; -}; - -struct _MetaWaylandDataOffer -{ - struct wl_resource *resource; - MetaWaylandDataSource *source; - struct wl_listener source_destroy_listener; -}; - -struct _MetaWaylandDataSource -{ - struct wl_resource *resource; - struct wl_array mime_types; - - void (*accept) (MetaWaylandDataSource * source, - uint32_t serial, const char *mime_type); - void (*send) (MetaWaylandDataSource * source, - const char *mime_type, int32_t fd); - void (*cancel) (MetaWaylandDataSource * source); -}; - -struct _MetaWaylandSeat -{ - struct wl_list base_resource_list; - struct wl_signal destroy_signal; - - uint32_t selection_serial; - MetaWaylandDataSource *selection_data_source; - struct wl_listener selection_data_source_listener; - struct wl_signal selection_signal; - - struct wl_list drag_resource_list; - struct wl_client *drag_client; - MetaWaylandDataSource *drag_data_source; - struct wl_listener drag_data_source_listener; - MetaWaylandSurface *drag_focus; - struct wl_resource *drag_focus_resource; - struct wl_listener drag_focus_listener; - MetaWaylandPointerGrab drag_grab; - MetaWaylandSurface *drag_surface; - struct wl_listener drag_icon_listener; - struct wl_signal drag_icon_signal; - - MetaWaylandPointer pointer; - MetaWaylandKeyboard keyboard; - - struct wl_display *display; - - MetaCursorTracker *cursor_tracker; - MetaWaylandSurface *sprite; - int hotspot_x, hotspot_y; - struct wl_listener sprite_destroy_listener; - - ClutterActor *current_stage; -}; - void meta_wayland_init (void); void meta_wayland_finalize (void); diff --git a/src/wayland/meta-wayland-seat.h b/src/wayland/meta-wayland-seat.h index d5a05976f..a8e6d2e5c 100644 --- a/src/wayland/meta-wayland-seat.h +++ b/src/wayland/meta-wayland-seat.h @@ -27,7 +27,64 @@ #include #include -#include "meta-wayland-private.h" +#include +#include "meta-wayland-types.h" +#include "meta-wayland-keyboard.h" +#include "meta-wayland-pointer.h" + +struct _MetaWaylandDataOffer +{ + struct wl_resource *resource; + MetaWaylandDataSource *source; + struct wl_listener source_destroy_listener; +}; + +struct _MetaWaylandDataSource +{ + struct wl_resource *resource; + struct wl_array mime_types; + + void (*accept) (MetaWaylandDataSource * source, + uint32_t serial, const char *mime_type); + void (*send) (MetaWaylandDataSource * source, + const char *mime_type, int32_t fd); + void (*cancel) (MetaWaylandDataSource * source); +}; + +struct _MetaWaylandSeat +{ + struct wl_list base_resource_list; + struct wl_signal destroy_signal; + + uint32_t selection_serial; + MetaWaylandDataSource *selection_data_source; + struct wl_listener selection_data_source_listener; + struct wl_signal selection_signal; + + struct wl_list drag_resource_list; + struct wl_client *drag_client; + MetaWaylandDataSource *drag_data_source; + struct wl_listener drag_data_source_listener; + MetaWaylandSurface *drag_focus; + struct wl_resource *drag_focus_resource; + struct wl_listener drag_focus_listener; + MetaWaylandPointerGrab drag_grab; + MetaWaylandSurface *drag_surface; + struct wl_listener drag_icon_listener; + struct wl_signal drag_icon_signal; + + MetaWaylandPointer pointer; + MetaWaylandKeyboard keyboard; + + struct wl_display *display; + + MetaCursorTracker *cursor_tracker; + MetaWaylandSurface *sprite; + int hotspot_x, hotspot_y; + struct wl_listener sprite_destroy_listener; + + ClutterActor *current_stage; +}; MetaWaylandSeat * meta_wayland_seat_new (struct wl_display *display, diff --git a/src/wayland/meta-wayland-stage.c b/src/wayland/meta-wayland-stage.c index 48fe8e754..16cb753a6 100644 --- a/src/wayland/meta-wayland-stage.c +++ b/src/wayland/meta-wayland-stage.c @@ -26,6 +26,7 @@ #include #include "meta-wayland-stage.h" +#include "meta-wayland-private.h" #include "meta/meta-window-actor.h" #include "meta/meta-shaped-texture.h" #include "meta-cursor-tracker-private.h" diff --git a/src/wayland/meta-wayland-surface.h b/src/wayland/meta-wayland-surface.h new file mode 100644 index 000000000..ec6f84951 --- /dev/null +++ b/src/wayland/meta-wayland-surface.h @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2013 Red Hat, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifndef META_WAYLAND_SURFACE_H +#define META_WAYLAND_SURFACE_H + +#include +#include +#include + +#include +#include + +#include +#include "meta-wayland-types.h" + +struct _MetaWaylandBuffer +{ + struct wl_resource *resource; + struct wl_signal destroy_signal; + struct wl_listener destroy_listener; + + int32_t width, height; + uint32_t busy_count; +}; + +struct _MetaWaylandBufferReference +{ + MetaWaylandBuffer *buffer; + struct wl_listener destroy_listener; +}; + +typedef struct +{ + /* wl_surface.attach */ + gboolean newly_attached; + MetaWaylandBuffer *buffer; + struct wl_listener buffer_destroy_listener; + int32_t sx; + int32_t sy; + + /* wl_surface.damage */ + cairo_region_t *damage; + + cairo_region_t *input_region; + cairo_region_t *opaque_region; + + /* wl_surface.frame */ + struct wl_list frame_callback_list; +} MetaWaylandDoubleBufferedState; + +struct _MetaWaylandSurface +{ + struct wl_resource *resource; + MetaWaylandCompositor *compositor; + guint32 xid; + int x; + int y; + MetaWaylandBufferReference buffer_ref; + MetaWindow *window; + gboolean has_shell_surface; + + /* All the pending state, that wl_surface.commit will apply. */ + MetaWaylandDoubleBufferedState pending; +}; + +typedef struct +{ + MetaWaylandSurface *surface; + struct wl_resource *resource; + struct wl_listener surface_destroy_listener; +} MetaWaylandSurfaceExtension; + +#endif diff --git a/src/wayland/meta-wayland-types.h b/src/wayland/meta-wayland-types.h new file mode 100644 index 000000000..adecb057d --- /dev/null +++ b/src/wayland/meta-wayland-types.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2013 Red Hat, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifndef META_WAYLAND_TYPES_H +#define META_WAYLAND_TYPES_H + +typedef struct _MetaWaylandCompositor MetaWaylandCompositor; + +typedef struct _MetaWaylandSeat MetaWaylandSeat; +typedef struct _MetaWaylandPointer MetaWaylandPointer; +typedef struct _MetaWaylandPointerGrab MetaWaylandPointerGrab; +typedef struct _MetaWaylandPointerGrabInterface MetaWaylandPointerGrabInterface; +typedef struct _MetaWaylandKeyboard MetaWaylandKeyboard; +typedef struct _MetaWaylandKeyboardGrab MetaWaylandKeyboardGrab; +typedef struct _MetaWaylandKeyboardGrabInterface MetaWaylandKeyboardGrabInterface; +typedef struct _MetaWaylandDataOffer MetaWaylandDataOffer; +typedef struct _MetaWaylandDataSource MetaWaylandDataSource; + +typedef struct _MetaWaylandBuffer MetaWaylandBuffer; +typedef struct _MetaWaylandBufferReference MetaWaylandBufferReference; + +typedef struct _MetaWaylandSurface MetaWaylandSurface; + +#endif