xwayland.h 5.69 KB
Newer Older
1 2 3
/*
 * Copyright © 2012 Intel Corporation
 *
4 5 6 7 8 9 10
 * 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:
11
 *
12 13 14 15 16 17 18 19 20 21 22 23
 * 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.
24 25
 */

26
#include <stdio.h>
27 28 29
#include <wayland-server.h>
#include <xcb/xcb.h>
#include <xcb/xfixes.h>
30
#include <xcb/composite.h>
31 32
#include <cairo/cairo-xcb.h>

33
#include <libweston/libweston.h>
34
#include "compositor/weston.h"
35
#include <libweston/xwayland-api.h>
36
#include "weston-debug.h"
37

38 39 40
#define SEND_EVENT_MASK (0x80)
#define EVENT_TYPE(event) ((event)->response_type & ~SEND_EVENT_MASK)

41 42 43 44 45 46 47 48
struct weston_xserver {
	struct wl_display *wl_display;
	struct wl_event_loop *loop;
	int abstract_fd;
	struct wl_event_source *abstract_source;
	int unix_fd;
	struct wl_event_source *unix_source;
	int display;
49
	pid_t pid;
50 51 52 53
	struct wl_client *client;
	struct weston_compositor *compositor;
	struct weston_wm *wm;
	struct wl_listener destroy_listener;
54 55
	weston_xwayland_spawn_xserver_func_t spawn_func;
	void *user_data;
56 57

	struct weston_debug_scope *wm_debug;
58 59 60 61 62 63 64 65 66 67 68 69
};

struct weston_wm {
	xcb_connection_t *conn;
	const xcb_query_extension_reply_t *xfixes;
	struct wl_event_source *source;
	xcb_screen_t *screen;
	struct hash_table *window_hash;
	struct weston_xserver *server;
	xcb_window_t wm_window;
	struct weston_wm_window *focus_window;
	struct theme *theme;
70 71
	xcb_cursor_t *cursors;
	int last_cursor;
72
	xcb_render_pictforminfo_t format_rgb, format_rgba;
73 74
	xcb_visualid_t visual_id;
	xcb_colormap_t colormap;
75
	struct wl_listener create_surface_listener;
76
	struct wl_listener activate_listener;
77
	struct wl_listener kill_listener;
78
	struct wl_list unpaired_window_list;
79 80

	xcb_window_t selection_window;
81
	xcb_window_t selection_owner;
82 83 84 85 86 87 88 89 90 91 92 93 94
	int incr;
	int data_source_fd;
	struct wl_event_source *property_source;
	xcb_get_property_reply_t *property_reply;
	int property_start;
	struct wl_array source_data;
	xcb_selection_request_event_t selection_request;
	xcb_atom_t selection_target;
	xcb_timestamp_t selection_timestamp;
	int selection_property_set;
	int flush_property_on_delete;
	struct wl_listener selection_listener;

95 96 97
	xcb_window_t dnd_window;
	xcb_window_t dnd_owner;

98 99
	struct {
		xcb_atom_t		 wm_protocols;
100
		xcb_atom_t		 wm_normal_hints;
101 102
		xcb_atom_t		 wm_take_focus;
		xcb_atom_t		 wm_delete_window;
103
		xcb_atom_t		 wm_state;
104
		xcb_atom_t		 wm_s0;
105
		xcb_atom_t		 wm_client_machine;
106
		xcb_atom_t		 net_wm_cm_s0;
107
		xcb_atom_t		 net_wm_name;
108
		xcb_atom_t		 net_wm_pid;
109 110
		xcb_atom_t		 net_wm_icon;
		xcb_atom_t		 net_wm_state;
111 112
		xcb_atom_t		 net_wm_state_maximized_vert;
		xcb_atom_t		 net_wm_state_maximized_horz;
113 114 115
		xcb_atom_t		 net_wm_state_fullscreen;
		xcb_atom_t		 net_wm_user_time;
		xcb_atom_t		 net_wm_icon_name;
116
		xcb_atom_t		 net_wm_desktop;
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
		xcb_atom_t		 net_wm_window_type;
		xcb_atom_t		 net_wm_window_type_desktop;
		xcb_atom_t		 net_wm_window_type_dock;
		xcb_atom_t		 net_wm_window_type_toolbar;
		xcb_atom_t		 net_wm_window_type_menu;
		xcb_atom_t		 net_wm_window_type_utility;
		xcb_atom_t		 net_wm_window_type_splash;
		xcb_atom_t		 net_wm_window_type_dialog;
		xcb_atom_t		 net_wm_window_type_dropdown;
		xcb_atom_t		 net_wm_window_type_popup;
		xcb_atom_t		 net_wm_window_type_tooltip;
		xcb_atom_t		 net_wm_window_type_notification;
		xcb_atom_t		 net_wm_window_type_combo;
		xcb_atom_t		 net_wm_window_type_dnd;
		xcb_atom_t		 net_wm_window_type_normal;
		xcb_atom_t		 net_wm_moveresize;
		xcb_atom_t		 net_supporting_wm_check;
		xcb_atom_t		 net_supported;
135
		xcb_atom_t		 net_active_window;
136 137
		xcb_atom_t		 motif_wm_hints;
		xcb_atom_t		 clipboard;
138
		xcb_atom_t		 clipboard_manager;
139 140 141 142 143 144 145 146 147
		xcb_atom_t		 targets;
		xcb_atom_t		 utf8_string;
		xcb_atom_t		 wl_selection;
		xcb_atom_t		 incr;
		xcb_atom_t		 timestamp;
		xcb_atom_t		 multiple;
		xcb_atom_t		 compound_text;
		xcb_atom_t		 text;
		xcb_atom_t		 string;
148
		xcb_atom_t		 window;
149 150
		xcb_atom_t		 text_plain_utf8;
		xcb_atom_t		 text_plain;
151 152 153 154 155 156 157 158 159
		xcb_atom_t		 xdnd_selection;
		xcb_atom_t		 xdnd_aware;
		xcb_atom_t		 xdnd_enter;
		xcb_atom_t		 xdnd_leave;
		xcb_atom_t		 xdnd_drop;
		xcb_atom_t		 xdnd_status;
		xcb_atom_t		 xdnd_finished;
		xcb_atom_t		 xdnd_type_list;
		xcb_atom_t		 xdnd_action_copy;
160
		xcb_atom_t		 wl_surface_id;
161
		xcb_atom_t		 allow_commits;
162 163 164 165
	} atom;
};

void
166
dump_property(FILE *fp, struct weston_wm *wm, xcb_atom_t property,
167 168 169 170 171
	      xcb_get_property_reply_t *reply);

const char *
get_atom_name(xcb_connection_t *c, xcb_atom_t atom);

172 173
void
weston_wm_selection_init(struct weston_wm *wm);
174 175 176 177
int
weston_wm_handle_selection_event(struct weston_wm *wm,
				 xcb_generic_event_t *event);

178
struct weston_wm *
179
weston_wm_create(struct weston_xserver *wxs, int fd);
180 181 182
void
weston_wm_destroy(struct weston_wm *wm);

183 184
struct weston_seat *
weston_wm_pick_seat(struct weston_wm *wm);
185 186 187 188 189 190

int
weston_wm_handle_dnd_event(struct weston_wm *wm,
			   xcb_generic_event_t *event);
void
weston_wm_dnd_init(struct weston_wm *wm);