diff --git a/clutter/clutter/cally/cally-actor.h b/clutter/clutter/cally/cally-actor.h index f67bcafb2..ebf096262 100644 --- a/clutter/clutter/cally/cally-actor.h +++ b/clutter/clutter/cally/cally-actor.h @@ -89,8 +89,6 @@ struct _CallyActor /** * CallyActorClass: * @notify_clutter: Signal handler for notify signal on Clutter actor - * @focus_clutter: Signal handler for key-focus-in and key-focus-out - * signal on Clutter actor. This virtual functions is deprecated. * @add_actor: Signal handler for actor-added signal on * ClutterContainer interface * @remove_actor: Signal handler for actor-added signal on @@ -110,9 +108,6 @@ struct _CallyActorClass void (*notify_clutter) (GObject *object, GParamSpec *pspec); - gboolean (*focus_clutter) (ClutterActor *actor, - gpointer data); - gint (*add_actor) (ClutterActor *container, ClutterActor *actor, gpointer data); diff --git a/src/core/window-private.h b/src/core/window-private.h index f80f1c752..7ad6e5400 100644 --- a/src/core/window-private.h +++ b/src/core/window-private.h @@ -518,8 +518,8 @@ struct _MetaWindow * For X11 windows, this matches XGetGeometry of the toplevel. * * For Wayland windows, the position matches the position of the - * surface associated with shell surface (wl_shell_surface, xdg_surface - * etc). The size matches the size surface size as displayed in the stage. + * surface associated with shell surface (xdg_surface etc). + * The size matches the size surface size as displayed in the stage. */ MetaRectangle buffer_rect; diff --git a/src/meson.build b/src/meson.build index 193472bd2..388315b43 100644 --- a/src/meson.build +++ b/src/meson.build @@ -500,20 +500,14 @@ if have_wayland 'wayland/meta-wayland-data-device.h', 'wayland/meta-wayland-data-device-primary.c', 'wayland/meta-wayland-data-device-primary.h', - 'wayland/meta-wayland-data-device-primary-legacy.c', - 'wayland/meta-wayland-data-device-primary-legacy.h', 'wayland/meta-wayland-data-offer.c', 'wayland/meta-wayland-data-offer.h', 'wayland/meta-wayland-data-offer-primary.c', 'wayland/meta-wayland-data-offer-primary.h', - 'wayland/meta-wayland-data-offer-primary-legacy.c', - 'wayland/meta-wayland-data-offer-primary-legacy.h', 'wayland/meta-wayland-data-source.c', 'wayland/meta-wayland-data-source.h', 'wayland/meta-wayland-data-source-primary.c', 'wayland/meta-wayland-data-source-primary.h', - 'wayland/meta-wayland-data-source-primary-legacy.c', - 'wayland/meta-wayland-data-source-primary-legacy.h', 'wayland/meta-wayland-dma-buf.c', 'wayland/meta-wayland-dma-buf.h', 'wayland/meta-wayland-dnd-surface.c', @@ -529,8 +523,6 @@ if have_wayland 'wayland/meta-wayland-input-device.h', 'wayland/meta-wayland-keyboard.c', 'wayland/meta-wayland-keyboard.h', - 'wayland/meta-wayland-legacy-xdg-shell.c', - 'wayland/meta-wayland-legacy-xdg-shell.h', 'wayland/meta-wayland-outputs.c', 'wayland/meta-wayland-outputs.h', 'wayland/meta-wayland-pointer.c', @@ -576,8 +568,6 @@ if have_wayland 'wayland/meta-wayland-tablet-tool.h', 'wayland/meta-wayland-text-input.c', 'wayland/meta-wayland-text-input.h', - 'wayland/meta-wayland-text-input-legacy.c', - 'wayland/meta-wayland-text-input-legacy.h', 'wayland/meta-wayland-touch.c', 'wayland/meta-wayland-touch.h', 'wayland/meta-wayland-types.h', @@ -586,8 +576,6 @@ if have_wayland 'wayland/meta-wayland-viewporter.h', 'wayland/meta-wayland-window-configuration.c', 'wayland/meta-wayland-window-configuration.h', - 'wayland/meta-wayland-wl-shell.c', - 'wayland/meta-wayland-wl-shell.h', 'wayland/meta-wayland-xdg-foreign.c', 'wayland/meta-wayland-xdg-foreign.h', 'wayland/meta-wayland-xdg-shell.c', @@ -801,9 +789,7 @@ if have_wayland # - protocol stability ('private', 'stable' or 'unstable') # - protocol version (if stability is 'unstable') wayland_protocols = [ - ['gtk-primary-selection', 'private', ], ['gtk-shell', 'private', ], - ['gtk-text-input', 'private', ], ['keyboard-shortcuts-inhibit', 'unstable', 'v1', ], ['linux-dmabuf', 'unstable', 'v1', ], ['pointer-constraints', 'unstable', 'v1', ], @@ -815,7 +801,6 @@ if have_wayland ['viewporter', 'stable', ], ['xdg-foreign', 'unstable', 'v1', ], ['xdg-output', 'unstable', 'v1', ], - ['xdg-shell', 'unstable', 'v6', ], ['xdg-shell', 'stable', ], ['xwayland-keyboard-grab', 'unstable', 'v1', ], ] diff --git a/src/wayland/meta-wayland-data-device-primary-legacy.c b/src/wayland/meta-wayland-data-device-primary-legacy.c deleted file mode 100644 index 2c5304c5f..000000000 --- a/src/wayland/meta-wayland-data-device-primary-legacy.c +++ /dev/null @@ -1,354 +0,0 @@ -/* - * Copyright © 2011 Kristian Høgsberg - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that copyright - * notice and this permission notice appear in supporting documentation, and - * that the name of the copyright holders not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. The copyright holders make no representations - * about the suitability of this software for any purpose. It is provided "as - * is" without express or implied warranty. - * - * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* The file is based on src/data-device.c from Weston */ - -#include "config.h" - -#include "wayland/meta-wayland-data-device-primary-legacy.h" - -#include "compositor/meta-dnd-actor-private.h" -#include "meta/meta-selection-source-memory.h" -#include "wayland/meta-selection-source-wayland-private.h" -#include "wayland/meta-wayland-data-offer-primary-legacy.h" -#include "wayland/meta-wayland-data-source-primary-legacy.h" -#include "wayland/meta-wayland-dnd-surface.h" -#include "wayland/meta-wayland-pointer.h" -#include "wayland/meta-wayland-private.h" -#include "wayland/meta-wayland-seat.h" - -#include "gtk-primary-selection-server-protocol.h" - -static struct wl_resource * create_and_send_primary_offer (MetaWaylandDataDevicePrimaryLegacy *data_device, - struct wl_resource *target); - -static void -move_resources (struct wl_list *destination, - struct wl_list *source) -{ - wl_list_insert_list (destination, source); - wl_list_init (source); -} - -static void -move_resources_for_client (struct wl_list *destination, - struct wl_list *source, - struct wl_client *client) -{ - struct wl_resource *resource, *tmp; - wl_resource_for_each_safe (resource, tmp, source) - { - if (wl_resource_get_client (resource) == client) - { - wl_list_remove (wl_resource_get_link (resource)); - wl_list_insert (destination, wl_resource_get_link (resource)); - } - } -} - -static void -unbind_resource (struct wl_resource *resource) -{ - wl_list_remove (wl_resource_get_link (resource)); -} - -static void -default_destructor (struct wl_client *client, - struct wl_resource *resource) -{ - wl_resource_destroy (resource); -} - -static void -set_selection_source (MetaWaylandDataDevicePrimaryLegacy *data_device, - MetaSelectionSource *selection_source) - -{ - MetaDisplay *display = meta_get_display (); - - meta_selection_set_owner (meta_display_get_selection (display), - META_SELECTION_PRIMARY, - selection_source); - g_set_object (&data_device->owner, selection_source); -} - -static void -unset_selection_source (MetaWaylandDataDevicePrimaryLegacy *data_device) -{ - MetaDisplay *display = meta_get_display (); - - if (!data_device->owner) - return; - - meta_selection_unset_owner (meta_display_get_selection (display), - META_SELECTION_PRIMARY, - data_device->owner); - g_clear_object (&data_device->owner); -} - -static void -primary_source_destroyed (gpointer data, - GObject *object_was_here) -{ - MetaWaylandDataDevicePrimaryLegacy *data_device = data; - - data_device->data_source = NULL; - unset_selection_source (data_device); -} - -static void -meta_wayland_data_device_primary_legacy_set_selection (MetaWaylandDataDevicePrimaryLegacy *data_device, - MetaWaylandDataSource *source, - uint32_t serial) -{ - MetaWaylandSeat *seat = wl_container_of (data_device, seat, primary_legacy_data_device); - MetaSelectionSource *selection_source; - - g_assert (!source || META_IS_WAYLAND_DATA_SOURCE_PRIMARY_LEGACY (source)); - - if (data_device->data_source && - data_device->serial - serial < UINT32_MAX / 2) - return; - - if (data_device->data_source) - { - g_object_weak_unref (G_OBJECT (data_device->data_source), - primary_source_destroyed, - data_device); - } - - data_device->data_source = source; - data_device->serial = serial; - - if (source) - { - meta_wayland_data_source_set_seat (source, seat); - g_object_weak_ref (G_OBJECT (source), - primary_source_destroyed, - data_device); - - selection_source = meta_selection_source_wayland_new (source); - } - else - { - selection_source = g_object_new (META_TYPE_SELECTION_SOURCE_MEMORY, NULL); - } - - set_selection_source (data_device, selection_source); - g_object_unref (selection_source); -} - -static void -primary_device_set_selection (struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *source_resource, - uint32_t serial) -{ - MetaWaylandDataDevicePrimaryLegacy *data_device = wl_resource_get_user_data (resource); - MetaWaylandSeat *seat = wl_container_of (data_device, seat, primary_legacy_data_device); - MetaWaylandDataSource *source = NULL; - - if (source_resource) - source = wl_resource_get_user_data (source_resource); - - if (wl_resource_get_client (resource) != - meta_wayland_keyboard_get_focus_client (seat->keyboard)) - return; - - meta_wayland_data_device_primary_legacy_set_selection (data_device, source, serial); -} - -static const struct gtk_primary_selection_device_interface primary_device_interface = { - primary_device_set_selection, - default_destructor, -}; - -static void -owner_changed_cb (MetaSelection *selection, - MetaSelectionType selection_type, - MetaSelectionSource *new_owner, - MetaWaylandDataDevicePrimaryLegacy *data_device) -{ - MetaWaylandCompositor *compositor = meta_wayland_compositor_get_default (); - MetaWaylandSeat *seat = compositor->seat; - struct wl_resource *data_device_resource; - struct wl_client *focus_client; - - focus_client = meta_wayland_keyboard_get_focus_client (seat->keyboard); - if (!focus_client) - return; - - if (selection_type == META_SELECTION_PRIMARY) - { - wl_resource_for_each (data_device_resource, &data_device->focus_resource_list) - { - struct wl_resource *offer = NULL; - - if (new_owner) - { - offer = create_and_send_primary_offer (data_device, - data_device_resource); - } - - gtk_primary_selection_device_send_selection (data_device_resource, - offer); - } - } -} - -static void -ensure_owners_changed_handler_connected (MetaWaylandDataDevicePrimaryLegacy *data_device) -{ - if (data_device->selection_owner_signal_id != 0) - return; - - data_device->selection_owner_signal_id = - g_signal_connect (meta_display_get_selection (meta_get_display ()), - "owner-changed", - G_CALLBACK (owner_changed_cb), data_device); -} - -static void -primary_device_manager_create_source (struct wl_client *client, - struct wl_resource *manager_resource, - guint32 id) -{ - struct wl_resource *source_resource; - - source_resource = - wl_resource_create (client, >k_primary_selection_source_interface, - wl_resource_get_version (manager_resource), - id); - meta_wayland_data_source_primary_legacy_new (source_resource); -} - -static void -primary_device_manager_get_device (struct wl_client *client, - struct wl_resource *manager_resource, - guint32 id, - struct wl_resource *seat_resource) -{ - MetaWaylandSeat *seat = wl_resource_get_user_data (seat_resource); - struct wl_resource *cr; - - cr = wl_resource_create (client, >k_primary_selection_device_interface, - wl_resource_get_version (manager_resource), id); - wl_resource_set_implementation (cr, &primary_device_interface, - &seat->primary_legacy_data_device, unbind_resource); - wl_list_insert (&seat->primary_legacy_data_device.resource_list, - wl_resource_get_link (cr)); - - ensure_owners_changed_handler_connected (&seat->primary_legacy_data_device); -} - -static const struct gtk_primary_selection_device_manager_interface primary_manager_interface = { - primary_device_manager_create_source, - primary_device_manager_get_device, - default_destructor, -}; - -static void -bind_primary_manager (struct wl_client *client, - void *data, - uint32_t version, - uint32_t id) -{ - struct wl_resource *resource; - - resource = wl_resource_create (client, >k_primary_selection_device_manager_interface, - version, id); - wl_resource_set_implementation (resource, &primary_manager_interface, NULL, NULL); -} - -void -meta_wayland_data_device_primary_legacy_manager_init (MetaWaylandCompositor *compositor) -{ - if (wl_global_create (compositor->wayland_display, - >k_primary_selection_device_manager_interface, - 1, NULL, bind_primary_manager) == NULL) - g_error ("Could not create data_device"); -} - -void -meta_wayland_data_device_primary_legacy_init (MetaWaylandDataDevicePrimaryLegacy *data_device) -{ - wl_list_init (&data_device->resource_list); - wl_list_init (&data_device->focus_resource_list); -} - -static struct wl_resource * -create_and_send_primary_offer (MetaWaylandDataDevicePrimaryLegacy *data_device, - struct wl_resource *target) -{ - MetaWaylandDataOffer *offer; - MetaDisplay *display = meta_get_display (); - struct wl_resource *resource; - GList *mimetypes, *l; - - mimetypes = meta_selection_get_mimetypes (meta_display_get_selection (display), - META_SELECTION_PRIMARY); - if (!mimetypes) - return NULL; - - offer = meta_wayland_data_offer_primary_legacy_new (target); - resource = meta_wayland_data_offer_get_resource (offer); - - gtk_primary_selection_device_send_data_offer (target, resource); - - for (l = mimetypes; l; l = l->next) - gtk_primary_selection_offer_send_offer (resource, l->data); - - g_list_free_full (mimetypes, g_free); - - return resource; -} - -void -meta_wayland_data_device_primary_legacy_set_keyboard_focus (MetaWaylandDataDevicePrimaryLegacy *data_device) -{ - MetaWaylandSeat *seat = wl_container_of (data_device, seat, primary_legacy_data_device); - struct wl_client *focus_client; - struct wl_resource *data_device_resource; - - focus_client = meta_wayland_keyboard_get_focus_client (seat->keyboard); - - if (focus_client == data_device->focus_client) - return; - - data_device->focus_client = focus_client; - move_resources (&data_device->resource_list, - &data_device->focus_resource_list); - - if (!focus_client) - return; - - move_resources_for_client (&data_device->focus_resource_list, - &data_device->resource_list, - focus_client); - - wl_resource_for_each (data_device_resource, &data_device->focus_resource_list) - { - struct wl_resource *offer; - offer = create_and_send_primary_offer (data_device, data_device_resource); - gtk_primary_selection_device_send_selection (data_device_resource, offer); - } -} diff --git a/src/wayland/meta-wayland-data-device-primary-legacy.h b/src/wayland/meta-wayland-data-device-primary-legacy.h deleted file mode 100644 index c1b4d6e99..000000000 --- a/src/wayland/meta-wayland-data-device-primary-legacy.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright © 2008 Kristian Høgsberg - * 2020 Red Hat Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that copyright - * notice and this permission notice appear in supporting documentation, and - * that the name of the copyright holders not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. The copyright holders make no representations - * about the suitability of this software for any purpose. It is provided "as - * is" without express or implied warranty. - * - * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#ifndef META_WAYLAND_DATA_DEVICE_PRIMARY_LEGACY_H -#define META_WAYLAND_DATA_DEVICE_PRIMARY_LEGACY_H - -#include -#include - -#include "clutter/clutter.h" -#include "meta/meta-selection-source.h" -#include "wayland/meta-wayland-data-offer.h" -#include "wayland/meta-wayland-data-source.h" -#include "wayland/meta-wayland-types.h" - -struct _MetaWaylandDataDevicePrimaryLegacy -{ - uint32_t serial; - MetaWaylandDataSource *data_source; - struct wl_list resource_list; - struct wl_list focus_resource_list; - struct wl_client *focus_client; - - guint selection_owner_signal_id; - - MetaSelectionSource *owner; -}; - -void meta_wayland_data_device_primary_legacy_manager_init (MetaWaylandCompositor *compositor); - -void meta_wayland_data_device_primary_legacy_init (MetaWaylandDataDevicePrimaryLegacy *data_device); - -void meta_wayland_data_device_primary_legacy_set_keyboard_focus (MetaWaylandDataDevicePrimaryLegacy *data_device); - -#endif /* META_WAYLAND_DATA_DEVICE_PRIMARY_LEGACY_H */ diff --git a/src/wayland/meta-wayland-data-device-primary.c b/src/wayland/meta-wayland-data-device-primary.c index fb6417cfe..485057507 100644 --- a/src/wayland/meta-wayland-data-device-primary.c +++ b/src/wayland/meta-wayland-data-device-primary.c @@ -283,7 +283,9 @@ meta_wayland_data_device_primary_manager_init (MetaWaylandCompositor *compositor { if (wl_global_create (compositor->wayland_display, &zwp_primary_selection_device_manager_v1_interface, - 1, NULL, bind_primary_manager) == NULL) + META_ZWP_PRIMARY_SELECTION_V1_VERSION, + NULL, bind_primary_manager) == NULL) + g_error ("Could not create data_device"); } diff --git a/src/wayland/meta-wayland-data-offer-primary-legacy.c b/src/wayland/meta-wayland-data-offer-primary-legacy.c deleted file mode 100644 index 5fe9523d3..000000000 --- a/src/wayland/meta-wayland-data-offer-primary-legacy.c +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright © 2011 Kristian Høgsberg - * 2020 Red Hat Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that copyright - * notice and this permission notice appear in supporting documentation, and - * that the name of the copyright holders not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. The copyright holders make no representations - * about the suitability of this software for any purpose. It is provided "as - * is" without express or implied warranty. - * - * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#include "config.h" - -#include "meta-wayland-data-offer-primary-legacy.h" - -#include -#include -#include -#include -#include -#include -#include - -#include "core/display-private.h" -#include "gtk-primary-selection-server-protocol.h" -#include "wayland/meta-wayland-data-offer.h" - -static void -transfer_cb (MetaSelection *selection, - GAsyncResult *res, - GOutputStream *stream) -{ - GError *error = NULL; - - if (!meta_selection_transfer_finish (selection, res, &error)) - { - g_warning ("Could not fetch selection data: %s", error->message); - g_error_free (error); - } - - g_output_stream_close (stream, NULL, NULL); - g_object_unref (stream); -} - -static void -primary_offer_receive (struct wl_client *client, - struct wl_resource *resource, - const char *mime_type, - int32_t fd) -{ - MetaDisplay *display = meta_get_display (); - GOutputStream *stream; - GList *mime_types; - gboolean found; - - mime_types = meta_selection_get_mimetypes (meta_display_get_selection (display), - META_SELECTION_PRIMARY); - found = g_list_find_custom (mime_types, mime_type, (GCompareFunc) g_strcmp0) != NULL; - g_list_free_full (mime_types, g_free); - - if (!found) - { - close (fd); - return; - } - - stream = g_unix_output_stream_new (fd, TRUE); - meta_selection_transfer_async (meta_display_get_selection (display), - META_SELECTION_PRIMARY, - mime_type, - -1, - stream, - NULL, - (GAsyncReadyCallback) transfer_cb, - stream); -} - -static void -primary_offer_destroy (struct wl_client *client, - struct wl_resource *resource) -{ - wl_resource_destroy (resource); -} - -static const struct gtk_primary_selection_offer_interface primary_offer_interface = { - primary_offer_receive, - primary_offer_destroy, -}; - -static void -destroy_primary_offer (struct wl_resource *resource) -{ - MetaWaylandDataOffer *offer = wl_resource_get_user_data (resource); - - if (offer->source) - { - if (offer == meta_wayland_data_source_get_current_offer (offer->source)) - { - meta_wayland_data_source_cancel (offer->source); - meta_wayland_data_source_set_current_offer (offer->source, NULL); - } - - g_object_remove_weak_pointer (G_OBJECT (offer->source), - (gpointer *)&offer->source); - offer->source = NULL; - } - - meta_display_sync_wayland_input_focus (meta_get_display ()); - g_slice_free (MetaWaylandDataOffer, offer); -} - -MetaWaylandDataOffer * -meta_wayland_data_offer_primary_legacy_new (struct wl_resource *target) -{ - MetaWaylandDataOffer *offer; - - offer = g_slice_new0 (MetaWaylandDataOffer); - offer->selection_type = META_SELECTION_PRIMARY; - offer->resource = wl_resource_create (wl_resource_get_client (target), - >k_primary_selection_offer_interface, - wl_resource_get_version (target), 0); - wl_resource_set_implementation (offer->resource, - &primary_offer_interface, - offer, - destroy_primary_offer); - return offer; -} diff --git a/src/wayland/meta-wayland-data-offer-primary-legacy.h b/src/wayland/meta-wayland-data-offer-primary-legacy.h deleted file mode 100644 index 96a32c34e..000000000 --- a/src/wayland/meta-wayland-data-offer-primary-legacy.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright © 2011 Kristian Høgsberg - * 2020 Red Hat Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that copyright - * notice and this permission notice appear in supporting documentation, and - * that the name of the copyright holders not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. The copyright holders make no representations - * about the suitability of this software for any purpose. It is provided "as - * is" without express or implied warranty. - * - * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#ifndef META_WAYLAND_DATA_OFFER_PRIMARY_LEGACY_H -#define META_WAYLAND_DATA_OFFER_PRIMARY_LEGACY_H - -#include "meta-wayland-data-offer.h" - -MetaWaylandDataOffer * meta_wayland_data_offer_primary_legacy_new (struct wl_resource *target); - -#endif /* META_WAYLAND_DATA_OFFER_PRIMARY_LEGACY_H */ diff --git a/src/wayland/meta-wayland-data-source-primary-legacy.c b/src/wayland/meta-wayland-data-source-primary-legacy.c deleted file mode 100644 index a7a1788ae..000000000 --- a/src/wayland/meta-wayland-data-source-primary-legacy.c +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright © 2011 Kristian Høgsberg - * 2020 Red Hat Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that copyright - * notice and this permission notice appear in supporting documentation, and - * that the name of the copyright holders not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. The copyright holders make no representations - * about the suitability of this software for any purpose. It is provided "as - * is" without express or implied warranty. - * - * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#include "config.h" - -#include - -#include "gtk-primary-selection-server-protocol.h" -#include "wayland/meta-wayland-data-source-primary-legacy.h" - -typedef struct _MetaWaylandDataSourcePrimaryLegacy -{ - MetaWaylandDataSource parent; -} MetaWaylandDataSourcePrimaryLegacy; - -G_DEFINE_TYPE (MetaWaylandDataSourcePrimaryLegacy, meta_wayland_data_source_primary_legacy, - META_TYPE_WAYLAND_DATA_SOURCE); - -static void -primary_source_offer (struct wl_client *client, - struct wl_resource *resource, - const char *type) -{ - MetaWaylandDataSource *source = wl_resource_get_user_data (resource); - - if (!meta_wayland_data_source_add_mime_type (source, type)) - wl_resource_post_no_memory (resource); -} - -static void -primary_source_destroy (struct wl_client *client, - struct wl_resource *resource) -{ - wl_resource_destroy (resource); -} - -static struct gtk_primary_selection_source_interface primary_source_interface = { - primary_source_offer, - primary_source_destroy, -}; - -static void -destroy_primary_source (struct wl_resource *resource) -{ - MetaWaylandDataSource *source = wl_resource_get_user_data (resource); - - meta_wayland_data_source_set_resource (source, NULL); - g_object_unref (source); -} - -static void -meta_wayland_data_source_primary_legacy_send (MetaWaylandDataSource *source, - const gchar *mime_type, - gint fd) -{ - struct wl_resource *resource = meta_wayland_data_source_get_resource (source); - - gtk_primary_selection_source_send_send (resource, mime_type, fd); - close (fd); -} - -static void -meta_wayland_data_source_primary_legacy_cancel (MetaWaylandDataSource *source) -{ - struct wl_resource *resource = meta_wayland_data_source_get_resource (source); - - if (resource) - gtk_primary_selection_source_send_cancelled (resource); -} - -static void -meta_wayland_data_source_primary_legacy_init (MetaWaylandDataSourcePrimaryLegacy *source_primary) -{ -} - -static void -meta_wayland_data_source_primary_legacy_class_init (MetaWaylandDataSourcePrimaryLegacyClass *klass) -{ - MetaWaylandDataSourceClass *data_source_class = - META_WAYLAND_DATA_SOURCE_CLASS (klass); - - data_source_class->send = meta_wayland_data_source_primary_legacy_send; - data_source_class->cancel = meta_wayland_data_source_primary_legacy_cancel; -} - -MetaWaylandDataSource * -meta_wayland_data_source_primary_legacy_new (struct wl_resource *resource) -{ - MetaWaylandDataSource *source_primary = - g_object_new (META_TYPE_WAYLAND_DATA_SOURCE_PRIMARY_LEGACY, NULL); - - meta_wayland_data_source_set_resource (source_primary, resource); - wl_resource_set_implementation (resource, &primary_source_interface, - source_primary, destroy_primary_source); - - return source_primary; -} diff --git a/src/wayland/meta-wayland-data-source-primary-legacy.h b/src/wayland/meta-wayland-data-source-primary-legacy.h deleted file mode 100644 index 2904807c8..000000000 --- a/src/wayland/meta-wayland-data-source-primary-legacy.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright © 2011 Kristian Høgsberg - * 2020 Red Hat Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that copyright - * notice and this permission notice appear in supporting documentation, and - * that the name of the copyright holders not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. The copyright holders make no representations - * about the suitability of this software for any purpose. It is provided "as - * is" without express or implied warranty. - * - * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#ifndef META_WAYLAND_DATA_SOURCE_PRIMARY_LEGACY_H -#define META_WAYLAND_DATA_SOURCE_PRIMARY_LEGACY_H - -#include "meta-wayland-data-source.h" - -#define META_TYPE_WAYLAND_DATA_SOURCE_PRIMARY_LEGACY (meta_wayland_data_source_primary_legacy_get_type ()) -G_DECLARE_FINAL_TYPE (MetaWaylandDataSourcePrimaryLegacy, - meta_wayland_data_source_primary_legacy, - META, WAYLAND_DATA_SOURCE_PRIMARY_LEGACY, - MetaWaylandDataSource); - -MetaWaylandDataSource * meta_wayland_data_source_primary_legacy_new (struct wl_resource *resource); - -#endif /* META_WAYLAND_DATA_SOURCE_PRIMARY_LEGACY_H */ diff --git a/src/wayland/meta-wayland-legacy-xdg-shell.c b/src/wayland/meta-wayland-legacy-xdg-shell.c deleted file mode 100644 index 90eacab36..000000000 --- a/src/wayland/meta-wayland-legacy-xdg-shell.c +++ /dev/null @@ -1,2102 +0,0 @@ -/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ - -/* - * Copyright (C) 2012-2013 Intel Corporation - * Copyright (C) 2013-2015 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. - * - */ - -#include "config.h" - -#include "wayland/meta-wayland-legacy-xdg-shell.h" - -#include "backends/meta-logical-monitor.h" -#include "core/window-private.h" -#include "wayland/meta-wayland-outputs.h" -#include "wayland/meta-wayland-popup.h" -#include "wayland/meta-wayland-private.h" -#include "wayland/meta-wayland-seat.h" -#include "wayland/meta-wayland-shell-surface.h" -#include "wayland/meta-wayland-surface.h" -#include "wayland/meta-wayland-versions.h" -#include "wayland/meta-wayland-window-configuration.h" -#include "wayland/meta-wayland.h" -#include "wayland/meta-window-wayland.h" - -#include "xdg-shell-unstable-v6-server-protocol.h" - -enum -{ - ZXDG_SURFACE_V6_PROP_0, - - ZXDG_SURFACE_V6_PROP_SHELL_CLIENT, - ZXDG_SURFACE_V6_PROP_RESOURCE, -}; - -typedef struct _MetaWaylandZxdgShellV6Client -{ - struct wl_resource *resource; - GList *surfaces; - GList *surface_constructors; -} MetaWaylandZxdgShellV6Client; - -typedef struct _MetaWaylandZxdgPositionerV6 -{ - MetaRectangle anchor_rect; - int32_t width; - int32_t height; - uint32_t gravity; - uint32_t anchor; - uint32_t constraint_adjustment; - int32_t offset_x; - int32_t offset_y; -} MetaWaylandZxdgPositionerV6; - -typedef struct _MetaWaylandZxdgSurfaceV6Constructor -{ - MetaWaylandSurface *surface; - struct wl_resource *resource; - MetaWaylandZxdgShellV6Client *shell_client; -} MetaWaylandZxdgSurfaceV6Constructor; - -typedef struct _MetaWaylandZxdgSurfaceV6Private -{ - struct wl_resource *resource; - MetaWaylandZxdgShellV6Client *shell_client; - MetaRectangle geometry; - - guint configure_sent : 1; - guint first_buffer_attached : 1; - guint has_set_geometry : 1; -} MetaWaylandZxdgSurfaceV6Private; - -G_DEFINE_TYPE_WITH_PRIVATE (MetaWaylandZxdgSurfaceV6, - meta_wayland_zxdg_surface_v6, - META_TYPE_WAYLAND_SHELL_SURFACE); - -struct _MetaWaylandZxdgToplevelV6 -{ - MetaWaylandZxdgSurfaceV6 parent; - - struct wl_resource *resource; -}; - -G_DEFINE_TYPE (MetaWaylandZxdgToplevelV6, - meta_wayland_zxdg_toplevel_v6, - META_TYPE_WAYLAND_ZXDG_SURFACE_V6); - -struct _MetaWaylandZxdgPopupV6 -{ - MetaWaylandZxdgSurfaceV6 parent; - - struct wl_resource *resource; - - MetaWaylandSurface *parent_surface; - struct wl_listener parent_destroy_listener; - - MetaWaylandPopup *popup; - - struct { - MetaWaylandSurface *parent_surface; - - /* - * The coordinates/dimensions in the placement rule are in logical pixel - * coordinate space, i.e. not scaled given what monitor the popup is on. - */ - MetaPlacementRule placement_rule; - - MetaWaylandSeat *grab_seat; - uint32_t grab_serial; - } setup; -}; - -static void -popup_surface_iface_init (MetaWaylandPopupSurfaceInterface *iface); - -G_DEFINE_TYPE_WITH_CODE (MetaWaylandZxdgPopupV6, - meta_wayland_zxdg_popup_v6, - META_TYPE_WAYLAND_ZXDG_SURFACE_V6, - G_IMPLEMENT_INTERFACE (META_TYPE_WAYLAND_POPUP_SURFACE, - popup_surface_iface_init)); - -static MetaPlacementRule -meta_wayland_zxdg_positioner_v6_to_placement (MetaWaylandZxdgPositionerV6 *xdg_positioner); - -static struct wl_resource * -meta_wayland_zxdg_surface_v6_get_shell_resource (MetaWaylandZxdgSurfaceV6 *xdg_surface); - -static MetaRectangle -meta_wayland_zxdg_surface_v6_get_window_geometry (MetaWaylandZxdgSurfaceV6 *xdg_surface); - -static void -meta_wayland_zxdg_surface_v6_send_configure (MetaWaylandZxdgSurfaceV6 *xdg_surface, - MetaWaylandWindowConfiguration *configuration); - -static MetaWaylandSurface * -surface_from_xdg_surface_resource (struct wl_resource *resource) -{ - MetaWaylandSurfaceRole *surface_role = wl_resource_get_user_data (resource); - - return meta_wayland_surface_role_get_surface (surface_role); -} - -static MetaWaylandSurface * -surface_from_xdg_toplevel_resource (struct wl_resource *resource) -{ - return surface_from_xdg_surface_resource (resource); -} - -static void -zxdg_toplevel_v6_destructor (struct wl_resource *resource) -{ - MetaWaylandZxdgToplevelV6 *xdg_toplevel = - wl_resource_get_user_data (resource); - MetaWaylandShellSurface *shell_surface = - META_WAYLAND_SHELL_SURFACE (xdg_toplevel); - - meta_wayland_shell_surface_destroy_window (shell_surface); - xdg_toplevel->resource = NULL; -} - -static void -zxdg_toplevel_v6_destroy (struct wl_client *client, - struct wl_resource *resource) -{ - wl_resource_destroy (resource); -} - -static void -zxdg_toplevel_v6_set_parent (struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *parent_resource) -{ - MetaWaylandSurface *surface = surface_from_xdg_toplevel_resource (resource); - MetaWindow *transient_for = NULL; - MetaWindow *window; - - window = meta_wayland_surface_get_window (surface); - if (!window) - return; - - if (parent_resource) - { - MetaWaylandSurface *parent_surface = - surface_from_xdg_surface_resource (parent_resource); - - transient_for = meta_wayland_surface_get_window (parent_surface); - } - - meta_window_set_transient_for (window, transient_for); -} - -static void -zxdg_toplevel_v6_set_title (struct wl_client *client, - struct wl_resource *resource, - const char *title) -{ - MetaWaylandSurface *surface = surface_from_xdg_toplevel_resource (resource); - MetaWindow *window; - - window = meta_wayland_surface_get_window (surface); - if (!window) - return; - - if (!g_utf8_validate (title, -1, NULL)) - title = ""; - - meta_window_set_title (window, title); -} - -static void -zxdg_toplevel_v6_set_app_id (struct wl_client *client, - struct wl_resource *resource, - const char *app_id) -{ - MetaWaylandSurface *surface = surface_from_xdg_toplevel_resource (resource); - MetaWindow *window; - - window = meta_wayland_surface_get_window (surface); - if (!window) - return; - - if (!g_utf8_validate (app_id, -1, NULL)) - app_id = ""; - - meta_window_set_wm_class (window, app_id, app_id); -} - -static void -zxdg_toplevel_v6_show_window_menu (struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *seat_resource, - uint32_t serial, - int32_t x, - int32_t y) -{ - MetaWaylandSeat *seat = wl_resource_get_user_data (seat_resource); - MetaWaylandSurface *surface = surface_from_xdg_toplevel_resource (resource); - MetaWindow *window; - int monitor_scale; - - window = meta_wayland_surface_get_window (surface); - if (!window) - return; - - if (!meta_wayland_seat_get_grab_info (seat, surface, serial, FALSE, NULL, NULL)) - return; - - monitor_scale = meta_window_wayland_get_geometry_scale (window); - meta_window_show_menu (window, META_WINDOW_MENU_WM, - window->buffer_rect.x + (x * monitor_scale), - window->buffer_rect.y + (y * monitor_scale)); -} - -static void -zxdg_toplevel_v6_move (struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *seat_resource, - uint32_t serial) -{ - MetaWaylandSeat *seat = wl_resource_get_user_data (seat_resource); - MetaWaylandSurface *surface = surface_from_xdg_toplevel_resource (resource); - MetaWindow *window; - gfloat x, y; - - window = meta_wayland_surface_get_window (surface); - if (!window) - return; - - if (!meta_wayland_seat_get_grab_info (seat, surface, serial, TRUE, &x, &y)) - return; - - meta_wayland_surface_begin_grab_op (surface, seat, META_GRAB_OP_MOVING, x, y); -} - -static MetaGrabOp -grab_op_for_xdg_toplevel_resize_edge (int edge) -{ - MetaGrabOp op = META_GRAB_OP_WINDOW_BASE; - - if (edge & ZXDG_TOPLEVEL_V6_RESIZE_EDGE_TOP) - op |= META_GRAB_OP_WINDOW_DIR_NORTH; - if (edge & ZXDG_TOPLEVEL_V6_RESIZE_EDGE_BOTTOM) - op |= META_GRAB_OP_WINDOW_DIR_SOUTH; - if (edge & ZXDG_TOPLEVEL_V6_RESIZE_EDGE_LEFT) - op |= META_GRAB_OP_WINDOW_DIR_WEST; - if (edge & ZXDG_TOPLEVEL_V6_RESIZE_EDGE_RIGHT) - op |= META_GRAB_OP_WINDOW_DIR_EAST; - - if (op == META_GRAB_OP_WINDOW_BASE) - { - g_warning ("invalid edge: %d", edge); - return META_GRAB_OP_NONE; - } - - return op; -} - -static void -zxdg_toplevel_v6_resize (struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *seat_resource, - uint32_t serial, - uint32_t edges) -{ - MetaWaylandSeat *seat = wl_resource_get_user_data (seat_resource); - MetaWaylandSurface *surface = surface_from_xdg_toplevel_resource (resource); - MetaWindow *window; - gfloat x, y; - MetaGrabOp grab_op; - - window = meta_wayland_surface_get_window (surface); - if (!window) - return; - - if (!meta_wayland_seat_get_grab_info (seat, surface, serial, TRUE, &x, &y)) - return; - - grab_op = grab_op_for_xdg_toplevel_resize_edge (edges); - meta_wayland_surface_begin_grab_op (surface, seat, grab_op, x, y); -} - -static void -zxdg_toplevel_v6_set_max_size (struct wl_client *client, - struct wl_resource *resource, - int32_t width, - int32_t height) -{ - MetaWaylandSurface *surface = surface_from_xdg_toplevel_resource (resource); - MetaWaylandSurfaceState *pending; - MetaWindow *window; - - window = meta_wayland_surface_get_window (surface); - if (!window) - return; - - if (width < 0 || height < 0) - { - wl_resource_post_error (resource, - ZXDG_SHELL_V6_ERROR_INVALID_SURFACE_STATE, - "invalid negative max size requested %i x %i", - width, height); - return; - } - - pending = meta_wayland_surface_get_pending_state (surface); - pending->has_new_max_size = TRUE; - pending->new_max_width = width; - pending->new_max_height = height; -} - -static void -zxdg_toplevel_v6_set_min_size (struct wl_client *client, - struct wl_resource *resource, - int32_t width, - int32_t height) -{ - MetaWaylandSurface *surface = surface_from_xdg_toplevel_resource (resource); - MetaWaylandSurfaceState *pending; - MetaWindow *window; - - window = meta_wayland_surface_get_window (surface); - if (!window) - return; - - if (width < 0 || height < 0) - { - wl_resource_post_error (resource, - ZXDG_SHELL_V6_ERROR_INVALID_SURFACE_STATE, - "invalid negative min size requested %i x %i", - width, height); - return; - } - - pending = meta_wayland_surface_get_pending_state (surface); - pending->has_new_min_size = TRUE; - pending->new_min_width = width; - pending->new_min_height = height; -} - -static void -zxdg_toplevel_v6_set_maximized (struct wl_client *client, - struct wl_resource *resource) -{ - MetaWaylandSurface *surface = surface_from_xdg_toplevel_resource (resource); - MetaWindow *window; - - window = meta_wayland_surface_get_window (surface); - if (!window) - return; - - if (!window->has_maximize_func) - return; - - meta_window_force_placement (window, TRUE); - meta_window_maximize (window, META_MAXIMIZE_BOTH); -} - -static void -zxdg_toplevel_v6_unset_maximized (struct wl_client *client, - struct wl_resource *resource) -{ - MetaWaylandSurface *surface = surface_from_xdg_toplevel_resource (resource); - MetaWindow *window; - - window = meta_wayland_surface_get_window (surface); - if (!window) - return; - - meta_window_unmaximize (window, META_MAXIMIZE_BOTH); -} - -static void -zxdg_toplevel_v6_set_fullscreen (struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *output_resource) -{ - MetaWaylandSurface *surface = surface_from_xdg_toplevel_resource (resource); - MetaWindow *window; - - window = meta_wayland_surface_get_window (surface); - if (!window) - return; - - if (output_resource) - { - MetaWaylandOutput *output = wl_resource_get_user_data (output_resource); - if (output && output->logical_monitor) - meta_window_move_to_monitor (window, output->logical_monitor->number); - } - - meta_window_make_fullscreen (window); -} - -static void -zxdg_toplevel_v6_unset_fullscreen (struct wl_client *client, - struct wl_resource *resource) -{ - MetaWaylandSurface *surface = surface_from_xdg_toplevel_resource (resource); - MetaWindow *window; - - window = meta_wayland_surface_get_window (surface); - if (!window) - return; - - meta_window_unmake_fullscreen (window); -} - -static void -zxdg_toplevel_v6_set_minimized (struct wl_client *client, - struct wl_resource *resource) -{ - MetaWaylandSurface *surface = surface_from_xdg_toplevel_resource (resource); - MetaWindow *window; - - window = meta_wayland_surface_get_window (surface); - if (!window) - return; - - meta_window_minimize (window); -} - -static const struct zxdg_toplevel_v6_interface meta_wayland_zxdg_toplevel_v6_interface = { - zxdg_toplevel_v6_destroy, - zxdg_toplevel_v6_set_parent, - zxdg_toplevel_v6_set_title, - zxdg_toplevel_v6_set_app_id, - zxdg_toplevel_v6_show_window_menu, - zxdg_toplevel_v6_move, - zxdg_toplevel_v6_resize, - zxdg_toplevel_v6_set_max_size, - zxdg_toplevel_v6_set_min_size, - zxdg_toplevel_v6_set_maximized, - zxdg_toplevel_v6_unset_maximized, - zxdg_toplevel_v6_set_fullscreen, - zxdg_toplevel_v6_unset_fullscreen, - zxdg_toplevel_v6_set_minimized, -}; - -static void -zxdg_popup_v6_destructor (struct wl_resource *resource) -{ - MetaWaylandZxdgPopupV6 *xdg_popup = - META_WAYLAND_ZXDG_POPUP_V6 (wl_resource_get_user_data (resource)); - - if (xdg_popup->parent_surface) - { - wl_list_remove (&xdg_popup->parent_destroy_listener.link); - xdg_popup->parent_surface = NULL; - } - - if (xdg_popup->popup) - meta_wayland_popup_dismiss (xdg_popup->popup); - - xdg_popup->resource = NULL; -} - -static void -zxdg_popup_v6_destroy (struct wl_client *client, - struct wl_resource *resource) -{ - wl_resource_destroy (resource); -} - -static void -zxdg_popup_v6_grab (struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *seat_resource, - uint32_t serial) -{ - MetaWaylandZxdgPopupV6 *xdg_popup = - META_WAYLAND_ZXDG_POPUP_V6 (wl_resource_get_user_data (resource)); - MetaWaylandSeat *seat = wl_resource_get_user_data (seat_resource); - MetaWaylandSurface *parent_surface; - - parent_surface = xdg_popup->setup.parent_surface; - if (!parent_surface) - { - wl_resource_post_error (resource, - ZXDG_POPUP_V6_ERROR_INVALID_GRAB, - "tried to grab after popup was mapped"); - return; - } - - xdg_popup->setup.grab_seat = seat; - xdg_popup->setup.grab_serial = serial; -} - -static const struct zxdg_popup_v6_interface meta_wayland_zxdg_popup_v6_interface = { - zxdg_popup_v6_destroy, - zxdg_popup_v6_grab, -}; - -static void -handle_popup_parent_destroyed (struct wl_listener *listener, - void *data) -{ - MetaWaylandZxdgPopupV6 *xdg_popup = - wl_container_of (listener, xdg_popup, parent_destroy_listener); - MetaWaylandZxdgSurfaceV6 *xdg_surface = - META_WAYLAND_ZXDG_SURFACE_V6 (xdg_popup); - struct wl_resource *xdg_shell_resource = - meta_wayland_zxdg_surface_v6_get_shell_resource (xdg_surface); - MetaWaylandShellSurface *shell_surface = - META_WAYLAND_SHELL_SURFACE (xdg_popup); - - wl_resource_post_error (xdg_shell_resource, - ZXDG_SHELL_V6_ERROR_NOT_THE_TOPMOST_POPUP, - "destroyed popup not top most popup"); - xdg_popup->parent_surface = NULL; - - meta_wayland_shell_surface_destroy_window (shell_surface); -} - -static void -add_state_value (struct wl_array *states, - enum zxdg_toplevel_v6_state state) -{ - uint32_t *s; - - s = wl_array_add (states, sizeof *s); - *s = state; -} - -static void -fill_states (struct wl_array *states, - MetaWindow *window) -{ - if (META_WINDOW_MAXIMIZED (window)) - add_state_value (states, ZXDG_TOPLEVEL_V6_STATE_MAXIMIZED); - if (meta_window_is_fullscreen (window)) - add_state_value (states, ZXDG_TOPLEVEL_V6_STATE_FULLSCREEN); - if (meta_grab_op_is_resizing (window->display->grab_op)) - add_state_value (states, ZXDG_TOPLEVEL_V6_STATE_RESIZING); - if (meta_window_appears_focused (window)) - add_state_value (states, ZXDG_TOPLEVEL_V6_STATE_ACTIVATED); -} - -static void -meta_wayland_zxdg_toplevel_v6_send_configure (MetaWaylandZxdgToplevelV6 *xdg_toplevel, - MetaWaylandWindowConfiguration *configuration) -{ - MetaWaylandZxdgSurfaceV6 *xdg_surface = - META_WAYLAND_ZXDG_SURFACE_V6 (xdg_toplevel); - MetaWaylandSurfaceRole *surface_role = - META_WAYLAND_SURFACE_ROLE (xdg_toplevel); - MetaWaylandSurface *surface = - meta_wayland_surface_role_get_surface (surface_role); - MetaWindow *window; - struct wl_array states; - - window = meta_wayland_surface_get_window (surface); - - wl_array_init (&states); - fill_states (&states, window); - - zxdg_toplevel_v6_send_configure (xdg_toplevel->resource, - configuration->width / configuration->scale, - configuration->height / configuration->scale, - &states); - wl_array_release (&states); - - meta_wayland_zxdg_surface_v6_send_configure (xdg_surface, configuration); -} - -static gboolean -is_new_size_hints_valid (MetaWindow *window, - MetaWaylandSurfaceState *pending) -{ - int new_min_width, new_min_height; - int new_max_width, new_max_height; - - if (pending->has_new_min_size) - { - new_min_width = pending->new_min_width; - new_min_height = pending->new_min_height; - } - else - { - meta_window_wayland_get_min_size (window, &new_min_width, &new_min_height); - } - - if (pending->has_new_max_size) - { - new_max_width = pending->new_max_width; - new_max_height = pending->new_max_height; - } - else - { - meta_window_wayland_get_max_size (window, &new_max_width, &new_max_height); - } - /* Zero means unlimited */ - return ((new_max_width == 0 || new_min_width <= new_max_width) && - (new_max_height == 0 || new_min_height <= new_max_height)); -} - -static void -meta_wayland_zxdg_toplevel_v6_apply_state (MetaWaylandSurfaceRole *surface_role, - MetaWaylandSurfaceState *pending) -{ - MetaWaylandZxdgToplevelV6 *xdg_toplevel = - META_WAYLAND_ZXDG_TOPLEVEL_V6 (surface_role); - MetaWaylandZxdgSurfaceV6 *xdg_surface = - META_WAYLAND_ZXDG_SURFACE_V6 (xdg_toplevel); - MetaWaylandZxdgSurfaceV6Private *xdg_surface_priv = - meta_wayland_zxdg_surface_v6_get_instance_private (xdg_surface); - MetaWaylandActorSurface *actor_surface = - META_WAYLAND_ACTOR_SURFACE (xdg_surface); - MetaWaylandSurfaceRoleClass *surface_role_class; - MetaWaylandSurface *surface = - meta_wayland_surface_role_get_surface (surface_role); - MetaWindow *window; - - window = meta_wayland_surface_get_window (surface); - if (!window) - { - meta_wayland_actor_surface_queue_frame_callbacks (actor_surface, pending); - return; - } - - surface_role_class = - META_WAYLAND_SURFACE_ROLE_CLASS (meta_wayland_zxdg_toplevel_v6_parent_class); - surface_role_class->apply_state (surface_role, pending); - - if (!xdg_surface_priv->configure_sent) - { - MetaWaylandWindowConfiguration *configuration; - - configuration = meta_wayland_window_configuration_new_empty (); - meta_wayland_zxdg_toplevel_v6_send_configure (xdg_toplevel, - configuration); - meta_wayland_window_configuration_free (configuration); - return; - } -} - -static void -meta_wayland_zxdg_toplevel_v6_post_apply_state (MetaWaylandSurfaceRole *surface_role, - MetaWaylandSurfaceState *pending) -{ - MetaWaylandZxdgToplevelV6 *xdg_toplevel = - META_WAYLAND_ZXDG_TOPLEVEL_V6 (surface_role); - MetaWaylandZxdgSurfaceV6 *xdg_surface = - META_WAYLAND_ZXDG_SURFACE_V6 (xdg_toplevel); - MetaWaylandZxdgSurfaceV6Private *xdg_surface_priv = - meta_wayland_zxdg_surface_v6_get_instance_private (xdg_surface); - MetaWaylandSurfaceRoleClass *surface_role_class; - MetaWaylandSurface *surface = - meta_wayland_surface_role_get_surface (surface_role); - MetaWindow *window; - MetaRectangle old_geometry; - gboolean geometry_changed; - - window = meta_wayland_surface_get_window (surface); - if (!window) - return; - - if (!pending->newly_attached) - return; - - old_geometry = xdg_surface_priv->geometry; - - surface_role_class = - META_WAYLAND_SURFACE_ROLE_CLASS (meta_wayland_zxdg_toplevel_v6_parent_class); - surface_role_class->post_apply_state (surface_role, pending); - - geometry_changed = !meta_rectangle_equal (&old_geometry, &xdg_surface_priv->geometry); - - if (geometry_changed || pending->has_acked_configure_serial) - { - MetaRectangle window_geometry; - - window_geometry = - meta_wayland_zxdg_surface_v6_get_window_geometry (xdg_surface); - meta_window_wayland_finish_move_resize (window, window_geometry, pending); - } - else if (pending->dx != 0 || pending->dy != 0) - { - g_warning ("XXX: Attach-initiated move without a new geometry. " - "This is unimplemented right now."); - } - - /* When we get to this point, we ought to have valid size hints */ - if (pending->has_new_min_size || pending->has_new_max_size) - { - if (is_new_size_hints_valid (window, pending)) - { - if (pending->has_new_min_size) - meta_window_wayland_set_min_size (window, - pending->new_min_width, - pending->new_min_height); - - if (pending->has_new_max_size) - meta_window_wayland_set_max_size (window, - pending->new_max_width, - pending->new_max_height); - - meta_window_recalc_features (window); - } - else - { - wl_resource_post_error (surface->resource, - ZXDG_SHELL_V6_ERROR_INVALID_SURFACE_STATE, - "Invalid min/max size"); - } - } -} - -static MetaWaylandSurface * -meta_wayland_zxdg_toplevel_v6_get_toplevel (MetaWaylandSurfaceRole *surface_role) -{ - return meta_wayland_surface_role_get_surface (surface_role); -} - -static void -meta_wayland_zxdg_toplevel_v6_configure (MetaWaylandShellSurface *shell_surface, - MetaWaylandWindowConfiguration *configuration) -{ - MetaWaylandZxdgToplevelV6 *xdg_toplevel = - META_WAYLAND_ZXDG_TOPLEVEL_V6 (shell_surface); - MetaWaylandZxdgSurfaceV6 *xdg_surface = - META_WAYLAND_ZXDG_SURFACE_V6 (xdg_toplevel); - MetaWaylandZxdgSurfaceV6Private *xdg_surface_priv = - meta_wayland_zxdg_surface_v6_get_instance_private (xdg_surface); - - if (!xdg_surface_priv->resource) - return; - - if (!xdg_toplevel->resource) - return; - - meta_wayland_zxdg_toplevel_v6_send_configure (xdg_toplevel, configuration); -} - -static void -meta_wayland_zxdg_toplevel_v6_managed (MetaWaylandShellSurface *shell_surface, - MetaWindow *window) -{ -} - -static void -meta_wayland_zxdg_toplevel_v6_close (MetaWaylandShellSurface *shell_surface) -{ - MetaWaylandZxdgToplevelV6 *xdg_toplevel = - META_WAYLAND_ZXDG_TOPLEVEL_V6 (shell_surface); - - zxdg_toplevel_v6_send_close (xdg_toplevel->resource); -} - -static void -meta_wayland_zxdg_toplevel_v6_shell_client_destroyed (MetaWaylandZxdgSurfaceV6 *xdg_surface) -{ - MetaWaylandZxdgToplevelV6 *xdg_toplevel = - META_WAYLAND_ZXDG_TOPLEVEL_V6 (xdg_surface); - struct wl_resource *xdg_shell_resource = - meta_wayland_zxdg_surface_v6_get_shell_resource (xdg_surface); - MetaWaylandZxdgSurfaceV6Class *xdg_surface_class = - META_WAYLAND_ZXDG_SURFACE_V6_CLASS (meta_wayland_zxdg_toplevel_v6_parent_class); - - xdg_surface_class->shell_client_destroyed (xdg_surface); - - if (xdg_toplevel->resource) - { - wl_resource_post_error (xdg_shell_resource, - ZXDG_SHELL_V6_ERROR_DEFUNCT_SURFACES, - "xdg_shell of xdg_toplevel@%d was destroyed", - wl_resource_get_id (xdg_toplevel->resource)); - - wl_resource_destroy (xdg_toplevel->resource); - } -} - -static void -meta_wayland_zxdg_toplevel_v6_finalize (GObject *object) -{ - MetaWaylandZxdgToplevelV6 *xdg_toplevel = - META_WAYLAND_ZXDG_TOPLEVEL_V6 (object); - - g_clear_pointer (&xdg_toplevel->resource, wl_resource_destroy); - - G_OBJECT_CLASS (meta_wayland_zxdg_toplevel_v6_parent_class)->finalize (object); -} - -static void -meta_wayland_zxdg_toplevel_v6_init (MetaWaylandZxdgToplevelV6 *role) -{ -} - -static void -meta_wayland_zxdg_toplevel_v6_class_init (MetaWaylandZxdgToplevelV6Class *klass) -{ - GObjectClass *object_class; - MetaWaylandSurfaceRoleClass *surface_role_class; - MetaWaylandShellSurfaceClass *shell_surface_class; - MetaWaylandZxdgSurfaceV6Class *xdg_surface_class; - - object_class = G_OBJECT_CLASS (klass); - object_class->finalize = meta_wayland_zxdg_toplevel_v6_finalize; - - surface_role_class = META_WAYLAND_SURFACE_ROLE_CLASS (klass); - surface_role_class->apply_state = meta_wayland_zxdg_toplevel_v6_apply_state; - surface_role_class->post_apply_state = - meta_wayland_zxdg_toplevel_v6_post_apply_state; - surface_role_class->get_toplevel = meta_wayland_zxdg_toplevel_v6_get_toplevel; - - shell_surface_class = META_WAYLAND_SHELL_SURFACE_CLASS (klass); - shell_surface_class->configure = meta_wayland_zxdg_toplevel_v6_configure; - shell_surface_class->managed = meta_wayland_zxdg_toplevel_v6_managed; - shell_surface_class->close = meta_wayland_zxdg_toplevel_v6_close; - - xdg_surface_class = META_WAYLAND_ZXDG_SURFACE_V6_CLASS (klass); - xdg_surface_class->shell_client_destroyed = - meta_wayland_zxdg_toplevel_v6_shell_client_destroyed; -} - -static void -scale_placement_rule (MetaPlacementRule *placement_rule, - MetaWaylandSurface *surface) -{ - MetaWindow *window; - int geometry_scale; - - window = meta_wayland_surface_get_window (surface); - geometry_scale = meta_window_wayland_get_geometry_scale (window); - - placement_rule->anchor_rect.x *= geometry_scale; - placement_rule->anchor_rect.y *= geometry_scale; - placement_rule->anchor_rect.width *= geometry_scale; - placement_rule->anchor_rect.height *= geometry_scale; - placement_rule->offset_x *= geometry_scale; - placement_rule->offset_y *= geometry_scale; - placement_rule->width *= geometry_scale; - placement_rule->height *= geometry_scale; -} - -static void -finish_popup_setup (MetaWaylandZxdgPopupV6 *xdg_popup) -{ - MetaWaylandZxdgSurfaceV6 *xdg_surface = - META_WAYLAND_ZXDG_SURFACE_V6 (xdg_popup); - MetaWaylandShellSurface *shell_surface = - META_WAYLAND_SHELL_SURFACE (xdg_popup); - MetaWaylandSurfaceRole *surface_role = META_WAYLAND_SURFACE_ROLE (xdg_popup); - struct wl_resource *xdg_shell_resource = - meta_wayland_zxdg_surface_v6_get_shell_resource (xdg_surface); - MetaWaylandSurface *surface = - meta_wayland_surface_role_get_surface (surface_role); - MetaWaylandSurface *parent_surface; - MetaPlacementRule scaled_placement_rule; - MetaWaylandSeat *seat; - uint32_t serial; - MetaDisplay *display = meta_get_display (); - MetaWindow *window; - - parent_surface = xdg_popup->setup.parent_surface; - seat = xdg_popup->setup.grab_seat; - serial = xdg_popup->setup.grab_serial; - - xdg_popup->setup.parent_surface = NULL; - xdg_popup->setup.grab_seat = NULL; - - if (!meta_wayland_surface_get_window (parent_surface)) - { - zxdg_popup_v6_send_popup_done (xdg_popup->resource); - return; - } - - if (seat) - { - MetaWaylandSurface *top_popup; - - if (!meta_wayland_seat_can_popup (seat, serial)) - { - zxdg_popup_v6_send_popup_done (xdg_popup->resource); - return; - } - - top_popup = meta_wayland_pointer_get_top_popup (seat->pointer); - if (top_popup && parent_surface != top_popup) - { - wl_resource_post_error (xdg_shell_resource, - ZXDG_SHELL_V6_ERROR_NOT_THE_TOPMOST_POPUP, - "parent not top most surface"); - return; - } - } - - xdg_popup->parent_surface = parent_surface; - xdg_popup->parent_destroy_listener.notify = handle_popup_parent_destroyed; - wl_resource_add_destroy_listener (parent_surface->resource, - &xdg_popup->parent_destroy_listener); - - window = meta_window_wayland_new (display, surface); - meta_wayland_shell_surface_set_window (shell_surface, window); - - scaled_placement_rule = xdg_popup->setup.placement_rule; - scale_placement_rule (&scaled_placement_rule, surface); - meta_window_place_with_placement_rule (window, &scaled_placement_rule); - - if (seat) - { - MetaWaylandPopupSurface *popup_surface; - MetaWaylandPopup *popup; - - meta_window_focus (window, meta_display_get_current_time (display)); - popup_surface = META_WAYLAND_POPUP_SURFACE (surface->role); - popup = meta_wayland_pointer_start_popup_grab (seat->pointer, - popup_surface); - if (popup == NULL) - { - zxdg_popup_v6_send_popup_done (xdg_popup->resource); - meta_wayland_shell_surface_destroy_window (shell_surface); - return; - } - - xdg_popup->popup = popup; - } - else - { - /* The keyboard focus semantics for non-grabbing zxdg_shell_v6 popups - * is pretty undefined. Same applies for subsurfaces, but in practice, - * subsurfaces never receive keyboard focus, so it makes sense to - * do the same for non-grabbing popups. - * - * See https://bugzilla.gnome.org/show_bug.cgi?id=771694#c24 - */ - window->input = FALSE; - } -} - -static void -meta_wayland_zxdg_popup_v6_apply_state (MetaWaylandSurfaceRole *surface_role, - MetaWaylandSurfaceState *pending) -{ - MetaWaylandZxdgPopupV6 *xdg_popup = META_WAYLAND_ZXDG_POPUP_V6 (surface_role); - MetaWaylandSurfaceRoleClass *surface_role_class; - - if (xdg_popup->setup.parent_surface) - finish_popup_setup (xdg_popup); - - surface_role_class = - META_WAYLAND_SURFACE_ROLE_CLASS (meta_wayland_zxdg_popup_v6_parent_class); - surface_role_class->apply_state (surface_role, pending); -} - -static void -meta_wayland_zxdg_popup_v6_post_apply_state (MetaWaylandSurfaceRole *surface_role, - MetaWaylandSurfaceState *pending) -{ - MetaWaylandZxdgSurfaceV6 *xdg_surface = - META_WAYLAND_ZXDG_SURFACE_V6 (surface_role); - MetaWaylandSurfaceRoleClass *surface_role_class; - MetaWaylandSurface *surface = - meta_wayland_surface_role_get_surface (surface_role); - MetaWindow *window; - - window = meta_wayland_surface_get_window (surface); - if (!window) - return; - - surface_role_class = - META_WAYLAND_SURFACE_ROLE_CLASS (meta_wayland_zxdg_popup_v6_parent_class); - surface_role_class->post_apply_state (surface_role, pending); - - if (!pending->newly_attached) - return; - - if (!surface->buffer_ref.buffer) - return; - - if (pending->has_acked_configure_serial) - { - MetaRectangle window_geometry; - - window_geometry = - meta_wayland_zxdg_surface_v6_get_window_geometry (xdg_surface); - meta_window_wayland_finish_move_resize (window, - window_geometry, - pending); - } -} - -static MetaWaylandSurface * -meta_wayland_zxdg_popup_v6_get_toplevel (MetaWaylandSurfaceRole *surface_role) -{ - MetaWaylandZxdgPopupV6 *xdg_popup = META_WAYLAND_ZXDG_POPUP_V6 (surface_role); - - if (xdg_popup->parent_surface) - return meta_wayland_surface_get_toplevel (xdg_popup->parent_surface); - else - return NULL; -} - -static void -meta_wayland_zxdg_popup_v6_configure (MetaWaylandShellSurface *shell_surface, - MetaWaylandWindowConfiguration *configuration) -{ - MetaWaylandZxdgPopupV6 *xdg_popup = - META_WAYLAND_ZXDG_POPUP_V6 (shell_surface); - MetaWaylandZxdgSurfaceV6 *xdg_surface = - META_WAYLAND_ZXDG_SURFACE_V6 (xdg_popup); - MetaWindow *parent_window = - meta_wayland_surface_get_window (xdg_popup->parent_surface); - int geometry_scale; - int x, y; - - /* If the parent surface was destroyed, its window will be destroyed - * before the popup receives the parent-destroy signal. This means that - * the popup may potentially get temporary focus until itself is destroyed. - * If this happen, don't try to configure the xdg_popup surface. - * - * FIXME: Could maybe add a signal that is emitted before the window is - * created so that we can avoid incorrect intermediate foci. - */ - if (!parent_window) - return; - - geometry_scale = meta_window_wayland_get_geometry_scale (parent_window); - x = configuration->rel_x / geometry_scale; - y = configuration->rel_y / geometry_scale; - - zxdg_popup_v6_send_configure (xdg_popup->resource, - x, y, - configuration->width / configuration->scale, - configuration->height / configuration->scale); - meta_wayland_zxdg_surface_v6_send_configure (xdg_surface, configuration); -} - -static void -meta_wayland_zxdg_popup_v6_managed (MetaWaylandShellSurface *shell_surface, - MetaWindow *window) -{ - MetaWaylandZxdgPopupV6 *xdg_popup = - META_WAYLAND_ZXDG_POPUP_V6 (shell_surface); - MetaWaylandSurface *parent = xdg_popup->parent_surface; - - g_assert (parent); - - meta_window_set_transient_for (window, - meta_wayland_surface_get_window (parent)); - meta_window_set_type (window, META_WINDOW_DROPDOWN_MENU); -} - -static void -meta_wayland_zxdg_popup_v6_shell_client_destroyed (MetaWaylandZxdgSurfaceV6 *xdg_surface) -{ - MetaWaylandZxdgPopupV6 *xdg_popup = META_WAYLAND_ZXDG_POPUP_V6 (xdg_surface); - struct wl_resource *xdg_shell_resource = - meta_wayland_zxdg_surface_v6_get_shell_resource (xdg_surface); - MetaWaylandZxdgSurfaceV6Class *xdg_surface_class = - META_WAYLAND_ZXDG_SURFACE_V6_CLASS (meta_wayland_zxdg_popup_v6_parent_class); - - xdg_surface_class->shell_client_destroyed (xdg_surface); - - if (xdg_popup->resource) - { - wl_resource_post_error (xdg_shell_resource, - ZXDG_SHELL_V6_ERROR_DEFUNCT_SURFACES, - "xdg_shell of xdg_popup@%d was destroyed", - wl_resource_get_id (xdg_popup->resource)); - - wl_resource_destroy (xdg_popup->resource); - } -} - -static void -meta_wayland_zxdg_popup_v6_done (MetaWaylandPopupSurface *popup_surface) -{ - MetaWaylandZxdgPopupV6 *xdg_popup = META_WAYLAND_ZXDG_POPUP_V6 (popup_surface); - - zxdg_popup_v6_send_popup_done (xdg_popup->resource); -} - -static void -meta_wayland_zxdg_popup_v6_dismiss (MetaWaylandPopupSurface *popup_surface) -{ - MetaWaylandZxdgPopupV6 *xdg_popup = - META_WAYLAND_ZXDG_POPUP_V6 (popup_surface); - MetaWaylandZxdgSurfaceV6 *xdg_surface = - META_WAYLAND_ZXDG_SURFACE_V6 (xdg_popup); - struct wl_resource *xdg_shell_resource = - meta_wayland_zxdg_surface_v6_get_shell_resource (xdg_surface); - MetaWaylandShellSurface *shell_surface = - META_WAYLAND_SHELL_SURFACE (xdg_popup); - MetaWaylandSurfaceRole *surface_role = META_WAYLAND_SURFACE_ROLE (xdg_popup); - MetaWaylandSurface *surface = - meta_wayland_surface_role_get_surface (surface_role); - MetaWaylandSurface *top_popup; - - top_popup = meta_wayland_popup_get_top_popup (xdg_popup->popup); - if (surface != top_popup) - { - wl_resource_post_error (xdg_shell_resource, - ZXDG_SHELL_V6_ERROR_NOT_THE_TOPMOST_POPUP, - "destroyed popup not top most popup"); - } - - xdg_popup->popup = NULL; - - meta_wayland_shell_surface_destroy_window (shell_surface); -} - -static MetaWaylandSurface * -meta_wayland_zxdg_popup_v6_get_surface (MetaWaylandPopupSurface *popup_surface) -{ - MetaWaylandSurfaceRole *surface_role = - META_WAYLAND_SURFACE_ROLE (popup_surface); - - return meta_wayland_surface_role_get_surface (surface_role); -} - -static void -popup_surface_iface_init (MetaWaylandPopupSurfaceInterface *iface) -{ - iface->done = meta_wayland_zxdg_popup_v6_done; - iface->dismiss = meta_wayland_zxdg_popup_v6_dismiss; - iface->get_surface = meta_wayland_zxdg_popup_v6_get_surface; -} - -static void -meta_wayland_zxdg_popup_v6_role_finalize (GObject *object) -{ - MetaWaylandZxdgPopupV6 *xdg_popup = META_WAYLAND_ZXDG_POPUP_V6 (object); - - g_clear_pointer (&xdg_popup->resource, wl_resource_destroy); - - G_OBJECT_CLASS (meta_wayland_zxdg_popup_v6_parent_class)->finalize (object); -} - -static void -meta_wayland_zxdg_popup_v6_init (MetaWaylandZxdgPopupV6 *role) -{ -} - -static void -meta_wayland_zxdg_popup_v6_class_init (MetaWaylandZxdgPopupV6Class *klass) -{ - GObjectClass *object_class; - MetaWaylandSurfaceRoleClass *surface_role_class; - MetaWaylandShellSurfaceClass *shell_surface_class; - MetaWaylandZxdgSurfaceV6Class *xdg_surface_class; - - object_class = G_OBJECT_CLASS (klass); - object_class->finalize = meta_wayland_zxdg_popup_v6_role_finalize; - - surface_role_class = META_WAYLAND_SURFACE_ROLE_CLASS (klass); - surface_role_class->apply_state = meta_wayland_zxdg_popup_v6_apply_state; - surface_role_class->post_apply_state = - meta_wayland_zxdg_popup_v6_post_apply_state; - surface_role_class->get_toplevel = meta_wayland_zxdg_popup_v6_get_toplevel; - - shell_surface_class = META_WAYLAND_SHELL_SURFACE_CLASS (klass); - shell_surface_class->configure = meta_wayland_zxdg_popup_v6_configure; - shell_surface_class->managed = meta_wayland_zxdg_popup_v6_managed; - - xdg_surface_class = META_WAYLAND_ZXDG_SURFACE_V6_CLASS (klass); - xdg_surface_class->shell_client_destroyed = - meta_wayland_zxdg_popup_v6_shell_client_destroyed; -} - -static struct wl_resource * -meta_wayland_zxdg_surface_v6_get_shell_resource (MetaWaylandZxdgSurfaceV6 *xdg_surface) -{ - MetaWaylandZxdgSurfaceV6Private *priv = - meta_wayland_zxdg_surface_v6_get_instance_private (xdg_surface); - - return priv->shell_client->resource; -} - -static MetaRectangle -meta_wayland_zxdg_surface_v6_get_window_geometry (MetaWaylandZxdgSurfaceV6 *xdg_surface) -{ - MetaWaylandZxdgSurfaceV6Private *priv = - meta_wayland_zxdg_surface_v6_get_instance_private (xdg_surface); - - return priv->geometry; -} - -static gboolean -meta_wayland_zxdg_surface_v6_is_assigned (MetaWaylandZxdgSurfaceV6 *xdg_surface) -{ - MetaWaylandZxdgSurfaceV6Private *priv = - meta_wayland_zxdg_surface_v6_get_instance_private (xdg_surface); - - return priv->resource != NULL; -} - -static void -meta_wayland_zxdg_surface_v6_send_configure (MetaWaylandZxdgSurfaceV6 *xdg_surface, - MetaWaylandWindowConfiguration *configuration) -{ - MetaWaylandZxdgSurfaceV6Private *priv = - meta_wayland_zxdg_surface_v6_get_instance_private (xdg_surface); - - zxdg_surface_v6_send_configure (priv->resource, configuration->serial); - - priv->configure_sent = TRUE; -} - -static void -zxdg_surface_v6_destructor (struct wl_resource *resource) -{ - MetaWaylandZxdgSurfaceV6 *xdg_surface = wl_resource_get_user_data (resource); - MetaWaylandZxdgSurfaceV6Private *priv = - meta_wayland_zxdg_surface_v6_get_instance_private (xdg_surface); - - priv->shell_client->surfaces = g_list_remove (priv->shell_client->surfaces, - xdg_surface); - - priv->resource = NULL; - priv->first_buffer_attached = FALSE; -} - -static void -zxdg_surface_v6_destroy (struct wl_client *client, - struct wl_resource *resource) -{ - wl_resource_destroy (resource); -} - -static void -zxdg_surface_v6_get_toplevel (struct wl_client *client, - struct wl_resource *resource, - uint32_t id) -{ - MetaWaylandZxdgSurfaceV6 *xdg_surface = wl_resource_get_user_data (resource); - MetaWaylandSurface *surface = surface_from_xdg_surface_resource (resource); - struct wl_resource *xdg_shell_resource = - meta_wayland_zxdg_surface_v6_get_shell_resource (xdg_surface); - - wl_resource_post_error (xdg_shell_resource, ZXDG_SHELL_V6_ERROR_ROLE, - "wl_surface@%d already has a role assigned", - wl_resource_get_id (surface->resource)); -} - -static void -zxdg_surface_v6_get_popup (struct wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct wl_resource *parent_resource, - struct wl_resource *positioner_resource) -{ - MetaWaylandZxdgSurfaceV6 *xdg_surface = wl_resource_get_user_data (resource); - MetaWaylandZxdgSurfaceV6Private *priv = - meta_wayland_zxdg_surface_v6_get_instance_private (xdg_surface); - MetaWaylandSurface *surface = surface_from_xdg_surface_resource (resource); - - wl_resource_post_error (priv->shell_client->resource, - ZXDG_SHELL_V6_ERROR_ROLE, - "wl_surface@%d already has a role assigned", - wl_resource_get_id (surface->resource)); -} - -static void -zxdg_surface_v6_set_window_geometry (struct wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y, - int32_t width, - int32_t height) -{ - MetaWaylandSurface *surface = surface_from_xdg_surface_resource (resource); - MetaWaylandSurfaceState *pending; - - pending = meta_wayland_surface_get_pending_state (surface); - pending->has_new_geometry = TRUE; - pending->new_geometry.x = x; - pending->new_geometry.y = y; - pending->new_geometry.width = width; - pending->new_geometry.height = height; -} - -static void -zxdg_surface_v6_ack_configure (struct wl_client *client, - struct wl_resource *resource, - uint32_t serial) -{ - MetaWaylandSurface *surface = surface_from_xdg_surface_resource (resource); - MetaWaylandSurfaceState *pending; - - pending = meta_wayland_surface_get_pending_state (surface); - pending->has_acked_configure_serial = TRUE; - pending->acked_configure_serial = serial; -} - -static const struct zxdg_surface_v6_interface meta_wayland_zxdg_surface_v6_interface = { - zxdg_surface_v6_destroy, - zxdg_surface_v6_get_toplevel, - zxdg_surface_v6_get_popup, - zxdg_surface_v6_set_window_geometry, - zxdg_surface_v6_ack_configure, -}; - -static void -meta_wayland_zxdg_surface_v6_finalize (GObject *object) -{ - MetaWaylandZxdgSurfaceV6 *xdg_surface = META_WAYLAND_ZXDG_SURFACE_V6 (object); - MetaWaylandZxdgSurfaceV6Private *priv = - meta_wayland_zxdg_surface_v6_get_instance_private (xdg_surface); - - g_clear_pointer (&priv->resource, wl_resource_destroy); - - G_OBJECT_CLASS (meta_wayland_zxdg_surface_v6_parent_class)->finalize (object); -} - -static void -meta_wayland_zxdg_surface_v6_apply_state (MetaWaylandSurfaceRole *surface_role, - MetaWaylandSurfaceState *pending) -{ - MetaWaylandZxdgSurfaceV6 *xdg_surface = - META_WAYLAND_ZXDG_SURFACE_V6 (surface_role); - MetaWaylandZxdgSurfaceV6Private *priv = - meta_wayland_zxdg_surface_v6_get_instance_private (xdg_surface); - MetaWaylandSurface *surface = - meta_wayland_surface_role_get_surface (surface_role); - MetaWindow *window = meta_wayland_surface_get_window (surface); - MetaWaylandSurfaceRoleClass *surface_role_class; - - surface_role_class = - META_WAYLAND_SURFACE_ROLE_CLASS (meta_wayland_zxdg_surface_v6_parent_class); - surface_role_class->apply_state (surface_role, pending); - - /* Ignore commits when unassigned. */ - if (!priv->resource) - return; - - if (surface->buffer_ref.buffer == NULL && priv->first_buffer_attached) - { - /* XDG surfaces can't commit NULL buffers */ - wl_resource_post_error (surface->resource, - WL_DISPLAY_ERROR_INVALID_OBJECT, - "Cannot commit a NULL buffer to an xdg_surface"); - return; - } - - if (surface->buffer_ref.buffer && !priv->configure_sent) - { - wl_resource_post_error (surface->resource, - ZXDG_SURFACE_V6_ERROR_UNCONFIGURED_BUFFER, - "buffer committed to unconfigured xdg_surface"); - return; - } - - if (!window) - return; - - if (surface->buffer_ref.buffer) - priv->first_buffer_attached = TRUE; -} - -static void -meta_wayland_zxdg_surface_v6_post_apply_state (MetaWaylandSurfaceRole *surface_role, - MetaWaylandSurfaceState *pending) -{ - MetaWaylandZxdgSurfaceV6 *xdg_surface = - META_WAYLAND_ZXDG_SURFACE_V6 (surface_role); - MetaWaylandZxdgSurfaceV6Private *priv = - meta_wayland_zxdg_surface_v6_get_instance_private (xdg_surface); - MetaWaylandShellSurface *shell_surface = - META_WAYLAND_SHELL_SURFACE (xdg_surface); - - if (pending->has_new_geometry) - { - meta_wayland_shell_surface_determine_geometry (shell_surface, - &pending->new_geometry, - &priv->geometry); - priv->has_set_geometry = TRUE; - } - else if (!priv->has_set_geometry) - { - MetaRectangle new_geometry = { 0 }; - - /* If the surface has never set any geometry, calculate - * a default one unioning the surface and all subsurfaces together. */ - - meta_wayland_shell_surface_calculate_geometry (shell_surface, - &new_geometry); - if (!meta_rectangle_equal (&new_geometry, &priv->geometry)) - { - pending->has_new_geometry = TRUE; - priv->geometry = new_geometry; - } - } -} - -static void -meta_wayland_zxdg_surface_v6_assigned (MetaWaylandSurfaceRole *surface_role) -{ - MetaWaylandZxdgSurfaceV6 *xdg_surface = - META_WAYLAND_ZXDG_SURFACE_V6 (surface_role); - MetaWaylandZxdgSurfaceV6Private *priv = - meta_wayland_zxdg_surface_v6_get_instance_private (xdg_surface); - MetaWaylandSurface *surface = - meta_wayland_surface_role_get_surface (surface_role); - struct wl_resource *xdg_shell_resource = - meta_wayland_zxdg_surface_v6_get_shell_resource (xdg_surface); - MetaWaylandSurfaceRoleClass *surface_role_class; - - priv->configure_sent = FALSE; - priv->first_buffer_attached = FALSE; - - if (surface->buffer_ref.buffer) - { - wl_resource_post_error (xdg_shell_resource, - ZXDG_SHELL_V6_ERROR_INVALID_SURFACE_STATE, - "wl_surface@%d already has a buffer committed", - wl_resource_get_id (surface->resource)); - return; - } - - surface_role_class = - META_WAYLAND_SURFACE_ROLE_CLASS (meta_wayland_zxdg_surface_v6_parent_class); - surface_role_class->assigned (surface_role); -} - -static void -meta_wayland_zxdg_surface_v6_ping (MetaWaylandShellSurface *shell_surface, - uint32_t serial) -{ - MetaWaylandZxdgSurfaceV6 *xdg_surface = - META_WAYLAND_ZXDG_SURFACE_V6 (shell_surface); - MetaWaylandZxdgSurfaceV6Private *priv = - meta_wayland_zxdg_surface_v6_get_instance_private (xdg_surface); - - zxdg_shell_v6_send_ping (priv->shell_client->resource, serial); -} - -static void -meta_wayland_zxdg_surface_v6_real_shell_client_destroyed (MetaWaylandZxdgSurfaceV6 *xdg_surface) -{ - MetaWaylandZxdgSurfaceV6Private *priv = - meta_wayland_zxdg_surface_v6_get_instance_private (xdg_surface); - - if (priv->resource) - { - wl_resource_post_error (priv->shell_client->resource, - ZXDG_SHELL_V6_ERROR_DEFUNCT_SURFACES, - "xdg_shell of xdg_surface@%d was destroyed", - wl_resource_get_id (priv->resource)); - - wl_resource_destroy (priv->resource); - } -} - -static void -meta_wayland_zxdg_surface_v6_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - MetaWaylandZxdgSurfaceV6 *xdg_surface = META_WAYLAND_ZXDG_SURFACE_V6 (object); - MetaWaylandZxdgSurfaceV6Private *priv = - meta_wayland_zxdg_surface_v6_get_instance_private (xdg_surface); - - switch (prop_id) - { - case ZXDG_SURFACE_V6_PROP_SHELL_CLIENT: - priv->shell_client = g_value_get_pointer (value); - break; - - case ZXDG_SURFACE_V6_PROP_RESOURCE: - priv->resource = g_value_get_pointer (value); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - } -} - -static void -meta_wayland_zxdg_surface_v6_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - MetaWaylandZxdgSurfaceV6 *xdg_surface = META_WAYLAND_ZXDG_SURFACE_V6 (object); - MetaWaylandZxdgSurfaceV6Private *priv = - meta_wayland_zxdg_surface_v6_get_instance_private (xdg_surface); - - switch (prop_id) - { - case ZXDG_SURFACE_V6_PROP_SHELL_CLIENT: - g_value_set_pointer (value, priv->shell_client); - break; - - case ZXDG_SURFACE_V6_PROP_RESOURCE: - g_value_set_pointer (value, priv->resource); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - } -} - -static void -meta_wayland_zxdg_surface_v6_init (MetaWaylandZxdgSurfaceV6 *xdg_surface) -{ -} - -static void -meta_wayland_zxdg_surface_v6_class_init (MetaWaylandZxdgSurfaceV6Class *klass) -{ - GObjectClass *object_class; - MetaWaylandSurfaceRoleClass *surface_role_class; - MetaWaylandShellSurfaceClass *shell_surface_class; - GParamSpec *pspec; - - object_class = G_OBJECT_CLASS (klass); - object_class->finalize = meta_wayland_zxdg_surface_v6_finalize; - object_class->set_property = meta_wayland_zxdg_surface_v6_set_property; - object_class->get_property = meta_wayland_zxdg_surface_v6_get_property; - - surface_role_class = META_WAYLAND_SURFACE_ROLE_CLASS (klass); - surface_role_class->apply_state = meta_wayland_zxdg_surface_v6_apply_state; - surface_role_class->post_apply_state = - meta_wayland_zxdg_surface_v6_post_apply_state; - surface_role_class->assigned = meta_wayland_zxdg_surface_v6_assigned; - - shell_surface_class = META_WAYLAND_SHELL_SURFACE_CLASS (klass); - shell_surface_class->ping = meta_wayland_zxdg_surface_v6_ping; - - klass->shell_client_destroyed = - meta_wayland_zxdg_surface_v6_real_shell_client_destroyed; - - pspec = g_param_spec_pointer ("shell-client", - "MetaWaylandZxdgShellV6Client", - "The shell client instance", - G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS); - g_object_class_install_property (object_class, - ZXDG_SURFACE_V6_PROP_SHELL_CLIENT, - pspec); - pspec = g_param_spec_pointer ("xdg-surface-resource", - "xdg_surface wl_resource", - "The xdg_surface wl_resource instance", - G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS); - g_object_class_install_property (object_class, - ZXDG_SURFACE_V6_PROP_RESOURCE, - pspec); -} - -static void -meta_wayland_zxdg_surface_v6_shell_client_destroyed (MetaWaylandZxdgSurfaceV6 *xdg_surface) -{ - MetaWaylandZxdgSurfaceV6Class *xdg_surface_class = - META_WAYLAND_ZXDG_SURFACE_V6_GET_CLASS (xdg_surface); - - xdg_surface_class->shell_client_destroyed (xdg_surface); -} - -static void -meta_wayland_zxdg_surface_v6_constructor_finalize (MetaWaylandZxdgSurfaceV6Constructor *constructor, - MetaWaylandZxdgSurfaceV6 *xdg_surface) -{ - MetaWaylandZxdgShellV6Client *shell_client = constructor->shell_client; - - shell_client->surface_constructors = - g_list_remove (shell_client->surface_constructors, constructor); - shell_client->surfaces = g_list_append (shell_client->surfaces, xdg_surface); - - wl_resource_set_implementation (constructor->resource, - &meta_wayland_zxdg_surface_v6_interface, - xdg_surface, - zxdg_surface_v6_destructor); - - g_free (constructor); -} - -static void -zxdg_surface_v6_constructor_destroy (struct wl_client *client, - struct wl_resource *resource) -{ - wl_resource_post_error (resource, - ZXDG_SURFACE_V6_ERROR_NOT_CONSTRUCTED, - "xdg_surface destroyed before constructed"); - wl_resource_destroy (resource); -} - -static void -zxdg_surface_v6_constructor_get_toplevel (struct wl_client *client, - struct wl_resource *resource, - uint32_t id) -{ - MetaWaylandZxdgSurfaceV6Constructor *constructor = - wl_resource_get_user_data (resource); - MetaWaylandZxdgShellV6Client *shell_client = constructor->shell_client; - struct wl_resource *xdg_surface_resource = constructor->resource; - MetaWaylandSurface *surface = constructor->surface; - MetaWaylandZxdgToplevelV6 *xdg_toplevel; - MetaWaylandZxdgSurfaceV6 *xdg_surface; - MetaWaylandShellSurface *shell_surface; - MetaWindow *window; - - if (!meta_wayland_surface_assign_role (surface, - META_TYPE_WAYLAND_ZXDG_TOPLEVEL_V6, - "shell-client", shell_client, - "xdg-surface-resource", xdg_surface_resource, - NULL)) - { - wl_resource_post_error (resource, ZXDG_SHELL_V6_ERROR_ROLE, - "wl_surface@%d already has a different role", - wl_resource_get_id (surface->resource)); - return; - } - - xdg_toplevel = META_WAYLAND_ZXDG_TOPLEVEL_V6 (surface->role); - xdg_toplevel->resource = wl_resource_create (client, - &zxdg_toplevel_v6_interface, - wl_resource_get_version (resource), - id); - wl_resource_set_implementation (xdg_toplevel->resource, - &meta_wayland_zxdg_toplevel_v6_interface, - xdg_toplevel, - zxdg_toplevel_v6_destructor); - - xdg_surface = META_WAYLAND_ZXDG_SURFACE_V6 (xdg_toplevel); - meta_wayland_zxdg_surface_v6_constructor_finalize (constructor, xdg_surface); - - window = meta_window_wayland_new (meta_get_display (), surface); - shell_surface = META_WAYLAND_SHELL_SURFACE (xdg_surface); - meta_wayland_shell_surface_set_window (shell_surface, window); -} - -static void -zxdg_surface_v6_constructor_get_popup (struct wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct wl_resource *parent_resource, - struct wl_resource *positioner_resource) -{ - MetaWaylandZxdgSurfaceV6Constructor *constructor = - wl_resource_get_user_data (resource); - MetaWaylandZxdgShellV6Client *shell_client = constructor->shell_client; - MetaWaylandSurface *surface = constructor->surface; - struct wl_resource *xdg_shell_resource = constructor->shell_client->resource; - struct wl_resource *xdg_surface_resource = constructor->resource; - MetaWaylandSurface *parent_surface = - surface_from_xdg_surface_resource (parent_resource); - MetaWaylandZxdgPositionerV6 *xdg_positioner; - MetaWaylandZxdgPopupV6 *xdg_popup; - MetaWaylandZxdgSurfaceV6 *xdg_surface; - - if (!meta_wayland_surface_assign_role (surface, - META_TYPE_WAYLAND_ZXDG_POPUP_V6, - "shell-client", shell_client, - "xdg-surface-resource", xdg_surface_resource, - NULL)) - { - wl_resource_post_error (xdg_shell_resource, ZXDG_SHELL_V6_ERROR_ROLE, - "wl_surface@%d already has a different role", - wl_resource_get_id (surface->resource)); - return; - } - - if (!META_IS_WAYLAND_ZXDG_SURFACE_V6 (parent_surface->role)) - { - wl_resource_post_error (xdg_shell_resource, - ZXDG_SHELL_V6_ERROR_INVALID_POPUP_PARENT, - "Invalid popup parent role"); - return; - } - - xdg_popup = META_WAYLAND_ZXDG_POPUP_V6 (surface->role); - - xdg_popup->resource = wl_resource_create (client, - &zxdg_popup_v6_interface, - wl_resource_get_version (resource), - id); - wl_resource_set_implementation (xdg_popup->resource, - &meta_wayland_zxdg_popup_v6_interface, - xdg_popup, - zxdg_popup_v6_destructor); - - xdg_surface = META_WAYLAND_ZXDG_SURFACE_V6 (xdg_popup); - meta_wayland_zxdg_surface_v6_constructor_finalize (constructor, xdg_surface); - - xdg_positioner = wl_resource_get_user_data (positioner_resource); - xdg_popup->setup.placement_rule = - meta_wayland_zxdg_positioner_v6_to_placement (xdg_positioner); - xdg_popup->setup.parent_surface = parent_surface; -} - -static void -zxdg_surface_v6_constructor_set_window_geometry (struct wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y, - int32_t width, - int32_t height) -{ - wl_resource_post_error (resource, - ZXDG_SURFACE_V6_ERROR_NOT_CONSTRUCTED, - "xdg_surface::set_window_geometry called before constructed"); -} - -static void -zxdg_surface_v6_constructor_ack_configure (struct wl_client *client, - struct wl_resource *resource, - uint32_t serial) -{ - wl_resource_post_error (resource, - ZXDG_SURFACE_V6_ERROR_NOT_CONSTRUCTED, - "xdg_surface::ack_configure called before constructed"); -} - -static const struct zxdg_surface_v6_interface meta_wayland_zxdg_surface_v6_constructor_interface = { - zxdg_surface_v6_constructor_destroy, - zxdg_surface_v6_constructor_get_toplevel, - zxdg_surface_v6_constructor_get_popup, - zxdg_surface_v6_constructor_set_window_geometry, - zxdg_surface_v6_constructor_ack_configure, -}; - -static void -zxdg_surface_v6_constructor_destructor (struct wl_resource *resource) -{ - MetaWaylandZxdgSurfaceV6Constructor *constructor = - wl_resource_get_user_data (resource); - - constructor->shell_client->surface_constructors = - g_list_remove (constructor->shell_client->surface_constructors, - constructor); - - g_free (constructor); -} - -static MetaPlacementRule -meta_wayland_zxdg_positioner_v6_to_placement (MetaWaylandZxdgPositionerV6 *xdg_positioner) -{ - return (MetaPlacementRule) { - .anchor_rect = xdg_positioner->anchor_rect, - .gravity = xdg_positioner->gravity, - .anchor = xdg_positioner->anchor, - .constraint_adjustment = xdg_positioner->constraint_adjustment, - .offset_x = xdg_positioner->offset_x, - .offset_y = xdg_positioner->offset_y, - .width = xdg_positioner->width, - .height = xdg_positioner->height, - }; -} - -static void -zxdg_positioner_v6_destroy (struct wl_client *client, - struct wl_resource *resource) -{ - wl_resource_destroy (resource); -} - -static void -zxdg_positioner_v6_set_size (struct wl_client *client, - struct wl_resource *resource, - int32_t width, - int32_t height) -{ - MetaWaylandZxdgPositionerV6 *positioner = wl_resource_get_user_data (resource); - - if (width <= 0 || height <= 0) - { - wl_resource_post_error (resource, ZXDG_POSITIONER_V6_ERROR_INVALID_INPUT, - "Invalid size"); - return; - } - - positioner->width = width; - positioner->height = height; -} - -static void -zxdg_positioner_v6_set_anchor_rect (struct wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y, - int32_t width, - int32_t height) -{ - MetaWaylandZxdgPositionerV6 *positioner = wl_resource_get_user_data (resource); - - if (width <= 0 || height <= 0) - { - wl_resource_post_error (resource, ZXDG_POSITIONER_V6_ERROR_INVALID_INPUT, - "Invalid anchor rectangle size"); - return; - } - - positioner->anchor_rect = (MetaRectangle) { - .x = x, - .y = y, - .width = width, - .height = height, - }; -} - -static void -zxdg_positioner_v6_set_anchor (struct wl_client *client, - struct wl_resource *resource, - uint32_t anchor) -{ - MetaWaylandZxdgPositionerV6 *positioner = wl_resource_get_user_data (resource); - - if ((anchor & ZXDG_POSITIONER_V6_ANCHOR_LEFT && - anchor & ZXDG_POSITIONER_V6_ANCHOR_RIGHT) || - (anchor & ZXDG_POSITIONER_V6_ANCHOR_TOP && - anchor & ZXDG_POSITIONER_V6_ANCHOR_BOTTOM)) - { - wl_resource_post_error (resource, ZXDG_POSITIONER_V6_ERROR_INVALID_INPUT, - "Invalid anchor"); - return; - } - - positioner->anchor = anchor; -} - -static void -zxdg_positioner_v6_set_gravity (struct wl_client *client, - struct wl_resource *resource, - uint32_t gravity) -{ - MetaWaylandZxdgPositionerV6 *positioner = wl_resource_get_user_data (resource); - - if ((gravity & ZXDG_POSITIONER_V6_GRAVITY_LEFT && - gravity & ZXDG_POSITIONER_V6_GRAVITY_RIGHT) || - (gravity & ZXDG_POSITIONER_V6_GRAVITY_TOP && - gravity & ZXDG_POSITIONER_V6_GRAVITY_BOTTOM)) - { - wl_resource_post_error (resource, ZXDG_POSITIONER_V6_ERROR_INVALID_INPUT, - "Invalid gravity"); - return; - } - - positioner->gravity = gravity; -} - -static void -zxdg_positioner_v6_set_constraint_adjustment (struct wl_client *client, - struct wl_resource *resource, - uint32_t constraint_adjustment) -{ - MetaWaylandZxdgPositionerV6 *positioner = wl_resource_get_user_data (resource); - uint32_t all_adjustments = (ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_SLIDE_X | - ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_FLIP_X | - ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_SLIDE_Y | - ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_FLIP_Y | - ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_RESIZE_X | - ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_RESIZE_Y); - - if ((constraint_adjustment & ~all_adjustments) != 0) - { - wl_resource_post_error (resource, ZXDG_POSITIONER_V6_ERROR_INVALID_INPUT, - "Invalid constraint action"); - return; - } - - positioner->constraint_adjustment = constraint_adjustment; -} - -static void -zxdg_positioner_v6_set_offset (struct wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y) -{ - MetaWaylandZxdgPositionerV6 *positioner = wl_resource_get_user_data (resource); - - positioner->offset_x = x; - positioner->offset_y = y; -} - -static const struct zxdg_positioner_v6_interface meta_wayland_zxdg_positioner_v6_interface = { - zxdg_positioner_v6_destroy, - zxdg_positioner_v6_set_size, - zxdg_positioner_v6_set_anchor_rect, - zxdg_positioner_v6_set_anchor, - zxdg_positioner_v6_set_gravity, - zxdg_positioner_v6_set_constraint_adjustment, - zxdg_positioner_v6_set_offset, -}; - -static void -zxdg_positioner_v6_destructor (struct wl_resource *resource) -{ - MetaWaylandZxdgPositionerV6 *positioner = wl_resource_get_user_data (resource); - - g_free (positioner); -} - -static void -zxdg_shell_v6_destroy (struct wl_client *client, - struct wl_resource *resource) -{ - MetaWaylandZxdgShellV6Client *shell_client = wl_resource_get_user_data (resource); - - if (shell_client->surfaces || shell_client->surface_constructors) - wl_resource_post_error (resource, ZXDG_SHELL_V6_ERROR_DEFUNCT_SURFACES, - "xdg_shell destroyed before its surfaces"); - - wl_resource_destroy (resource); -} - -static void -zxdg_shell_v6_create_positioner (struct wl_client *client, - struct wl_resource *resource, - uint32_t id) -{ - MetaWaylandZxdgPositionerV6 *positioner; - struct wl_resource *positioner_resource; - - positioner = g_new0 (MetaWaylandZxdgPositionerV6, 1); - positioner_resource = wl_resource_create (client, - &zxdg_positioner_v6_interface, - wl_resource_get_version (resource), - id); - wl_resource_set_implementation (positioner_resource, - &meta_wayland_zxdg_positioner_v6_interface, - positioner, - zxdg_positioner_v6_destructor); -} - -static void -zxdg_shell_v6_get_xdg_surface (struct wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct wl_resource *surface_resource) -{ - MetaWaylandZxdgShellV6Client *shell_client = wl_resource_get_user_data (resource); - MetaWaylandSurface *surface = wl_resource_get_user_data (surface_resource); - MetaWaylandZxdgSurfaceV6 *xdg_surface = NULL; - MetaWaylandZxdgSurfaceV6Constructor *constructor; - - if (surface->role && !META_IS_WAYLAND_ZXDG_SURFACE_V6 (surface->role)) - { - wl_resource_post_error (resource, ZXDG_SHELL_V6_ERROR_ROLE, - "wl_surface@%d already has a different role", - wl_resource_get_id (surface->resource)); - return; - } - - if (surface->role) - xdg_surface = META_WAYLAND_ZXDG_SURFACE_V6 (surface->role); - if (xdg_surface && meta_wayland_zxdg_surface_v6_is_assigned (xdg_surface)) - { - wl_resource_post_error (surface_resource, - WL_DISPLAY_ERROR_INVALID_OBJECT, - "zxdg_shell_v6::get_xdg_surface already requested"); - return; - } - - if (surface->buffer_ref.buffer) - { - wl_resource_post_error (resource, - ZXDG_SHELL_V6_ERROR_INVALID_SURFACE_STATE, - "wl_surface@%d already has a buffer committed", - wl_resource_get_id (surface->resource)); - return; - } - - constructor = g_new0 (MetaWaylandZxdgSurfaceV6Constructor, 1); - constructor->surface = surface; - constructor->shell_client = shell_client; - constructor->resource = wl_resource_create (client, - &zxdg_surface_v6_interface, - wl_resource_get_version (resource), - id); - wl_resource_set_implementation (constructor->resource, - &meta_wayland_zxdg_surface_v6_constructor_interface, - constructor, - zxdg_surface_v6_constructor_destructor); - - shell_client->surface_constructors = - g_list_append (shell_client->surface_constructors, constructor); -} - -static void -zxdg_shell_v6_pong (struct wl_client *client, - struct wl_resource *resource, - uint32_t serial) -{ - MetaDisplay *display = meta_get_display (); - - meta_display_pong_for_serial (display, serial); -} - -static const struct zxdg_shell_v6_interface meta_wayland_zxdg_shell_v6_interface = { - zxdg_shell_v6_destroy, - zxdg_shell_v6_create_positioner, - zxdg_shell_v6_get_xdg_surface, - zxdg_shell_v6_pong, -}; - -static void -meta_wayland_zxdg_shell_v6_client_destroy (MetaWaylandZxdgShellV6Client *shell_client) -{ - while (shell_client->surface_constructors) - { - MetaWaylandZxdgSurfaceV6Constructor *constructor = - g_list_first (shell_client->surface_constructors)->data; - - wl_resource_destroy (constructor->resource); - } - g_list_free (shell_client->surface_constructors); - - while (shell_client->surfaces) - { - MetaWaylandZxdgSurfaceV6 *xdg_surface = - g_list_first (shell_client->surfaces)->data; - - meta_wayland_zxdg_surface_v6_shell_client_destroyed (xdg_surface); - } - g_list_free (shell_client->surfaces); - - g_free (shell_client); -} - -static void -zxdg_shell_v6_destructor (struct wl_resource *resource) -{ - MetaWaylandZxdgShellV6Client *shell_client = wl_resource_get_user_data (resource); - - meta_wayland_zxdg_shell_v6_client_destroy (shell_client); -} - -static void -bind_zxdg_shell_v6 (struct wl_client *client, - void *data, - guint32 version, - guint32 id) -{ - MetaWaylandZxdgShellV6Client *shell_client; - - shell_client = g_new0 (MetaWaylandZxdgShellV6Client, 1); - - shell_client->resource = wl_resource_create (client, - &zxdg_shell_v6_interface, - version, id); - wl_resource_set_implementation (shell_client->resource, - &meta_wayland_zxdg_shell_v6_interface, - shell_client, zxdg_shell_v6_destructor); -} - -void -meta_wayland_legacy_xdg_shell_init (MetaWaylandCompositor *compositor) -{ - if (wl_global_create (compositor->wayland_display, - &zxdg_shell_v6_interface, - META_ZXDG_SHELL_V6_VERSION, - compositor, bind_zxdg_shell_v6) == NULL) - g_error ("Failed to register a global xdg-shell object"); -} diff --git a/src/wayland/meta-wayland-legacy-xdg-shell.h b/src/wayland/meta-wayland-legacy-xdg-shell.h deleted file mode 100644 index 8a07dfb29..000000000 --- a/src/wayland/meta-wayland-legacy-xdg-shell.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2013-2015 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_LEGACY_XDG_SHELL_H -#define META_WAYLAND_LEGACY_XDG_SHELL_H - -#include "wayland/meta-wayland-shell-surface.h" -#include "wayland/meta-wayland-surface.h" - -#define META_TYPE_WAYLAND_ZXDG_SURFACE_V6 (meta_wayland_zxdg_surface_v6_get_type ()) -G_DECLARE_DERIVABLE_TYPE (MetaWaylandZxdgSurfaceV6, - meta_wayland_zxdg_surface_v6, - META, WAYLAND_ZXDG_SURFACE_V6, - MetaWaylandShellSurface) - -struct _MetaWaylandZxdgSurfaceV6Class -{ - MetaWaylandShellSurfaceClass parent_class; - - void (*shell_client_destroyed) (MetaWaylandZxdgSurfaceV6 *xdg_surface); -}; - -#define META_TYPE_WAYLAND_ZXDG_TOPLEVEL_V6 (meta_wayland_zxdg_toplevel_v6_get_type ()) -G_DECLARE_FINAL_TYPE (MetaWaylandZxdgToplevelV6, - meta_wayland_zxdg_toplevel_v6, - META, WAYLAND_ZXDG_TOPLEVEL_V6, - MetaWaylandZxdgSurfaceV6); - -#define META_TYPE_WAYLAND_ZXDG_POPUP_V6 (meta_wayland_zxdg_popup_v6_get_type ()) -G_DECLARE_FINAL_TYPE (MetaWaylandZxdgPopupV6, - meta_wayland_zxdg_popup_v6, - META, WAYLAND_ZXDG_POPUP_V6, - MetaWaylandZxdgSurfaceV6); - -void meta_wayland_legacy_xdg_shell_init (MetaWaylandCompositor *compositor); - -#endif /* META_WAYLAND_LEGACY_XDG_SHELL_H */ diff --git a/src/wayland/meta-wayland-seat.c b/src/wayland/meta-wayland-seat.c index 10dbc4e97..2315fecee 100644 --- a/src/wayland/meta-wayland-seat.c +++ b/src/wayland/meta-wayland-seat.c @@ -24,7 +24,6 @@ #include "wayland/meta-wayland-seat.h" #include "wayland/meta-wayland-data-device.h" -#include "wayland/meta-wayland-data-device-primary-legacy.h" #include "wayland/meta-wayland-private.h" #include "wayland/meta-wayland-tablet-seat.h" #include "wayland/meta-wayland-versions.h" @@ -237,11 +236,9 @@ meta_wayland_seat_new (MetaWaylandCompositor *compositor, NULL); seat->text_input = meta_wayland_text_input_new (seat); - seat->gtk_text_input = meta_wayland_gtk_text_input_new (seat); meta_wayland_data_device_init (&seat->data_device); meta_wayland_data_device_primary_init (&seat->primary_data_device); - meta_wayland_data_device_primary_legacy_init (&seat->primary_legacy_data_device); clutter_seat = clutter_backend_get_default_seat (clutter_get_default_backend ()); meta_wayland_seat_update_capabilities (seat, clutter_seat); @@ -276,7 +273,6 @@ meta_wayland_seat_free (MetaWaylandSeat *seat) g_object_unref (seat->pointer); g_object_unref (seat->keyboard); g_object_unref (seat->touch); - meta_wayland_gtk_text_input_destroy (seat->gtk_text_input); meta_wayland_text_input_destroy (seat->text_input); g_free (seat); @@ -400,10 +396,6 @@ meta_wayland_seat_handle_event (MetaWaylandSeat *seat, if (meta_wayland_text_input_handle_event (seat->text_input, event)) return TRUE; - if (meta_wayland_gtk_text_input_handle_event (seat->gtk_text_input, - event)) - return TRUE; - if (meta_wayland_seat_has_keyboard (seat)) return meta_wayland_keyboard_handle_event (seat->keyboard, (const ClutterKeyEvent *) event); @@ -420,9 +412,6 @@ meta_wayland_seat_handle_event (MetaWaylandSeat *seat, case CLUTTER_IM_PREEDIT: if (meta_wayland_text_input_handle_event (seat->text_input, event)) return TRUE; - if (meta_wayland_gtk_text_input_handle_event (seat->gtk_text_input, - event)) - return TRUE; break; default: @@ -453,14 +442,12 @@ meta_wayland_seat_set_input_focus (MetaWaylandSeat *seat, meta_wayland_keyboard_set_focus (seat->keyboard, surface); meta_wayland_data_device_set_keyboard_focus (&seat->data_device); meta_wayland_data_device_primary_set_keyboard_focus (&seat->primary_data_device); - meta_wayland_data_device_primary_legacy_set_keyboard_focus (&seat->primary_legacy_data_device); } tablet_seat = meta_wayland_tablet_manager_ensure_seat (compositor->tablet_manager, seat); meta_wayland_tablet_seat_set_pad_focus (tablet_seat, surface); meta_wayland_text_input_set_focus (seat->text_input, surface); - meta_wayland_gtk_text_input_set_focus (seat->gtk_text_input, surface); } gboolean diff --git a/src/wayland/meta-wayland-seat.h b/src/wayland/meta-wayland-seat.h index f41c44207..2e20a201c 100644 --- a/src/wayland/meta-wayland-seat.h +++ b/src/wayland/meta-wayland-seat.h @@ -27,13 +27,11 @@ #include "clutter/clutter.h" #include "wayland/meta-wayland-data-device.h" #include "wayland/meta-wayland-data-device-primary.h" -#include "wayland/meta-wayland-data-device-primary-legacy.h" #include "wayland/meta-wayland-input-device.h" #include "wayland/meta-wayland-keyboard.h" #include "wayland/meta-wayland-pointer.h" #include "wayland/meta-wayland-tablet-tool.h" #include "wayland/meta-wayland-text-input.h" -#include "wayland/meta-wayland-text-input-legacy.h" #include "wayland/meta-wayland-touch.h" #include "wayland/meta-wayland-types.h" @@ -48,9 +46,7 @@ struct _MetaWaylandSeat MetaWaylandDataDevice data_device; MetaWaylandDataDevicePrimary primary_data_device; - MetaWaylandDataDevicePrimaryLegacy primary_legacy_data_device; - MetaWaylandGtkTextInput *gtk_text_input; MetaWaylandTextInput *text_input; guint capabilities; diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c index befac4f84..5eb049b02 100644 --- a/src/wayland/meta-wayland-surface.c +++ b/src/wayland/meta-wayland-surface.c @@ -43,7 +43,6 @@ #include "wayland/meta-wayland-data-device.h" #include "wayland/meta-wayland-gtk-shell.h" #include "wayland/meta-wayland-keyboard.h" -#include "wayland/meta-wayland-legacy-xdg-shell.h" #include "wayland/meta-wayland-outputs.h" #include "wayland/meta-wayland-pointer.h" #include "wayland/meta-wayland-private.h" @@ -51,7 +50,6 @@ #include "wayland/meta-wayland-seat.h" #include "wayland/meta-wayland-subsurface.h" #include "wayland/meta-wayland-viewporter.h" -#include "wayland/meta-wayland-wl-shell.h" #include "wayland/meta-wayland-xdg-shell.h" #include "wayland/meta-window-wayland.h" #include "wayland/meta-xwayland-private.h" @@ -1438,14 +1436,12 @@ meta_wayland_surface_begin_grab_op (MetaWaylandSurface *surface, * @compositor: The #MetaWaylandCompositor object * * Initializes the Wayland interfaces providing features that deal with - * desktop-specific conundrums, like XDG shell, wl_shell (deprecated), etc. + * desktop-specific conundrums, like XDG shell, etc. */ void meta_wayland_shell_init (MetaWaylandCompositor *compositor) { meta_wayland_xdg_shell_init (compositor); - meta_wayland_legacy_xdg_shell_init (compositor); - meta_wayland_wl_shell_init (compositor); meta_wayland_init_gtk_shell (compositor); meta_wayland_init_viewporter (compositor); } diff --git a/src/wayland/meta-wayland-text-input-legacy.c b/src/wayland/meta-wayland-text-input-legacy.c deleted file mode 100644 index 442708e0f..000000000 --- a/src/wayland/meta-wayland-text-input-legacy.c +++ /dev/null @@ -1,633 +0,0 @@ -/* - * Copyright (C) 2017, 2018 Red Hat - * - * 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. - * - * Author: Carlos Garnacho - */ - -#include "config.h" - -#include - -#include "wayland/meta-wayland-private.h" -#include "wayland/meta-wayland-seat.h" -#include "wayland/meta-wayland-text-input-legacy.h" -#include "wayland/meta-wayland-versions.h" - -#include "gtk-text-input-server-protocol.h" - -#define META_TYPE_WAYLAND_GTK_TEXT_INPUT_FOCUS (meta_wayland_gtk_text_input_focus_get_type ()) - -typedef enum -{ - META_WAYLAND_PENDING_STATE_NONE = 0, - META_WAYLAND_PENDING_STATE_INPUT_RECT = 1 << 0, - META_WAYLAND_PENDING_STATE_CONTENT_TYPE = 1 << 1, - META_WAYLAND_PENDING_STATE_SURROUNDING_TEXT = 1 << 2, -} MetaWaylandTextInputPendingState; - -typedef struct _MetaWaylandGtkTextInput MetaWaylandGtkTextInput; - -struct _MetaWaylandGtkTextInput -{ - MetaWaylandSeat *seat; - ClutterInputFocus *input_focus; - - struct wl_list resource_list; - struct wl_list focus_resource_list; - MetaWaylandSurface *surface; - struct wl_listener surface_listener; - uint32_t focus_serial; - - MetaWaylandTextInputPendingState pending_state; - - struct - { - char *text; - uint32_t cursor; - uint32_t anchor; - } surrounding; - - cairo_rectangle_int_t cursor_rect; - - uint32_t content_type_hint; - uint32_t content_type_purpose; -}; - -struct _MetaWaylandGtkTextInputFocus -{ - ClutterInputFocus parent_instance; - MetaWaylandGtkTextInput *text_input; -}; - -G_DECLARE_FINAL_TYPE (MetaWaylandGtkTextInputFocus, - meta_wayland_gtk_text_input_focus, - META, WAYLAND_GTK_TEXT_INPUT_FOCUS, ClutterInputFocus) -G_DEFINE_TYPE (MetaWaylandGtkTextInputFocus, meta_wayland_gtk_text_input_focus, - CLUTTER_TYPE_INPUT_FOCUS) - -static void -meta_wayland_text_input_focus_request_surrounding (ClutterInputFocus *focus) -{ - MetaWaylandGtkTextInput *text_input; - - text_input = META_WAYLAND_GTK_TEXT_INPUT_FOCUS (focus)->text_input; - clutter_input_focus_set_surrounding (focus, - text_input->surrounding.text, - text_input->surrounding.cursor, - text_input->surrounding.anchor); -} - -static void -meta_wayland_text_input_focus_delete_surrounding (ClutterInputFocus *focus, - int offset, - guint len) -{ - MetaWaylandGtkTextInput *text_input; - uint32_t before_length; - uint32_t after_length; - struct wl_resource *resource; - - text_input = META_WAYLAND_GTK_TEXT_INPUT_FOCUS (focus)->text_input; - before_length = ABS (MIN (offset, 0)); - after_length = MAX (0, offset + len); - g_warn_if_fail (ABS (offset) <= len); - - wl_resource_for_each (resource, &text_input->focus_resource_list) - { - gtk_text_input_send_delete_surrounding_text (resource, - before_length, - after_length); - } -} - -static void -meta_wayland_text_input_focus_commit_text (ClutterInputFocus *focus, - const gchar *text) -{ - MetaWaylandGtkTextInput *text_input; - struct wl_resource *resource; - - text_input = META_WAYLAND_GTK_TEXT_INPUT_FOCUS (focus)->text_input; - - wl_resource_for_each (resource, &text_input->focus_resource_list) - { - gtk_text_input_send_preedit_string (resource, NULL, 0); - gtk_text_input_send_commit_string (resource, text); - } -} - -static void -meta_wayland_text_input_focus_set_preedit_text (ClutterInputFocus *focus, - const gchar *text, - guint cursor) -{ - MetaWaylandGtkTextInput *text_input; - struct wl_resource *resource; - - text_input = META_WAYLAND_GTK_TEXT_INPUT_FOCUS (focus)->text_input; - - wl_resource_for_each (resource, &text_input->focus_resource_list) - { - gtk_text_input_send_preedit_string (resource, text, cursor); - } -} - -static void -meta_wayland_gtk_text_input_focus_class_init (MetaWaylandGtkTextInputFocusClass *klass) -{ - ClutterInputFocusClass *focus_class = CLUTTER_INPUT_FOCUS_CLASS (klass); - - focus_class->request_surrounding = meta_wayland_text_input_focus_request_surrounding; - focus_class->delete_surrounding = meta_wayland_text_input_focus_delete_surrounding; - focus_class->commit_text = meta_wayland_text_input_focus_commit_text; - focus_class->set_preedit_text = meta_wayland_text_input_focus_set_preedit_text; -} - -static void -meta_wayland_gtk_text_input_focus_init (MetaWaylandGtkTextInputFocus *focus) -{ -} - -static ClutterInputFocus * -meta_wayland_text_input_focus_new (MetaWaylandGtkTextInput *text_input) -{ - MetaWaylandGtkTextInputFocus *focus; - - focus = g_object_new (META_TYPE_WAYLAND_GTK_TEXT_INPUT_FOCUS, NULL); - focus->text_input = text_input; - - return CLUTTER_INPUT_FOCUS (focus); -} - -static void -text_input_handle_focus_surface_destroy (struct wl_listener *listener, - void *data) -{ - MetaWaylandGtkTextInput *text_input = wl_container_of (listener, text_input, - surface_listener); - - meta_wayland_gtk_text_input_set_focus (text_input, NULL); -} - -static void -move_resources (struct wl_list *destination, struct wl_list *source) -{ - wl_list_insert_list (destination, source); - wl_list_init (source); -} - -static void -move_resources_for_client (struct wl_list *destination, - struct wl_list *source, - struct wl_client *client) -{ - struct wl_resource *resource, *tmp; - wl_resource_for_each_safe (resource, tmp, source) - { - if (wl_resource_get_client (resource) == client) - { - wl_list_remove (wl_resource_get_link (resource)); - wl_list_insert (destination, wl_resource_get_link (resource)); - } - } -} - -void -meta_wayland_gtk_text_input_set_focus (MetaWaylandGtkTextInput *text_input, - MetaWaylandSurface *surface) -{ - if (text_input->surface == surface) - return; - - text_input->pending_state = META_WAYLAND_PENDING_STATE_NONE; - - if (text_input->surface) - { - if (!wl_list_empty (&text_input->focus_resource_list)) - { - ClutterInputFocus *focus = text_input->input_focus; - ClutterInputMethod *input_method; - struct wl_resource *resource; - uint32_t serial; - - if (clutter_input_focus_is_focused (focus)) - { - input_method = clutter_backend_get_input_method (clutter_get_default_backend ()); - clutter_input_method_focus_out (input_method); - } - - serial = wl_display_next_serial (text_input->seat->wl_display); - - wl_resource_for_each (resource, &text_input->focus_resource_list) - { - gtk_text_input_send_leave (resource, serial, - text_input->surface->resource); - } - - move_resources (&text_input->resource_list, - &text_input->focus_resource_list); - } - - wl_list_remove (&text_input->surface_listener.link); - text_input->surface = NULL; - } - - if (surface) - { - struct wl_resource *focus_surface_resource; - - text_input->surface = surface; - focus_surface_resource = text_input->surface->resource; - wl_resource_add_destroy_listener (focus_surface_resource, - &text_input->surface_listener); - - move_resources_for_client (&text_input->focus_resource_list, - &text_input->resource_list, - wl_resource_get_client (focus_surface_resource)); - - if (!wl_list_empty (&text_input->focus_resource_list)) - { - struct wl_resource *resource; - - text_input->focus_serial = - wl_display_next_serial (text_input->seat->wl_display); - - wl_resource_for_each (resource, &text_input->focus_resource_list) - { - gtk_text_input_send_enter (resource, text_input->focus_serial, - surface->resource); - } - } - } -} - -static void -unbind_resource (struct wl_resource *resource) -{ - wl_list_remove (wl_resource_get_link (resource)); -} - -static void -text_input_destroy (struct wl_client *client, - struct wl_resource *resource) -{ - wl_resource_destroy (resource); -} - -static void -text_input_enable (struct wl_client *client, - struct wl_resource *resource, - uint32_t serial, - uint32_t flags) -{ - MetaWaylandGtkTextInput *text_input = wl_resource_get_user_data (resource); - ClutterInputFocus *focus = text_input->input_focus; - ClutterInputMethod *input_method; - gboolean show_preedit; - - if (serial != text_input->focus_serial) - return; - - if (!clutter_input_focus_is_focused (focus)) - { - input_method = clutter_backend_get_input_method (clutter_get_default_backend ()); - if (input_method) - clutter_input_method_focus_in (input_method, focus); - else - return; - } - - show_preedit = (flags & GTK_TEXT_INPUT_ENABLE_FLAGS_CAN_SHOW_PREEDIT) != 0; - clutter_input_focus_set_can_show_preedit (focus, show_preedit); - - if (flags & GTK_TEXT_INPUT_ENABLE_FLAGS_TOGGLE_INPUT_PANEL) - clutter_input_focus_set_input_panel_state (focus, CLUTTER_INPUT_PANEL_STATE_TOGGLE); -} - -static void -text_input_disable (struct wl_client *client, - struct wl_resource *resource) -{ - MetaWaylandGtkTextInput *text_input = wl_resource_get_user_data (resource); - ClutterInputFocus *focus = text_input->input_focus; - ClutterInputMethod *input_method; - - if (!clutter_input_focus_is_focused (focus)) - return; - - clutter_input_focus_reset (text_input->input_focus); - text_input->pending_state = META_WAYLAND_PENDING_STATE_NONE; - - input_method = clutter_backend_get_input_method (clutter_get_default_backend ()); - clutter_input_method_focus_out (input_method); -} - -static void -text_input_set_surrounding_text (struct wl_client *client, - struct wl_resource *resource, - const char *text, - int32_t cursor, - int32_t anchor) -{ - MetaWaylandGtkTextInput *text_input = wl_resource_get_user_data (resource); - - g_free (text_input->surrounding.text); - text_input->surrounding.text = g_strdup (text); - text_input->surrounding.cursor = cursor; - text_input->surrounding.anchor = anchor; - text_input->pending_state |= META_WAYLAND_PENDING_STATE_SURROUNDING_TEXT; -} - -static ClutterInputContentHintFlags -translate_hints (uint32_t hints) -{ - ClutterInputContentHintFlags clutter_hints = 0; - - if (hints & GTK_TEXT_INPUT_CONTENT_HINT_COMPLETION) - clutter_hints |= CLUTTER_INPUT_CONTENT_HINT_COMPLETION; - if (hints & GTK_TEXT_INPUT_CONTENT_HINT_SPELLCHECK) - clutter_hints |= CLUTTER_INPUT_CONTENT_HINT_SPELLCHECK; - if (hints & GTK_TEXT_INPUT_CONTENT_HINT_AUTO_CAPITALIZATION) - clutter_hints |= CLUTTER_INPUT_CONTENT_HINT_AUTO_CAPITALIZATION; - if (hints & GTK_TEXT_INPUT_CONTENT_HINT_LOWERCASE) - clutter_hints |= CLUTTER_INPUT_CONTENT_HINT_LOWERCASE; - if (hints & GTK_TEXT_INPUT_CONTENT_HINT_UPPERCASE) - clutter_hints |= CLUTTER_INPUT_CONTENT_HINT_UPPERCASE; - if (hints & GTK_TEXT_INPUT_CONTENT_HINT_TITLECASE) - clutter_hints |= CLUTTER_INPUT_CONTENT_HINT_TITLECASE; - if (hints & GTK_TEXT_INPUT_CONTENT_HINT_HIDDEN_TEXT) - clutter_hints |= CLUTTER_INPUT_CONTENT_HINT_HIDDEN_TEXT; - if (hints & GTK_TEXT_INPUT_CONTENT_HINT_SENSITIVE_DATA) - clutter_hints |= CLUTTER_INPUT_CONTENT_HINT_SENSITIVE_DATA; - if (hints & GTK_TEXT_INPUT_CONTENT_HINT_LATIN) - clutter_hints |= CLUTTER_INPUT_CONTENT_HINT_LATIN; - if (hints & GTK_TEXT_INPUT_CONTENT_HINT_MULTILINE) - clutter_hints |= CLUTTER_INPUT_CONTENT_HINT_MULTILINE; - - return clutter_hints; -} - -static ClutterInputContentPurpose -translate_purpose (uint32_t purpose) -{ - switch (purpose) - { - case GTK_TEXT_INPUT_CONTENT_PURPOSE_NORMAL: - return CLUTTER_INPUT_CONTENT_PURPOSE_NORMAL; - case GTK_TEXT_INPUT_CONTENT_PURPOSE_ALPHA: - return CLUTTER_INPUT_CONTENT_PURPOSE_ALPHA; - case GTK_TEXT_INPUT_CONTENT_PURPOSE_DIGITS: - return CLUTTER_INPUT_CONTENT_PURPOSE_DIGITS; - case GTK_TEXT_INPUT_CONTENT_PURPOSE_NUMBER: - return CLUTTER_INPUT_CONTENT_PURPOSE_NUMBER; - case GTK_TEXT_INPUT_CONTENT_PURPOSE_PHONE: - return CLUTTER_INPUT_CONTENT_PURPOSE_PHONE; - case GTK_TEXT_INPUT_CONTENT_PURPOSE_URL: - return CLUTTER_INPUT_CONTENT_PURPOSE_URL; - case GTK_TEXT_INPUT_CONTENT_PURPOSE_EMAIL: - return CLUTTER_INPUT_CONTENT_PURPOSE_EMAIL; - case GTK_TEXT_INPUT_CONTENT_PURPOSE_NAME: - return CLUTTER_INPUT_CONTENT_PURPOSE_NAME; - case GTK_TEXT_INPUT_CONTENT_PURPOSE_PASSWORD: - return CLUTTER_INPUT_CONTENT_PURPOSE_PASSWORD; - case GTK_TEXT_INPUT_CONTENT_PURPOSE_DATE: - return CLUTTER_INPUT_CONTENT_PURPOSE_DATE; - case GTK_TEXT_INPUT_CONTENT_PURPOSE_TIME: - return CLUTTER_INPUT_CONTENT_PURPOSE_TIME; - case GTK_TEXT_INPUT_CONTENT_PURPOSE_DATETIME: - return CLUTTER_INPUT_CONTENT_PURPOSE_DATETIME; - case GTK_TEXT_INPUT_CONTENT_PURPOSE_TERMINAL: - return CLUTTER_INPUT_CONTENT_PURPOSE_TERMINAL; - } - - g_warn_if_reached (); - return CLUTTER_INPUT_CONTENT_PURPOSE_NORMAL; -} - -static void -text_input_set_content_type (struct wl_client *client, - struct wl_resource *resource, - uint32_t hint, - uint32_t purpose) -{ - MetaWaylandGtkTextInput *text_input = wl_resource_get_user_data (resource); - - if (!text_input->surface) - return; - - text_input->content_type_hint = hint; - text_input->content_type_purpose = purpose; - text_input->pending_state |= META_WAYLAND_PENDING_STATE_CONTENT_TYPE; -} - -static void -text_input_set_cursor_rectangle (struct wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y, - int32_t width, - int32_t height) -{ - MetaWaylandGtkTextInput *text_input = wl_resource_get_user_data (resource); - - if (!text_input->surface) - return; - - text_input->cursor_rect = (cairo_rectangle_int_t) { x, y, width, height }; - text_input->pending_state |= META_WAYLAND_PENDING_STATE_INPUT_RECT; -} - -static void -text_input_commit_state (struct wl_client *client, - struct wl_resource *resource) -{ - MetaWaylandGtkTextInput *text_input = wl_resource_get_user_data (resource); - ClutterInputFocus *focus = text_input->input_focus; - - if (!clutter_input_focus_is_focused (focus)) - return; - if (text_input->surface == NULL) - return; - - if (text_input->pending_state & META_WAYLAND_PENDING_STATE_CONTENT_TYPE) - { - clutter_input_focus_set_content_hints (text_input->input_focus, - translate_hints (text_input->content_type_hint)); - clutter_input_focus_set_content_purpose (text_input->input_focus, - translate_purpose (text_input->content_type_purpose)); - } - - if (text_input->pending_state & META_WAYLAND_PENDING_STATE_SURROUNDING_TEXT) - { - clutter_input_focus_set_surrounding (text_input->input_focus, - text_input->surrounding.text, - text_input->surrounding.cursor, - text_input->surrounding.anchor); - } - - if (text_input->pending_state & META_WAYLAND_PENDING_STATE_INPUT_RECT) - { - graphene_rect_t cursor_rect; - float x1, y1, x2, y2; - cairo_rectangle_int_t rect; - - rect = text_input->cursor_rect; - meta_wayland_surface_get_absolute_coordinates (text_input->surface, - rect.x, rect.y, &x1, &y1); - meta_wayland_surface_get_absolute_coordinates (text_input->surface, - rect.x + rect.width, - rect.y + rect.height, - &x2, &y2); - - graphene_rect_init (&cursor_rect, x1, y1, x2 - x1, y2 - y1); - clutter_input_focus_set_cursor_location (text_input->input_focus, - &cursor_rect); - } - - text_input->pending_state = META_WAYLAND_PENDING_STATE_NONE; -} - -static struct gtk_text_input_interface meta_text_input_interface = { - text_input_destroy, - text_input_enable, - text_input_disable, - text_input_set_surrounding_text, - text_input_set_content_type, - text_input_set_cursor_rectangle, - text_input_commit_state, -}; - -MetaWaylandGtkTextInput * -meta_wayland_gtk_text_input_new (MetaWaylandSeat *seat) -{ - MetaWaylandGtkTextInput *text_input; - - text_input = g_new0 (MetaWaylandGtkTextInput, 1); - text_input->input_focus = meta_wayland_text_input_focus_new (text_input); - text_input->seat = seat; - - wl_list_init (&text_input->resource_list); - wl_list_init (&text_input->focus_resource_list); - text_input->surface_listener.notify = text_input_handle_focus_surface_destroy; - - return text_input; -} - -void -meta_wayland_gtk_text_input_destroy (MetaWaylandGtkTextInput *text_input) -{ - meta_wayland_gtk_text_input_set_focus (text_input, NULL); - g_object_unref (text_input->input_focus); - g_free (text_input); -} - -static void -meta_wayland_text_input_create_new_resource (MetaWaylandGtkTextInput *text_input, - struct wl_client *client, - struct wl_resource *seat_resource, - uint32_t id) -{ - struct wl_resource *text_input_resource; - - text_input_resource = wl_resource_create (client, - >k_text_input_interface, - META_GTK_TEXT_INPUT_VERSION, - id); - - wl_resource_set_implementation (text_input_resource, - &meta_text_input_interface, - text_input, unbind_resource); - - if (text_input->surface && - wl_resource_get_client (text_input->surface->resource) == client) - { - wl_list_insert (&text_input->focus_resource_list, - wl_resource_get_link (text_input_resource)); - - gtk_text_input_send_enter (text_input_resource, - text_input->focus_serial, - text_input->surface->resource); - } - else - { - wl_list_insert (&text_input->resource_list, - wl_resource_get_link (text_input_resource)); - } -} - -static void -text_input_manager_destroy (struct wl_client *client, - struct wl_resource *resource) -{ - wl_resource_destroy (resource); -} - -static void -text_input_manager_get_text_input (struct wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct wl_resource *seat_resource) -{ - MetaWaylandSeat *seat = wl_resource_get_user_data (seat_resource); - - meta_wayland_text_input_create_new_resource (seat->gtk_text_input, client, - seat_resource, id); -} - -static struct gtk_text_input_manager_interface meta_text_input_manager_interface = { - text_input_manager_destroy, - text_input_manager_get_text_input, -}; - -static void -bind_text_input (struct wl_client *client, - void *data, - uint32_t version, - uint32_t id) -{ - struct wl_resource *resource; - - resource = wl_resource_create (client, - >k_text_input_manager_interface, - META_GTK_TEXT_INPUT_VERSION, - id); - wl_resource_set_implementation (resource, - &meta_text_input_manager_interface, - NULL, NULL); -} - -gboolean -meta_wayland_gtk_text_input_init (MetaWaylandCompositor *compositor) -{ - return (wl_global_create (compositor->wayland_display, - >k_text_input_manager_interface, - META_GTK_TEXT_INPUT_VERSION, - compositor->seat->gtk_text_input, - bind_text_input) != NULL); -} - -gboolean -meta_wayland_gtk_text_input_handle_event (MetaWaylandGtkTextInput *text_input, - const ClutterEvent *event) -{ - if (!text_input->surface || - !clutter_input_focus_is_focused (text_input->input_focus)) - return FALSE; - - return clutter_input_focus_filter_event (text_input->input_focus, event); -} diff --git a/src/wayland/meta-wayland-text-input-legacy.h b/src/wayland/meta-wayland-text-input-legacy.h deleted file mode 100644 index 55bfed809..000000000 --- a/src/wayland/meta-wayland-text-input-legacy.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2017 Red Hat - * - * 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. - * - * Author: Carlos Garnacho - */ - -#ifndef META_WAYLAND_GTK_TEXT_INPUT_H -#define META_WAYLAND_GTK_TEXT_INPUT_H - -#include - -#include "meta/window.h" -#include "wayland/meta-wayland-types.h" - -typedef struct _MetaWaylandGtkTextInput MetaWaylandGtkTextInput; - -MetaWaylandGtkTextInput * meta_wayland_gtk_text_input_new (MetaWaylandSeat *seat); -void meta_wayland_gtk_text_input_destroy (MetaWaylandGtkTextInput *text_input); - -gboolean meta_wayland_gtk_text_input_init (MetaWaylandCompositor *compositor); - -void meta_wayland_gtk_text_input_set_focus (MetaWaylandGtkTextInput *text_input, - MetaWaylandSurface *surface); - -gboolean meta_wayland_gtk_text_input_handle_event (MetaWaylandGtkTextInput *text_input, - const ClutterEvent *event); - -#endif /* META_WAYLAND_GTK_TEXT_INPUT_H */ diff --git a/src/wayland/meta-wayland-types.h b/src/wayland/meta-wayland-types.h index 00712ad1f..23d066d56 100644 --- a/src/wayland/meta-wayland-types.h +++ b/src/wayland/meta-wayland-types.h @@ -38,7 +38,6 @@ typedef struct _MetaWaylandDragDestFuncs MetaWaylandDragDestFuncs; typedef struct _MetaWaylandDataOffer MetaWaylandDataOffer; typedef struct _MetaWaylandDataDevice MetaWaylandDataDevice; typedef struct _MetaWaylandDataDevicePrimary MetaWaylandDataDevicePrimary; -typedef struct _MetaWaylandDataDevicePrimaryLegacy MetaWaylandDataDevicePrimaryLegacy; typedef struct _MetaWaylandTabletManager MetaWaylandTabletManager; typedef struct _MetaWaylandTabletSeat MetaWaylandTabletSeat; diff --git a/src/wayland/meta-wayland-versions.h b/src/wayland/meta-wayland-versions.h index 2d6ce5ace..f4856ac83 100644 --- a/src/wayland/meta-wayland-versions.h +++ b/src/wayland/meta-wayland-versions.h @@ -38,8 +38,6 @@ #define META_WL_COMPOSITOR_VERSION 4 #define META_WL_DATA_DEVICE_MANAGER_VERSION 3 #define META_XDG_WM_BASE_VERSION 3 -#define META_ZXDG_SHELL_V6_VERSION 1 -#define META_WL_SHELL_VERSION 1 #define META_WL_SEAT_VERSION 5 #define META_WL_OUTPUT_VERSION 2 #define META_XSERVER_VERSION 1 @@ -52,8 +50,8 @@ #define META_ZWP_KEYBOARD_SHORTCUTS_INHIBIT_V1_VERSION 1 #define META_ZXDG_OUTPUT_V1_VERSION 3 #define META_ZWP_XWAYLAND_KEYBOARD_GRAB_V1_VERSION 1 -#define META_GTK_TEXT_INPUT_VERSION 1 #define META_ZWP_TEXT_INPUT_V3_VERSION 1 #define META_WP_VIEWPORTER_VERSION 1 +#define META_ZWP_PRIMARY_SELECTION_V1_VERSION 1 #endif diff --git a/src/wayland/meta-wayland-wl-shell.c b/src/wayland/meta-wayland-wl-shell.c deleted file mode 100644 index d6d76195a..000000000 --- a/src/wayland/meta-wayland-wl-shell.c +++ /dev/null @@ -1,780 +0,0 @@ -/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ - -/* - * Copyright (C) 2012-2013 Intel Corporation - * Copyright (C) 2013-2015 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. - * - */ - -#include "config.h" - -#include "wayland/meta-wayland-wl-shell.h" - -#include "core/window-private.h" -#include "wayland/meta-wayland-popup.h" -#include "wayland/meta-wayland-private.h" -#include "wayland/meta-wayland-seat.h" -#include "wayland/meta-wayland-shell-surface.h" -#include "wayland/meta-wayland-surface.h" -#include "wayland/meta-wayland-versions.h" -#include "wayland/meta-wayland-window-configuration.h" -#include "wayland/meta-wayland.h" -#include "wayland/meta-window-wayland.h" - -typedef enum -{ - META_WL_SHELL_SURFACE_STATE_NONE, - META_WL_SHELL_SURFACE_STATE_TOPLEVEL, - META_WL_SHELL_SURFACE_STATE_POPUP, - META_WL_SHELL_SURFACE_STATE_TRANSIENT, - META_WL_SHELL_SURFACE_STATE_FULLSCREEN, - META_WL_SHELL_SURFACE_STATE_MAXIMIZED, -} MetaWlShellSurfaceState; - -struct _MetaWaylandWlShellSurface -{ - MetaWaylandShellSurface parent; - - struct wl_resource *resource; - - MetaWlShellSurfaceState state; - - char *title; - char *wm_class; - - MetaWaylandSurface *parent_surface; - GList *children; - - MetaWaylandSeat *popup_seat; - MetaWaylandPopup *popup; - gboolean pending_popup; - - int x; - int y; - - uint32_t emulated_ack_configure_serial; -}; - -static void -popup_surface_iface_init (MetaWaylandPopupSurfaceInterface *iface); - -G_DEFINE_TYPE_WITH_CODE (MetaWaylandWlShellSurface, - meta_wayland_wl_shell_surface, - META_TYPE_WAYLAND_SHELL_SURFACE, - G_IMPLEMENT_INTERFACE (META_TYPE_WAYLAND_POPUP_SURFACE, - popup_surface_iface_init)); - -static MetaWaylandSurface * -surface_from_wl_shell_surface_resource (struct wl_resource *resource) -{ - MetaWaylandWlShellSurface *wl_shell_surface = - wl_resource_get_user_data (resource); - MetaWaylandSurfaceRole *surface_role = - META_WAYLAND_SURFACE_ROLE (wl_shell_surface); - - return meta_wayland_surface_role_get_surface (surface_role); -} - -static void -sync_wl_shell_parent_relationship (MetaWaylandSurface *surface, - MetaWaylandSurface *parent); - -static void -wl_shell_surface_destructor (struct wl_resource *resource) -{ - MetaWaylandWlShellSurface *wl_shell_surface = - META_WAYLAND_WL_SHELL_SURFACE (wl_resource_get_user_data (resource)); - MetaWaylandSurface *surface = - surface_from_wl_shell_surface_resource (resource); - GList *l; - - if (wl_shell_surface->popup) - meta_wayland_popup_dismiss (wl_shell_surface->popup); - - for (l = wl_shell_surface->children; l; l = l->next) - { - MetaWaylandSurface *child_surface = l->data; - MetaWaylandWlShellSurface *child_wl_shell_surface = - META_WAYLAND_WL_SHELL_SURFACE (child_surface->role); - - child_wl_shell_surface->parent_surface = NULL; - - if (child_wl_shell_surface->parent_surface == surface) - { - meta_wayland_popup_dismiss (child_wl_shell_surface->popup); - child_wl_shell_surface->parent_surface = NULL; - } - } - - if (wl_shell_surface->parent_surface) - { - MetaWaylandSurface *parent_surface = wl_shell_surface->parent_surface; - MetaWaylandWlShellSurface *parent_wl_shell_surface = - META_WAYLAND_WL_SHELL_SURFACE (parent_surface->role); - - parent_wl_shell_surface->children = - g_list_remove (parent_wl_shell_surface->children, surface); - } - - g_free (wl_shell_surface->title); - g_free (wl_shell_surface->wm_class); - - if (wl_shell_surface->popup) - { - wl_shell_surface->parent_surface = NULL; - - meta_wayland_popup_dismiss (wl_shell_surface->popup); - } - - wl_shell_surface->resource = NULL; -} - -static void -wl_shell_surface_pong (struct wl_client *client, - struct wl_resource *resource, - uint32_t serial) -{ - MetaDisplay *display = meta_get_display (); - - meta_display_pong_for_serial (display, serial); -} - -static void -wl_shell_surface_move (struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *seat_resource, - uint32_t serial) -{ - MetaWaylandSeat *seat = wl_resource_get_user_data (seat_resource); - MetaWaylandSurface *surface = - surface_from_wl_shell_surface_resource (resource); - gfloat x, y; - - if (!meta_wayland_seat_get_grab_info (seat, surface, serial, TRUE, &x, &y)) - return; - - meta_wayland_surface_begin_grab_op (surface, seat, META_GRAB_OP_MOVING, x, y); -} - -static MetaGrabOp -grab_op_for_wl_shell_surface_resize_edge (int edge) -{ - MetaGrabOp op = META_GRAB_OP_WINDOW_BASE; - - if (edge & WL_SHELL_SURFACE_RESIZE_TOP) - op |= META_GRAB_OP_WINDOW_DIR_NORTH; - if (edge & WL_SHELL_SURFACE_RESIZE_BOTTOM) - op |= META_GRAB_OP_WINDOW_DIR_SOUTH; - if (edge & WL_SHELL_SURFACE_RESIZE_LEFT) - op |= META_GRAB_OP_WINDOW_DIR_WEST; - if (edge & WL_SHELL_SURFACE_RESIZE_RIGHT) - op |= META_GRAB_OP_WINDOW_DIR_EAST; - - if (op == META_GRAB_OP_WINDOW_BASE) - { - g_warning ("invalid edge: %d", edge); - return META_GRAB_OP_NONE; - } - - return op; -} - -static void -wl_shell_surface_resize (struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *seat_resource, - uint32_t serial, - uint32_t edges) -{ - MetaWaylandSeat *seat = wl_resource_get_user_data (seat_resource); - MetaWaylandSurface *surface = - surface_from_wl_shell_surface_resource (resource); - gfloat x, y; - MetaGrabOp grab_op; - - if (!meta_wayland_seat_get_grab_info (seat, surface, serial, TRUE, &x, &y)) - return; - - grab_op = grab_op_for_wl_shell_surface_resize_edge (edges); - meta_wayland_surface_begin_grab_op (surface, seat, grab_op, x, y); -} - -static void -wl_shell_surface_set_state (MetaWaylandSurface *surface, - MetaWlShellSurfaceState state) -{ - MetaWaylandWlShellSurface *wl_shell_surface = - META_WAYLAND_WL_SHELL_SURFACE (surface->role); - MetaWlShellSurfaceState old_state = wl_shell_surface->state; - MetaWindow *window; - - wl_shell_surface->state = state; - - window = meta_wayland_surface_get_window (surface); - if (window && old_state != state) - { - if (old_state == META_WL_SHELL_SURFACE_STATE_POPUP && - wl_shell_surface->popup) - { - meta_wayland_popup_dismiss (wl_shell_surface->popup); - wl_shell_surface->popup = NULL; - } - - if (state == META_WL_SHELL_SURFACE_STATE_FULLSCREEN) - meta_window_make_fullscreen (window); - else - meta_window_unmake_fullscreen (window); - - if (state == META_WL_SHELL_SURFACE_STATE_MAXIMIZED) - meta_window_maximize (window, META_MAXIMIZE_BOTH); - else - meta_window_unmaximize (window, META_MAXIMIZE_BOTH); - } -} - -static void -wl_shell_surface_set_toplevel (struct wl_client *client, - struct wl_resource *resource) -{ - MetaWaylandSurface *surface = - surface_from_wl_shell_surface_resource (resource); - - wl_shell_surface_set_state (surface, - META_WL_SHELL_SURFACE_STATE_TOPLEVEL); -} - -static void -set_wl_shell_surface_parent (MetaWaylandSurface *surface, - MetaWaylandSurface *parent) -{ - MetaWaylandWlShellSurface *wl_shell_surface = - META_WAYLAND_WL_SHELL_SURFACE (surface->role); - MetaWaylandWlShellSurface *parent_wl_shell_surface = - META_WAYLAND_WL_SHELL_SURFACE (parent->role); - - if (wl_shell_surface->parent_surface) - { - MetaWaylandWlShellSurface *old_parent = - META_WAYLAND_WL_SHELL_SURFACE (wl_shell_surface->parent_surface->role); - - old_parent->children = g_list_remove (old_parent->children, surface); - } - - parent_wl_shell_surface->children = - g_list_append (parent_wl_shell_surface->children, surface); - wl_shell_surface->parent_surface = parent; -} - -static void -wl_shell_surface_set_transient (struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *parent_resource, - int32_t x, - int32_t y, - uint32_t flags) -{ - MetaWaylandWlShellSurface *wl_shell_surface = - META_WAYLAND_WL_SHELL_SURFACE (wl_resource_get_user_data (resource)); - MetaWaylandSurface *surface = - surface_from_wl_shell_surface_resource (resource); - MetaWaylandSurface *parent_surf = wl_resource_get_user_data (parent_resource); - - wl_shell_surface_set_state (surface, - META_WL_SHELL_SURFACE_STATE_TRANSIENT); - - set_wl_shell_surface_parent (surface, parent_surf); - wl_shell_surface->x = x; - wl_shell_surface->y = y; - - if (meta_wayland_surface_get_window (surface) && - meta_wayland_surface_get_window (parent_surf)) - sync_wl_shell_parent_relationship (surface, parent_surf); -} - -static void -wl_shell_surface_set_fullscreen (struct wl_client *client, - struct wl_resource *resource, - uint32_t method, - uint32_t framerate, - struct wl_resource *output) -{ - MetaWaylandSurface *surface = - surface_from_wl_shell_surface_resource (resource); - - wl_shell_surface_set_state (surface, - META_WL_SHELL_SURFACE_STATE_FULLSCREEN); -} - -static void -meta_wayland_wl_shell_surface_create_popup (MetaWaylandWlShellSurface *wl_shell_surface) -{ - MetaWaylandPopupSurface *popup_surface = - META_WAYLAND_POPUP_SURFACE (wl_shell_surface); - MetaWaylandSeat *seat = wl_shell_surface->popup_seat; - MetaWaylandPopup *popup; - - popup = meta_wayland_pointer_start_popup_grab (seat->pointer, popup_surface); - if (!popup) - { - wl_shell_surface_send_popup_done (wl_shell_surface->resource); - return; - } - - wl_shell_surface->popup = popup; -} - -static void -wl_shell_surface_set_popup (struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *seat_resource, - uint32_t serial, - struct wl_resource *parent_resource, - int32_t x, - int32_t y, - uint32_t flags) -{ - MetaWaylandWlShellSurface *wl_shell_surface = - META_WAYLAND_WL_SHELL_SURFACE (wl_resource_get_user_data (resource)); - MetaWaylandSurface *surface = - surface_from_wl_shell_surface_resource (resource); - MetaWaylandSurface *parent_surf = wl_resource_get_user_data (parent_resource); - MetaWaylandSeat *seat = wl_resource_get_user_data (seat_resource); - - if (wl_shell_surface->popup) - { - wl_shell_surface->parent_surface = NULL; - - meta_wayland_popup_dismiss (wl_shell_surface->popup); - } - - wl_shell_surface_set_state (surface, - META_WL_SHELL_SURFACE_STATE_POPUP); - - if (!meta_wayland_seat_can_popup (seat, serial)) - { - wl_shell_surface_send_popup_done (resource); - return; - } - - set_wl_shell_surface_parent (surface, parent_surf); - wl_shell_surface->popup_seat = seat; - wl_shell_surface->x = x; - wl_shell_surface->y = y; - wl_shell_surface->pending_popup = TRUE; - - if (meta_wayland_surface_get_window (surface) && - meta_wayland_surface_get_window (parent_surf)) - sync_wl_shell_parent_relationship (surface, parent_surf); -} - -static void -wl_shell_surface_set_maximized (struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *output) -{ - MetaWaylandSurface *surface = - surface_from_wl_shell_surface_resource (resource); - - wl_shell_surface_set_state (surface, - META_WL_SHELL_SURFACE_STATE_MAXIMIZED); -} - -static void -wl_shell_surface_set_title (struct wl_client *client, - struct wl_resource *resource, - const char *title) -{ - MetaWaylandWlShellSurface *wl_shell_surface = - META_WAYLAND_WL_SHELL_SURFACE (wl_resource_get_user_data (resource)); - MetaWaylandSurface *surface = - surface_from_wl_shell_surface_resource (resource); - MetaWindow *window; - - g_clear_pointer (&wl_shell_surface->title, g_free); - - if (!g_utf8_validate (title, -1, NULL)) - title = ""; - - wl_shell_surface->title = g_strdup (title); - - window = meta_wayland_surface_get_window (surface); - if (window) - meta_window_set_title (window, title); -} - -static void -wl_shell_surface_set_class (struct wl_client *client, - struct wl_resource *resource, - const char *class_) -{ - MetaWaylandWlShellSurface *wl_shell_surface = - META_WAYLAND_WL_SHELL_SURFACE (wl_resource_get_user_data (resource)); - MetaWaylandSurface *surface = - surface_from_wl_shell_surface_resource (resource); - MetaWindow *window; - - g_clear_pointer (&wl_shell_surface->wm_class, g_free); - - if (!g_utf8_validate (class_, -1, NULL)) - class_ = ""; - - wl_shell_surface->wm_class = g_strdup (class_); - - window = meta_wayland_surface_get_window (surface); - if (window) - meta_window_set_wm_class (window, class_, class_); -} - -static const struct wl_shell_surface_interface meta_wayland_wl_shell_surface_interface = { - wl_shell_surface_pong, - wl_shell_surface_move, - wl_shell_surface_resize, - wl_shell_surface_set_toplevel, - wl_shell_surface_set_transient, - wl_shell_surface_set_fullscreen, - wl_shell_surface_set_popup, - wl_shell_surface_set_maximized, - wl_shell_surface_set_title, - wl_shell_surface_set_class, -}; - -static void -sync_wl_shell_parent_relationship (MetaWaylandSurface *surface, - MetaWaylandSurface *parent) -{ - MetaWaylandWlShellSurface *wl_shell_surface = - META_WAYLAND_WL_SHELL_SURFACE (surface->role); - MetaWindow *window; - MetaWindow *parent_window; - - window = meta_wayland_surface_get_window (surface); - parent_window = meta_wayland_surface_get_window (parent); - meta_window_set_transient_for (window, parent_window); - - if (wl_shell_surface->state == META_WL_SHELL_SURFACE_STATE_POPUP || - wl_shell_surface->state == META_WL_SHELL_SURFACE_STATE_TRANSIENT) - meta_window_wayland_place_relative_to (window, - parent_window, - wl_shell_surface->x, - wl_shell_surface->y); - - if (wl_shell_surface->state == META_WL_SHELL_SURFACE_STATE_POPUP && - wl_shell_surface->pending_popup) - { - meta_wayland_wl_shell_surface_create_popup (wl_shell_surface); - wl_shell_surface->pending_popup = FALSE; - } -} - -static void -create_wl_shell_surface_window (MetaWaylandSurface *surface) -{ - MetaWaylandWlShellSurface *wl_shell_surface = - META_WAYLAND_WL_SHELL_SURFACE (surface->role); - MetaWaylandShellSurface *shell_surface = - META_WAYLAND_SHELL_SURFACE (wl_shell_surface); - MetaWaylandSurface *parent; - MetaWindow *window; - GList *l; - - window = meta_window_wayland_new (meta_get_display (), surface); - meta_wayland_shell_surface_set_window (shell_surface, window); - - if (wl_shell_surface->title) - meta_window_set_title (window, wl_shell_surface->title); - if (wl_shell_surface->wm_class) - meta_window_set_wm_class (window, - wl_shell_surface->wm_class, - wl_shell_surface->wm_class); - - parent = wl_shell_surface->parent_surface; - if (parent && meta_wayland_surface_get_window (parent)) - sync_wl_shell_parent_relationship (surface, parent); - - for (l = wl_shell_surface->children; l; l = l->next) - { - MetaWaylandSurface *child = l->data; - - if (meta_wayland_surface_get_window (child)) - sync_wl_shell_parent_relationship (child, surface); - } -} - -static void -wl_shell_get_shell_surface (struct wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct wl_resource *surface_resource) -{ - MetaWaylandSurface *surface = wl_resource_get_user_data (surface_resource); - MetaWaylandWlShellSurface *wl_shell_surface; - - if (META_IS_WAYLAND_WL_SHELL_SURFACE (surface->role) && - META_WAYLAND_WL_SHELL_SURFACE (surface->role)->resource) - { - wl_resource_post_error (surface_resource, - WL_DISPLAY_ERROR_INVALID_OBJECT, - "wl_shell::get_shell_surface already requested"); - return; - } - - if (!meta_wayland_surface_assign_role (surface, - META_TYPE_WAYLAND_WL_SHELL_SURFACE, - NULL)) - { - wl_resource_post_error (resource, WL_SHELL_ERROR_ROLE, - "wl_surface@%d already has a different role", - wl_resource_get_id (surface->resource)); - return; - } - - wl_shell_surface = META_WAYLAND_WL_SHELL_SURFACE (surface->role); - wl_shell_surface->resource = - wl_resource_create (client, - &wl_shell_surface_interface, - wl_resource_get_version (resource), - id); - wl_resource_set_implementation (wl_shell_surface->resource, - &meta_wayland_wl_shell_surface_interface, - wl_shell_surface, - wl_shell_surface_destructor); - - create_wl_shell_surface_window (surface); -} - -static const struct wl_shell_interface meta_wayland_wl_shell_interface = { - wl_shell_get_shell_surface, -}; - -static void -bind_wl_shell (struct wl_client *client, - void *data, - uint32_t version, - uint32_t id) -{ - struct wl_resource *resource; - - resource = wl_resource_create (client, &wl_shell_interface, version, id); - wl_resource_set_implementation (resource, &meta_wayland_wl_shell_interface, data, NULL); -} - -static void -wl_shell_surface_role_apply_state (MetaWaylandSurfaceRole *surface_role, - MetaWaylandSurfaceState *pending) -{ - MetaWaylandWlShellSurface *wl_shell_surface = - META_WAYLAND_WL_SHELL_SURFACE (surface_role); - MetaWaylandShellSurface *shell_surface = - META_WAYLAND_SHELL_SURFACE (wl_shell_surface); - MetaWaylandSurfaceRoleClass *surface_role_class; - MetaWaylandSurface *surface = - meta_wayland_surface_role_get_surface (surface_role); - MetaWindow *window = meta_wayland_surface_get_window (surface); - cairo_region_t *input_region; - MetaRectangle geom = { 0 }; - - surface_role_class = - META_WAYLAND_SURFACE_ROLE_CLASS (meta_wayland_wl_shell_surface_parent_class); - surface_role_class->apply_state (surface_role, pending); - - /* For wl_shell, it's equivalent to an unmap. Semantics - * are poorly defined, so we can choose some that are - * convenient for us. */ - if (surface->buffer_ref.buffer && !window) - { - create_wl_shell_surface_window (surface); - } - else if (!surface->buffer_ref.buffer && window) - { - if (wl_shell_surface->popup) - meta_wayland_popup_dismiss (wl_shell_surface->popup); - else - meta_wayland_shell_surface_destroy_window (shell_surface); - return; - } - - if (!window) - return; - - if (!pending->newly_attached) - return; - - input_region = meta_wayland_surface_calculate_input_region (surface); - if (!cairo_region_is_empty (input_region)) - { - cairo_region_get_extents (input_region, &geom); - cairo_region_destroy (input_region); - } - else - { - meta_wayland_shell_surface_calculate_geometry (shell_surface, &geom); - } - - pending->has_acked_configure_serial = TRUE; - pending->acked_configure_serial = - wl_shell_surface->emulated_ack_configure_serial; - - meta_window_wayland_finish_move_resize (window, geom, pending); -} - -static MetaWaylandSurface * -wl_shell_surface_role_get_toplevel (MetaWaylandSurfaceRole *surface_role) -{ - MetaWaylandWlShellSurface *wl_shell_surface = - META_WAYLAND_WL_SHELL_SURFACE (surface_role); - - if (wl_shell_surface->state == META_WL_SHELL_SURFACE_STATE_POPUP && - wl_shell_surface->parent_surface) - return meta_wayland_surface_get_toplevel (wl_shell_surface->parent_surface); - else - return meta_wayland_surface_role_get_surface (surface_role); -} - -static void -wl_shell_surface_role_configure (MetaWaylandShellSurface *shell_surface, - MetaWaylandWindowConfiguration *configuration) -{ - MetaWaylandWlShellSurface *wl_shell_surface = - META_WAYLAND_WL_SHELL_SURFACE (shell_surface); - - if (!wl_shell_surface->resource) - return; - - wl_shell_surface_send_configure (wl_shell_surface->resource, - 0, - configuration->width / configuration->scale, - configuration->height / configuration->scale); - - wl_shell_surface->emulated_ack_configure_serial = configuration->serial; -} - -static void -wl_shell_surface_role_managed (MetaWaylandShellSurface *shell_surface, - MetaWindow *window) -{ - MetaWaylandWlShellSurface *wl_shell_surface = - META_WAYLAND_WL_SHELL_SURFACE (shell_surface); - - if (wl_shell_surface->state == META_WL_SHELL_SURFACE_STATE_POPUP) - meta_window_set_type (window, META_WINDOW_DROPDOWN_MENU); -} - -static void -wl_shell_surface_role_ping (MetaWaylandShellSurface *shell_surface, - guint32 serial) -{ - MetaWaylandWlShellSurface *wl_shell_surface = - META_WAYLAND_WL_SHELL_SURFACE (shell_surface); - - wl_shell_surface_send_ping (wl_shell_surface->resource, serial); -} - -static void -wl_shell_surface_role_close (MetaWaylandShellSurface *shell_surface) -{ - /* Not supported by wl_shell_surface. */ -} - -static void -meta_wayland_wl_shell_surface_popup_done (MetaWaylandPopupSurface *popup_surface) -{ - MetaWaylandWlShellSurface *wl_shell_surface = - META_WAYLAND_WL_SHELL_SURFACE (popup_surface); - - wl_shell_surface_send_popup_done (wl_shell_surface->resource); -} - -static void -meta_wayland_wl_shell_surface_popup_dismiss (MetaWaylandPopupSurface *popup_surface) -{ - MetaWaylandWlShellSurface *wl_shell_surface = - META_WAYLAND_WL_SHELL_SURFACE (popup_surface); - MetaWaylandShellSurface *shell_surface = - META_WAYLAND_SHELL_SURFACE (wl_shell_surface); - - wl_shell_surface->popup = NULL; - - meta_wayland_shell_surface_destroy_window (shell_surface); -} - -static MetaWaylandSurface * -meta_wayland_wl_shell_surface_popup_get_surface (MetaWaylandPopupSurface *popup_surface) -{ - MetaWaylandSurfaceRole *surface_role = - META_WAYLAND_SURFACE_ROLE (popup_surface); - - return meta_wayland_surface_role_get_surface (surface_role); -} - -static void -popup_surface_iface_init (MetaWaylandPopupSurfaceInterface *iface) -{ - iface->done = meta_wayland_wl_shell_surface_popup_done; - iface->dismiss = meta_wayland_wl_shell_surface_popup_dismiss; - iface->get_surface = meta_wayland_wl_shell_surface_popup_get_surface; -} - -static void -wl_shell_surface_role_finalize (GObject *object) -{ - MetaWaylandWlShellSurface *wl_shell_surface = - META_WAYLAND_WL_SHELL_SURFACE (object); - GObjectClass *object_class; - - g_clear_pointer (&wl_shell_surface->resource, wl_resource_destroy); - - object_class = - G_OBJECT_CLASS (meta_wayland_wl_shell_surface_parent_class); - object_class->finalize (object); -} - -static void -meta_wayland_wl_shell_surface_init (MetaWaylandWlShellSurface *wl_shell_surface) -{ -} - -static void -meta_wayland_wl_shell_surface_class_init (MetaWaylandWlShellSurfaceClass *klass) -{ - GObjectClass *object_class; - MetaWaylandSurfaceRoleClass *surface_role_class; - MetaWaylandShellSurfaceClass *shell_surface_class; - - object_class = G_OBJECT_CLASS (klass); - object_class->finalize = wl_shell_surface_role_finalize; - - surface_role_class = META_WAYLAND_SURFACE_ROLE_CLASS (klass); - surface_role_class->apply_state = wl_shell_surface_role_apply_state; - surface_role_class->get_toplevel = wl_shell_surface_role_get_toplevel; - - shell_surface_class = META_WAYLAND_SHELL_SURFACE_CLASS (klass); - shell_surface_class->configure = wl_shell_surface_role_configure; - shell_surface_class->managed = wl_shell_surface_role_managed; - shell_surface_class->ping = wl_shell_surface_role_ping; - shell_surface_class->close = wl_shell_surface_role_close; -} - -void -meta_wayland_wl_shell_init (MetaWaylandCompositor *compositor) -{ - if (wl_global_create (compositor->wayland_display, - &wl_shell_interface, - META_WL_SHELL_VERSION, - compositor, bind_wl_shell) == NULL) - g_error ("Failed to register a global wl-shell object"); -} diff --git a/src/wayland/meta-wayland-wl-shell.h b/src/wayland/meta-wayland-wl-shell.h deleted file mode 100644 index 4a62d8a72..000000000 --- a/src/wayland/meta-wayland-wl-shell.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2013-2015 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_WL_SHELL_H -#define META_WAYLAND_WL_SHELL_H - -#include "wayland/meta-wayland-shell-surface.h" - -#define META_TYPE_WAYLAND_WL_SHELL_SURFACE (meta_wayland_wl_shell_surface_get_type ()) -G_DECLARE_FINAL_TYPE (MetaWaylandWlShellSurface, - meta_wayland_wl_shell_surface, - META, WAYLAND_WL_SHELL_SURFACE, - MetaWaylandShellSurface); - -void meta_wayland_wl_shell_init (MetaWaylandCompositor *compositor); - -#endif /* META_WAYLAND_WL_SHELL_H */ diff --git a/src/wayland/meta-wayland-xdg-foreign.c b/src/wayland/meta-wayland-xdg-foreign.c index eb480b996..c29aea243 100644 --- a/src/wayland/meta-wayland-xdg-foreign.c +++ b/src/wayland/meta-wayland-xdg-foreign.c @@ -32,7 +32,6 @@ #include "wayland/meta-wayland-private.h" #include "wayland/meta-wayland-versions.h" #include "wayland/meta-wayland-xdg-shell.h" -#include "wayland/meta-wayland-legacy-xdg-shell.h" #include "xdg-foreign-unstable-v1-server-protocol.h" @@ -145,9 +144,8 @@ xdg_exporter_export (struct wl_client *client, char *handle; if (!surface->role || - !meta_wayland_surface_get_window (surface) || - !(META_IS_WAYLAND_XDG_SURFACE (surface->role) || - META_IS_WAYLAND_ZXDG_SURFACE_V6 (surface->role))) + !meta_wayland_surface_get_window (surface) || + !META_IS_WAYLAND_XDG_SURFACE (surface->role)) { wl_resource_post_error (resource, WL_DISPLAY_ERROR_INVALID_OBJECT, @@ -253,8 +251,7 @@ is_valid_child (MetaWaylandSurface *surface) if (!surface->role) return FALSE; - if (!META_IS_WAYLAND_XDG_TOPLEVEL (surface->role) && - !META_IS_WAYLAND_ZXDG_TOPLEVEL_V6 (surface->role)) + if (!META_IS_WAYLAND_XDG_TOPLEVEL (surface->role)) return FALSE; if (!meta_wayland_surface_get_window (surface)) @@ -385,9 +382,7 @@ xdg_importer_import (struct wl_client *client, xdg_imported_destructor); exported = g_hash_table_lookup (foreign->exported_surfaces, handle); - if (!exported || - (!META_IS_WAYLAND_XDG_SURFACE (exported->surface->role) && - !META_IS_WAYLAND_ZXDG_SURFACE_V6 (exported->surface->role))) + if (!exported || !META_IS_WAYLAND_XDG_SURFACE (exported->surface->role)) { zxdg_imported_v1_send_destroyed (xdg_imported_resource); return; diff --git a/src/wayland/meta-wayland.c b/src/wayland/meta-wayland.c index e4b09cbfc..76ecf7560 100644 --- a/src/wayland/meta-wayland.c +++ b/src/wayland/meta-wayland.c @@ -424,7 +424,6 @@ meta_wayland_compositor_setup (MetaWaylandCompositor *wayland_compositor) meta_wayland_outputs_init (compositor); meta_wayland_data_device_manager_init (compositor); meta_wayland_data_device_primary_manager_init (compositor); - meta_wayland_data_device_primary_legacy_manager_init (compositor); meta_wayland_subsurfaces_init (compositor); meta_wayland_shell_init (compositor); meta_wayland_pointer_gestures_init (compositor); @@ -437,7 +436,6 @@ meta_wayland_compositor_setup (MetaWaylandCompositor *wayland_compositor) meta_wayland_keyboard_shortcuts_inhibit_init (compositor); meta_wayland_surface_inhibit_shortcuts_dialog_init (); meta_wayland_text_input_init (compositor); - meta_wayland_gtk_text_input_init (compositor); /* Xwayland specific protocol, needs to be filtered out for all other clients */ if (meta_xwayland_grab_keyboard_init (compositor)) diff --git a/src/wayland/protocol/gtk-primary-selection.xml b/src/wayland/protocol/gtk-primary-selection.xml deleted file mode 100644 index 02cab94fc..000000000 --- a/src/wayland/protocol/gtk-primary-selection.xml +++ /dev/null @@ -1,225 +0,0 @@ - - - - Copyright © 2015, 2016 Red Hat - - Permission is hereby granted, free of charge, to any person obtaining a - copy of this software and associated documentation files (the "Software"), - to deal in the Software without restriction, including without limitation - the rights to use, copy, modify, merge, publish, distribute, sublicense, - and/or sell copies of the Software, and to permit persons to whom the - Software is furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice (including the next - paragraph) shall be included in all copies or substantial portions of the - Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - DEALINGS IN THE SOFTWARE. - - - - This protocol provides the ability to have a primary selection device to - match that of the X server. This primary selection is a shortcut to the - common clipboard selection, where text just needs to be selected in order - to allow copying it elsewhere. The de facto way to perform this action - is the middle mouse button, although it is not limited to this one. - - Clients wishing to honor primary selection should create a primary - selection source and set it as the selection through - wp_primary_selection_device.set_selection whenever the text selection - changes. In order to minimize calls in pointer-driven text selection, - it should happen only once after the operation finished. Similarly, - a NULL source should be set when text is unselected. - - wp_primary_selection_offer objects are first announced through the - wp_primary_selection_device.data_offer event. Immediately after this event, - the primary data offer will emit wp_primary_selection_offer.offer events - to let know of the mime types being offered. - - When the primary selection changes, the client with the keyboard focus - will receive wp_primary_selection_device.selection events. Only the client - with the keyboard focus will receive such events with a non-NULL - wp_primary_selection_offer. Across keyboard focus changes, previously - focused clients will receive wp_primary_selection_device.events with a - NULL wp_primary_selection_offer. - - In order to request the primary selection data, the client must pass - a recent serial pertaining to the press event that is triggering the - operation, if the compositor deems the serial valid and recent, the - wp_primary_selection_source.send event will happen in the other end - to let the transfer begin. The client owning the primary selection - should write the requested data, and close the file descriptor - immediately. - - If the primary selection owner client disappeared during the transfer, - the client reading the data will receive a - wp_primary_selection_device.selection event with a NULL - wp_primary_selection_offer, the client should take this as a hint - to finish the reads related to the no longer existing offer. - - The primary selection owner should be checking for errors during - writes, merely cancelling the ongoing transfer if any happened. - - - - - The primary selection device manager is a singleton global object that - provides access to the primary selection. It allows to create - wp_primary_selection_source objects, as well as retrieving the per-seat - wp_primary_selection_device objects. - - - - - Create a new primary selection source. - - - - - - - Create a new data device for a given seat. - - - - - - - - Destroy the primary selection device manager. - - - - - - - - Replaces the current selection. The previous owner of the primary selection - will receive a wp_primary_selection_source.cancelled event. - - To unset the selection, set the source to NULL. - - - - - - - - Introduces a new wp_primary_selection_offer object that may be used - to receive the current primary selection. Immediately following this - event, the new wp_primary_selection_offer object will send - wp_primary_selection_offer.offer events to describe the offered mime - types. - - - - - - - The wp_primary_selection_device.selection event is sent to notify the - client of a new primary selection. This event is sent after the - wp_primary_selection.data_offer event introducing this object, and after - the offer has announced its mimetypes through - wp_primary_selection_offer.offer. - - The data_offer is valid until a new offer or NULL is received - or until the client loses keyboard focus. The client must destroy the - previous selection data_offer, if any, upon receiving this event. - - - - - - - Destroy the primary selection device. - - - - - - - A wp_primary_selection_offer represents an offer to transfer the contents - of the primary selection clipboard to the client. Similar to - wl_data_offer, the offer also describes the mime types that the source - will transferthat the - data can be converted to and provides the mechanisms for transferring the - data directly to the client. - - - - - To transfer the contents of the primary selection clipboard, the client - issues this request and indicates the mime type that it wants to - receive. The transfer happens through the passed file descriptor - (typically created with the pipe system call). The source client writes - the data in the mime type representation requested and then closes the - file descriptor. - - The receiving client reads from the read end of the pipe until EOF and - closes its end, at which point the transfer is complete. - - - - - - - - Destroy the primary selection offer. - - - - - - Sent immediately after creating announcing the wp_primary_selection_offer - through wp_primary_selection_device.data_offer. One event is sent per - offered mime type. - - - - - - - - The source side of a wp_primary_selection_offer, it provides a way to - describe the offered data and respond to requests to transfer the - requested contents of the primary selection clipboard. - - - - - This request adds a mime type to the set of mime types advertised to - targets. Can be called several times to offer multiple types. - - - - - - - Destroy the primary selection source. - - - - - - Request for the current primary selection contents from the client. - Send the specified mime type over the passed file descriptor, then - close it. - - - - - - - - This primary selection source is no longer valid. The client should - clean up and destroy this primary selection source. - - - - diff --git a/src/wayland/protocol/gtk-text-input.xml b/src/wayland/protocol/gtk-text-input.xml deleted file mode 100644 index a134a19f6..000000000 --- a/src/wayland/protocol/gtk-text-input.xml +++ /dev/null @@ -1,302 +0,0 @@ - - - - - Copyright © 2012, 2013 Intel Corporation - Copyright © 2015, 2016 Jan Arne Petersen - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that copyright notice and this permission - notice appear in supporting documentation, and that the name of - the copyright holders not be used in advertising or publicity - pertaining to distribution of the software without specific, - written prior permission. The copyright holders make no - representations about the suitability of this software for any - purpose. It is provided "as is" without express or implied - warranty. - - THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS - SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND - FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY - SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN - AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, - ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF - THIS SOFTWARE. - - - - - The gtk_text_input interface represents text input and input methods - associated with a seat. It provides enter/leave events to follow the - text input focus for a seat. - - Requests are used to enable/disable the text-input object and set - state information like surrounding and selected text or the content type. - The information about the entered text is sent to the text-input object - via the pre-edit and commit_string events. Using this interface removes - the need for applications to directly process hardware key events and - compose text out of them. - - Text is valid UTF-8 encoded, indices and lengths are in bytes. Indices - have to always point to the first byte of an UTF-8 encoded code point. - Lengths are not allowed to contain just a part of an UTF-8 encoded code - point. - - Focus moving throughout surfaces will result in the emission of - gtk_text_input.enter and gtk_text_input.leave events. The focused - surface must perform gtk_text_input.enable and - gtk_text_input.disable requests as the keyboard focus moves across - editable and non-editable elements of the UI. Those two requests are not - expected to be paired with each other, the compositor must be able to - handle consecutive series of the same request. - - State is sent by the state requests (set_surrounding_text, - set_content_type and set_cursor_rectangle) and a commit request. - After an enter event or disable request all state information is - invalidated and needs to be resent by the client. - - This protocol defines requests and events necessary for regular clients - to communicate with an input method. The gtk_input_method protocol - defines the interfaces necessary to implement standalone input methods. - If a compositor implements both interfaces, it will be the arbiter of the - communication between both. - - Warning! The protocol described in this file is experimental and - backward incompatible changes may be made. Backward compatible changes - may be added together with the corresponding interface version bump. - Backward incompatible changes are done by bumping the version number in - the protocol and interface names and resetting the interface version. - Once the protocol is to be declared stable, the 'z' prefix and the - version number in the protocol and interface names are removed and the - interface version number is reset. - - - - - Destroy the wp_text_input object. Also disables all surfaces enabled - through this wp_text_input object - - - - - - Content hint is a bitmask to allow to modify the behavior of the text - input. - - - - - - - - - Requests text input on a surface. The serial provided must be the one - received on gtk_text_input.enter. - - - - - - - - Explicitly disable text input in a surface (typically when there is no - focus on any text entry inside the surface). - - - - - - Sets the plain surrounding text around the input position. Text is - UTF-8 encoded. Cursor is the byte offset within the surrounding text. - Anchor is the byte offset of the selection anchor within the - surrounding text. If there is no selected text, anchor is the same as - cursor. - - Make sure to always send some text before and after the cursor - except when the cursor is at the beginning or end of text. - - When there was a configure_surrounding_text event take the - before_cursor and after_cursor arguments into account for picking how - much surrounding text to send. - - There is a maximum length of wayland messages so text can not be - longer than 4000 bytes. - - - - - - - - - Content hint is a bitmask to allow to modify the behavior of the text - input. - - - - - - - - - - - - - - - - - The content purpose allows to specify the primary purpose of a text - input. - - This allows an input method to show special purpose input panels with - extra characters or to disallow some characters. - - - - - - - - - - - - - - - - - - - - Sets the content purpose and content hint. While the purpose is the - basic purpose of an input field, the hint flags allow to modify some - of the behavior. - - When no content type is explicitly set, a normal content purpose with - none hint should be assumed. - - - - - - - - Sets the cursor outline as a x, y, width, height rectangle in surface - local coordinates. - - Allows the compositor to put a window with word suggestions near the - cursor. - - - - - - - - - - Allows to atomically send state updates from client. The previous - set_surrounding_text, set_content_type and set_cursor_rectangle - become effective after this call. - - Serial should be set to the serial from the last wp_text_input.enter - event. - - To make sure to not receive outdated input method events after a - state update, wl_display_sync() should be called after making this - request. - - - - - - Notification that this seat's text-input focus is on a certain surface. - - When the seat has the keyboard capability the text-input focus follows - the keyboard focus. - - - - - - - - Notification that this seat's text-input focus is no longer on - a certain surface. The client should reset any preedit string previously - set. - - The leave notification is sent before the enter notification - for the new focus. - - When the seat has the keyboard capability the text-input focus follows - the keyboard focus. - - - - - - - - Notify when a new composing text (pre-edit) should be set around the - current cursor position. Any previously set composing text should - be removed. - - - - - - - - Notify when text should be inserted into the editor widget. The text to - commit could be either just a single character after a key press or the - result of some composing (pre-edit). - - The text argument could be also null if some text is removed (see - gtk_text_input.delete_surrounding_text). - - Any previously set composing text should be removed. - - - - - - - Notify when the text around the current cursor position should be - deleted. Before_length and after_length is the length (in bytes) of text - before and after the current cursor position (excluding the selection) - to delete. - - This event should be handled as part of a following commit_string or - preedit_string event. - - - - - - - - - A factory for text-input objects. This object is a global singleton. - - - - - Destroy the wp_text_input_manager object. - - - - - - Creates a new text-input object for a given seat. - - - - - -