2014-03-12 00:11:39 +01:00
|
|
|
/*
|
|
|
|
* Copyright © 2014 Intel Corporation
|
|
|
|
*
|
|
|
|
* 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 XWAYLAND_H
|
|
|
|
#define XWAYLAND_H
|
|
|
|
|
|
|
|
#include <dix-config.h>
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
#include <wayland-client.h>
|
|
|
|
|
|
|
|
#include <X11/X.h>
|
|
|
|
|
|
|
|
#include <fb.h>
|
|
|
|
#include <input.h>
|
|
|
|
#include <dix.h>
|
|
|
|
#include <randrstr.h>
|
|
|
|
#include <exevents.h>
|
|
|
|
|
2016-09-29 04:40:01 +02:00
|
|
|
#include "relative-pointer-unstable-v1-client-protocol.h"
|
2016-09-29 04:42:13 +02:00
|
|
|
#include "pointer-constraints-unstable-v1-client-protocol.h"
|
2016-09-29 04:40:01 +02:00
|
|
|
|
2014-03-12 00:11:39 +01:00
|
|
|
struct xwl_screen {
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
int depth;
|
|
|
|
ScreenPtr screen;
|
|
|
|
int expecting_event;
|
dix: Add hybrid full-size/empty-clip mode to SetRootClip
216bdbc735 removed the SetRootClip call in the XWayland output-hotplug
handler when running rootless (e.g. as a part of Weston/Mutter), since
the root window has no storage, so generating exposures will result in
writes to invalid memory.
Unfortunately, preventing the segfault also breaks sprite confinement.
SetRootClip updates winSize and borderSize for the root window, which
when combined with RRScreenSizeChanged calling ScreenRestructured,
generates a new sprite-confinment area to update it to the whole screen.
Removing this call results in the window geometry being reported
correctly, but winSize/borderSize never changing from their values at
startup, i.e. out of sync with the root window geometry / screen
information in the connection info / XRandR.
This patch introduces a hybrid mode, where we update winSize and
borderSize for the root window, enabling sprite confinement to work
correctly, but keep the clip emptied so exposures are never generated.
Signed-off-by: Daniel Stone <daniels@collabora.com>
Tested-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-02-12 17:36:59 +01:00
|
|
|
enum RootClipMode root_clip_mode;
|
2014-03-12 00:11:39 +01:00
|
|
|
|
|
|
|
int wm_fd;
|
|
|
|
int listen_fds[5];
|
|
|
|
int listen_fd_count;
|
|
|
|
int rootless;
|
2014-06-16 20:34:55 +02:00
|
|
|
int glamor;
|
2014-03-12 00:11:39 +01:00
|
|
|
|
|
|
|
CreateScreenResourcesProcPtr CreateScreenResources;
|
|
|
|
CloseScreenProcPtr CloseScreen;
|
|
|
|
CreateWindowProcPtr CreateWindow;
|
|
|
|
DestroyWindowProcPtr DestroyWindow;
|
|
|
|
RealizeWindowProcPtr RealizeWindow;
|
|
|
|
UnrealizeWindowProcPtr UnrealizeWindow;
|
2016-06-21 13:54:35 +02:00
|
|
|
XYToWindowProcPtr XYToWindow;
|
2014-03-12 00:11:39 +01:00
|
|
|
|
|
|
|
struct xorg_list output_list;
|
|
|
|
struct xorg_list seat_list;
|
|
|
|
struct xorg_list damage_window_list;
|
|
|
|
|
|
|
|
int wayland_fd;
|
|
|
|
struct wl_display *display;
|
|
|
|
struct wl_registry *registry;
|
|
|
|
struct wl_registry *input_registry;
|
|
|
|
struct wl_compositor *compositor;
|
|
|
|
struct wl_shm *shm;
|
|
|
|
struct wl_shell *shell;
|
2016-09-29 04:40:01 +02:00
|
|
|
struct zwp_relative_pointer_manager_v1 *relative_pointer_manager;
|
2016-09-29 04:42:13 +02:00
|
|
|
struct zwp_pointer_constraints_v1 *pointer_constraints;
|
2014-03-12 00:11:39 +01:00
|
|
|
|
|
|
|
uint32_t serial;
|
|
|
|
|
|
|
|
#define XWL_FORMAT_ARGB8888 (1 << 0)
|
|
|
|
#define XWL_FORMAT_XRGB8888 (1 << 1)
|
|
|
|
#define XWL_FORMAT_RGB565 (1 << 2)
|
|
|
|
|
|
|
|
int prepare_read;
|
xwayland: handle EAGAIN on Wayland fd
wl_display_flush() can fail with EAGAIN and Xwayland would make this a
fatal error.
When this happens, it means that Xwayland has flooded the Wayland file
descriptor, either because the Wayland compositor cannot cope or more
likely because of a deadlock situation where the Wayland compositor is
blocking, waiting for an X reply while Xwayland tries to write data to
the Wayland file descriptor.
The general consensus to avoid the deadlock is for the Wayland
compositor to never issue blocking X11 roundtrips, but in practice
blocking rountrips can occur in various places, including Xlib calls
themselves so this is not always achievable without major surgery in the
Wayland compositor/Window manager.
What this patch does is to avoid dispatching to the Wayland file
descriptor until it becomes available for writing again, while at the
same time continue processing X11 requests to release the deadlock.
This is not perfect, as there is still the possibility of another X
client hammering the connection and we'll still fail writing to the
Wayland connection eventually, but this improves things enough to avoid
a 100% repeatable crash with vlc and gtkperf.
Also, it is worth considering that window managers and Wayland
compositors such as mutter already have a higher priority than other
regular X clients thanks to XSyncSetPriority(), mitigating the risk.
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1278159
Bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=763400
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2016-09-15 15:59:07 +02:00
|
|
|
int wait_flush;
|
2014-06-16 20:34:55 +02:00
|
|
|
|
|
|
|
char *device_name;
|
|
|
|
int drm_fd;
|
|
|
|
int fd_render_node;
|
|
|
|
struct wl_drm *drm;
|
|
|
|
uint32_t formats;
|
|
|
|
uint32_t capabilities;
|
|
|
|
void *egl_display, *egl_context;
|
|
|
|
struct gbm_device *gbm;
|
|
|
|
struct glamor_context *glamor_ctx;
|
2014-03-12 00:11:39 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct xwl_window {
|
|
|
|
struct xwl_screen *xwl_screen;
|
|
|
|
struct wl_surface *surface;
|
|
|
|
struct wl_shell_surface *shell_surface;
|
|
|
|
WindowPtr window;
|
|
|
|
DamagePtr damage;
|
|
|
|
struct xorg_list link_damage;
|
2014-06-30 19:53:50 +02:00
|
|
|
struct wl_callback *frame_callback;
|
2014-03-12 00:11:39 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#define MODIFIER_META 0x01
|
|
|
|
|
2015-05-27 18:41:58 +02:00
|
|
|
struct xwl_touch {
|
|
|
|
struct xwl_window *window;
|
|
|
|
int32_t id;
|
|
|
|
int x, y;
|
|
|
|
struct xorg_list link_touch;
|
|
|
|
};
|
|
|
|
|
2016-09-13 09:17:08 +02:00
|
|
|
struct xwl_pointer_warp_emulator {
|
|
|
|
struct xwl_seat *xwl_seat;
|
|
|
|
struct xwl_window *locked_window;
|
|
|
|
struct zwp_locked_pointer_v1 *locked_pointer;
|
|
|
|
};
|
|
|
|
|
2014-03-12 00:11:39 +01:00
|
|
|
struct xwl_seat {
|
|
|
|
DeviceIntPtr pointer;
|
2016-09-13 16:23:49 +02:00
|
|
|
DeviceIntPtr relative_pointer;
|
2014-03-12 00:11:39 +01:00
|
|
|
DeviceIntPtr keyboard;
|
2015-05-27 18:41:59 +02:00
|
|
|
DeviceIntPtr touch;
|
2014-03-12 00:11:39 +01:00
|
|
|
struct xwl_screen *xwl_screen;
|
|
|
|
struct wl_seat *seat;
|
|
|
|
struct wl_pointer *wl_pointer;
|
2016-09-13 09:17:04 +02:00
|
|
|
struct zwp_relative_pointer_v1 *wp_relative_pointer;
|
2014-03-12 00:11:39 +01:00
|
|
|
struct wl_keyboard *wl_keyboard;
|
2015-05-27 18:41:59 +02:00
|
|
|
struct wl_touch *wl_touch;
|
2014-03-12 00:11:39 +01:00
|
|
|
struct wl_array keys;
|
|
|
|
struct xwl_window *focus_window;
|
|
|
|
uint32_t id;
|
|
|
|
uint32_t pointer_enter_serial;
|
|
|
|
struct xorg_list link;
|
|
|
|
CursorPtr x_cursor;
|
2015-05-27 12:08:45 +02:00
|
|
|
struct wl_surface *cursor;
|
|
|
|
struct wl_callback *cursor_frame_cb;
|
|
|
|
Bool cursor_needs_update;
|
2016-06-23 15:31:30 +02:00
|
|
|
WindowPtr last_xwindow;
|
2014-03-12 00:11:39 +01:00
|
|
|
|
2015-05-27 18:41:58 +02:00
|
|
|
struct xorg_list touches;
|
|
|
|
|
2014-03-12 00:11:39 +01:00
|
|
|
size_t keymap_size;
|
|
|
|
char *keymap;
|
|
|
|
struct wl_surface *keyboard_focus;
|
2016-03-09 10:31:58 +01:00
|
|
|
|
|
|
|
struct xorg_list sync_pending;
|
2016-09-13 09:17:03 +02:00
|
|
|
|
2016-09-13 09:17:08 +02:00
|
|
|
struct xwl_pointer_warp_emulator *pointer_warp_emulator;
|
|
|
|
|
2016-09-13 09:17:07 +02:00
|
|
|
struct xwl_window *cursor_confinement_window;
|
|
|
|
struct zwp_confined_pointer_v1 *confined_pointer;
|
|
|
|
|
2016-09-13 09:17:03 +02:00
|
|
|
struct {
|
|
|
|
Bool has_absolute;
|
|
|
|
wl_fixed_t x;
|
|
|
|
wl_fixed_t y;
|
2016-09-13 09:17:04 +02:00
|
|
|
|
|
|
|
Bool has_relative;
|
|
|
|
double dx;
|
|
|
|
double dy;
|
|
|
|
double dx_unaccel;
|
|
|
|
double dy_unaccel;
|
2016-09-13 09:17:03 +02:00
|
|
|
} pending_pointer_event;
|
2014-03-12 00:11:39 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct xwl_output {
|
|
|
|
struct xorg_list link;
|
|
|
|
struct wl_output *output;
|
2015-05-16 07:38:28 +02:00
|
|
|
uint32_t server_output_id;
|
2014-03-12 00:11:39 +01:00
|
|
|
struct xwl_screen *xwl_screen;
|
|
|
|
RROutputPtr randr_output;
|
|
|
|
RRCrtcPtr randr_crtc;
|
2016-07-13 19:19:09 +02:00
|
|
|
int32_t x, y, width, height, refresh;
|
2014-03-12 00:11:39 +01:00
|
|
|
Rotation rotation;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct xwl_pixmap;
|
|
|
|
|
2016-03-09 10:33:50 +01:00
|
|
|
void xwl_sync_events (struct xwl_screen *xwl_screen);
|
|
|
|
|
2014-03-12 00:11:39 +01:00
|
|
|
Bool xwl_screen_init_cursor(struct xwl_screen *xwl_screen);
|
|
|
|
|
|
|
|
struct xwl_screen *xwl_screen_get(ScreenPtr screen);
|
|
|
|
|
|
|
|
void xwl_seat_set_cursor(struct xwl_seat *xwl_seat);
|
|
|
|
|
|
|
|
void xwl_seat_destroy(struct xwl_seat *xwl_seat);
|
|
|
|
|
2015-05-27 18:42:00 +02:00
|
|
|
void xwl_seat_clear_touch(struct xwl_seat *xwl_seat, WindowPtr window);
|
|
|
|
|
2016-09-13 09:17:08 +02:00
|
|
|
void xwl_seat_emulate_pointer_warp(struct xwl_seat *xwl_seat,
|
|
|
|
struct xwl_window *xwl_window,
|
|
|
|
SpritePtr sprite,
|
|
|
|
int x, int y);
|
|
|
|
|
|
|
|
void xwl_seat_destroy_pointer_warp_emulator(struct xwl_seat *xwl_seat);
|
|
|
|
|
|
|
|
void xwl_seat_cursor_visibility_changed(struct xwl_seat *xwl_seat);
|
|
|
|
|
2016-09-13 09:17:07 +02:00
|
|
|
void xwl_seat_confine_pointer(struct xwl_seat *xwl_seat,
|
|
|
|
struct xwl_window *xwl_window);
|
|
|
|
void xwl_seat_unconfine_pointer(struct xwl_seat *xwl_seat);
|
|
|
|
|
2014-03-12 00:11:39 +01:00
|
|
|
Bool xwl_screen_init_output(struct xwl_screen *xwl_screen);
|
|
|
|
|
|
|
|
struct xwl_output *xwl_output_create(struct xwl_screen *xwl_screen,
|
|
|
|
uint32_t id);
|
|
|
|
|
|
|
|
void xwl_output_destroy(struct xwl_output *xwl_output);
|
|
|
|
|
2016-08-08 17:57:57 +02:00
|
|
|
void xwl_output_remove(struct xwl_output *xwl_output);
|
|
|
|
|
2014-03-12 00:11:39 +01:00
|
|
|
RRModePtr xwayland_cvt(int HDisplay, int VDisplay,
|
|
|
|
float VRefresh, Bool Reduced, Bool Interlaced);
|
|
|
|
|
|
|
|
void xwl_pixmap_set_private(PixmapPtr pixmap, struct xwl_pixmap *xwl_pixmap);
|
|
|
|
struct xwl_pixmap *xwl_pixmap_get(PixmapPtr pixmap);
|
|
|
|
|
|
|
|
|
|
|
|
Bool xwl_shm_create_screen_resources(ScreenPtr screen);
|
|
|
|
PixmapPtr xwl_shm_create_pixmap(ScreenPtr screen, int width, int height,
|
|
|
|
int depth, unsigned int hint);
|
|
|
|
Bool xwl_shm_destroy_pixmap(PixmapPtr pixmap);
|
|
|
|
struct wl_buffer *xwl_shm_pixmap_get_wl_buffer(PixmapPtr pixmap);
|
|
|
|
|
|
|
|
|
2014-06-16 20:34:55 +02:00
|
|
|
Bool xwl_glamor_init(struct xwl_screen *xwl_screen);
|
|
|
|
|
|
|
|
Bool xwl_screen_init_glamor(struct xwl_screen *xwl_screen,
|
|
|
|
uint32_t id, uint32_t version);
|
|
|
|
struct wl_buffer *xwl_glamor_pixmap_get_wl_buffer(PixmapPtr pixmap);
|
|
|
|
|
2016-03-09 16:21:18 +01:00
|
|
|
#ifdef XV
|
|
|
|
/* glamor Xv Adaptor */
|
|
|
|
Bool xwl_glamor_xv_init(ScreenPtr pScreen);
|
|
|
|
#endif
|
|
|
|
|
2016-02-10 09:35:39 +01:00
|
|
|
#ifdef XF86VIDMODE
|
|
|
|
void xwlVidModeExtensionInit(void);
|
|
|
|
#endif
|
|
|
|
|
2014-03-12 00:11:39 +01:00
|
|
|
#endif
|