2013-05-03 13:51:22 -04:00
|
|
|
/*
|
|
|
|
* Wayland Support
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013 Intel Corporation
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright © 2008-2011 Kristian Høgsberg
|
|
|
|
* Copyright © 2012 Collabora, Ltd.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2014-04-22 18:09:38 -04:00
|
|
|
#ifndef META_WAYLAND_KEYBOARD_H
|
|
|
|
#define META_WAYLAND_KEYBOARD_H
|
2013-05-03 13:51:22 -04:00
|
|
|
|
|
|
|
#include <clutter/clutter.h>
|
|
|
|
#include <wayland-server.h>
|
2014-02-28 10:24:06 -05:00
|
|
|
#include <xkbcommon/xkbcommon.h>
|
2013-05-03 13:51:22 -04:00
|
|
|
|
2016-04-01 04:39:30 -04:00
|
|
|
#include "wayland/meta-wayland-types.h"
|
|
|
|
|
|
|
|
#define META_TYPE_WAYLAND_KEYBOARD (meta_wayland_keyboard_get_type ())
|
|
|
|
G_DECLARE_FINAL_TYPE (MetaWaylandKeyboard, meta_wayland_keyboard,
|
|
|
|
META, WAYLAND_KEYBOARD,
|
2016-09-12 11:17:28 -04:00
|
|
|
MetaWaylandInputDevice)
|
2016-04-01 04:39:30 -04:00
|
|
|
|
2015-04-07 09:54:41 -04:00
|
|
|
struct _MetaWaylandKeyboardGrabInterface
|
|
|
|
{
|
|
|
|
gboolean (*key) (MetaWaylandKeyboardGrab *grab,
|
|
|
|
const ClutterEvent *event);
|
|
|
|
void (*modifiers) (MetaWaylandKeyboardGrab *grab,
|
|
|
|
ClutterModifierType modifiers);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _MetaWaylandKeyboardGrab
|
|
|
|
{
|
|
|
|
const MetaWaylandKeyboardGrabInterface *interface;
|
|
|
|
MetaWaylandKeyboard *keyboard;
|
|
|
|
};
|
|
|
|
|
2013-08-30 12:03:30 -04:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
struct xkb_keymap *keymap;
|
2014-03-06 08:41:45 -05:00
|
|
|
struct xkb_state *state;
|
2013-08-30 12:03:30 -04:00
|
|
|
size_t keymap_size;
|
wayland/keyboard: Create a separate keymap shm file per resource
By using the shm file when sending the keymap to all clients, we
effectively allows any client to change the keymap, as any client has
the ability to change the content of the file. Sending a read-only file
descriptor, or making the file itself read-only before unlinking, can
be worked around by the client by using chmod(2) and open(2) on
/proc/<pid>/<fd>.
Using memfd could potentially solve this issue, but as the usage of
mmap with MAP_SHARED is wide spread among clients, such a change can
not be introduced without causing wide spread compatibility issues.
So, to avoid allowing clients to interfere with each other, create a
separate shm file for each wl_keyboard resource when sending the
keymap. We could eventually do this per client, but in most cases,
there will only be one wl_keyboard resource per client anyway.
https://bugzilla.gnome.org/show_bug.cgi?id=784206
2017-06-29 00:22:47 -04:00
|
|
|
char *keymap_string;
|
2013-08-30 12:03:30 -04:00
|
|
|
} MetaWaylandXkbInfo;
|
|
|
|
|
|
|
|
struct _MetaWaylandKeyboard
|
|
|
|
{
|
2016-09-12 11:17:28 -04:00
|
|
|
MetaWaylandInputDevice parent;
|
2016-04-01 04:39:30 -04:00
|
|
|
|
2013-08-30 12:03:30 -04:00
|
|
|
struct wl_list resource_list;
|
2014-04-16 15:11:10 -04:00
|
|
|
struct wl_list focus_resource_list;
|
2014-02-18 18:00:26 -05:00
|
|
|
|
|
|
|
MetaWaylandSurface *focus_surface;
|
2014-02-17 19:13:16 -05:00
|
|
|
struct wl_listener focus_surface_listener;
|
2013-08-30 12:03:30 -04:00
|
|
|
uint32_t focus_serial;
|
2018-07-25 10:18:36 -04:00
|
|
|
|
|
|
|
uint32_t key_down_keycode;
|
|
|
|
uint32_t key_down_serial;
|
|
|
|
|
|
|
|
uint32_t key_up_keycode;
|
|
|
|
uint32_t key_up_serial;
|
2013-08-30 12:03:30 -04:00
|
|
|
|
|
|
|
MetaWaylandXkbInfo xkb_info;
|
2014-07-22 05:24:56 -04:00
|
|
|
enum xkb_state_component mods_changed;
|
2017-10-19 02:15:08 -04:00
|
|
|
xkb_mod_mask_t kbd_a11y_latched_mods;
|
|
|
|
xkb_mod_mask_t kbd_a11y_locked_mods;
|
2014-07-25 09:20:47 -04:00
|
|
|
|
2015-04-07 09:54:41 -04:00
|
|
|
MetaWaylandKeyboardGrab *grab;
|
|
|
|
MetaWaylandKeyboardGrab default_grab;
|
|
|
|
|
2014-07-25 09:20:47 -04:00
|
|
|
GSettings *settings;
|
2016-09-08 03:55:44 -04:00
|
|
|
GSettings *gsd_settings;
|
2013-08-30 12:03:30 -04:00
|
|
|
};
|
2013-05-03 13:51:22 -04:00
|
|
|
|
2016-09-12 11:20:36 -04:00
|
|
|
void meta_wayland_keyboard_enable (MetaWaylandKeyboard *keyboard);
|
2013-05-03 13:51:22 -04:00
|
|
|
|
2016-04-01 04:39:30 -04:00
|
|
|
void meta_wayland_keyboard_disable (MetaWaylandKeyboard *keyboard);
|
2013-09-04 05:11:39 -04:00
|
|
|
|
2014-04-22 18:09:38 -04:00
|
|
|
void meta_wayland_keyboard_update (MetaWaylandKeyboard *keyboard,
|
|
|
|
const ClutterKeyEvent *event);
|
2014-04-17 18:50:16 -04:00
|
|
|
|
2014-04-22 18:09:38 -04:00
|
|
|
gboolean meta_wayland_keyboard_handle_event (MetaWaylandKeyboard *keyboard,
|
|
|
|
const ClutterKeyEvent *event);
|
2015-08-21 16:25:53 -04:00
|
|
|
void meta_wayland_keyboard_update_key_state (MetaWaylandKeyboard *compositor,
|
|
|
|
char *key_vector,
|
|
|
|
int key_vector_len,
|
|
|
|
int offset);
|
2013-05-03 13:51:22 -04:00
|
|
|
|
2014-04-22 18:09:38 -04:00
|
|
|
void meta_wayland_keyboard_set_focus (MetaWaylandKeyboard *keyboard,
|
|
|
|
MetaWaylandSurface *surface);
|
2013-05-03 13:51:22 -04:00
|
|
|
|
2014-04-22 18:09:38 -04:00
|
|
|
struct wl_client * meta_wayland_keyboard_get_focus_client (MetaWaylandKeyboard *keyboard);
|
|
|
|
|
|
|
|
void meta_wayland_keyboard_create_new_resource (MetaWaylandKeyboard *keyboard,
|
|
|
|
struct wl_client *client,
|
|
|
|
struct wl_resource *seat_resource,
|
|
|
|
uint32_t id);
|
|
|
|
|
2015-10-09 10:42:06 -04:00
|
|
|
gboolean meta_wayland_keyboard_can_popup (MetaWaylandKeyboard *keyboard,
|
|
|
|
uint32_t serial);
|
|
|
|
|
2015-04-07 09:54:41 -04:00
|
|
|
void meta_wayland_keyboard_start_grab (MetaWaylandKeyboard *keyboard,
|
|
|
|
MetaWaylandKeyboardGrab *grab);
|
|
|
|
void meta_wayland_keyboard_end_grab (MetaWaylandKeyboard *keyboard);
|
|
|
|
|
2014-04-22 18:09:38 -04:00
|
|
|
#endif /* META_WAYLAND_KEYBOARD_H */
|