2 * Copyright © 2012 Intel Corporation
4 * Permission to use, copy, modify, distribute, and sell this software and
5 * its documentation for any purpose is hereby granted without fee, provided
6 * that the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of the copyright holders not be used in
9 * advertising or publicity pertaining to distribution of the software
10 * without specific, written prior permission. The copyright holders make
11 * no representations about the suitability of this software for any
12 * purpose. It is provided "as is" without express or implied warranty.
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
15 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
17 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
18 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
19 * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
20 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 #include <wayland-server.h>
25 #include <xcb/xfixes.h>
26 #include <xcb/composite.h>
27 #include <cairo/cairo-xcb.h>
29 #include "compositor.h"
31 #define SEND_EVENT_MASK (0x80)
32 #define EVENT_TYPE(event) ((event)->response_type & ~SEND_EVENT_MASK)
34 struct weston_xserver {
35 struct wl_display *wl_display;
36 struct wl_event_loop *loop;
37 struct wl_event_source *sigchld_source;
39 struct wl_event_source *abstract_source;
41 struct wl_event_source *unix_source;
43 struct weston_process process;
44 struct wl_resource *resource;
45 struct wl_client *client;
46 struct weston_compositor *compositor;
48 struct wl_listener destroy_listener;
52 xcb_connection_t *conn;
53 const xcb_query_extension_reply_t *xfixes;
54 struct wl_event_source *source;
56 struct hash_table *window_hash;
57 struct weston_xserver *server;
58 xcb_window_t wm_window;
59 struct weston_wm_window *focus_window;
61 xcb_cursor_t *cursors;
63 xcb_render_pictforminfo_t format_rgb, format_rgba;
64 xcb_visualid_t visual_id;
65 xcb_colormap_t colormap;
66 struct wl_listener activate_listener;
67 struct wl_listener transform_listener;
68 struct wl_listener kill_listener;
70 xcb_window_t selection_window;
71 xcb_window_t selection_owner;
74 struct wl_event_source *property_source;
75 xcb_get_property_reply_t *property_reply;
77 struct wl_array source_data;
78 xcb_selection_request_event_t selection_request;
79 xcb_atom_t selection_target;
80 xcb_timestamp_t selection_timestamp;
81 int selection_property_set;
82 int flush_property_on_delete;
83 struct wl_listener selection_listener;
85 xcb_window_t dnd_window;
86 xcb_window_t dnd_owner;
89 xcb_atom_t wm_protocols;
90 xcb_atom_t wm_normal_hints;
91 xcb_atom_t wm_take_focus;
92 xcb_atom_t wm_delete_window;
95 xcb_atom_t wm_client_machine;
96 xcb_atom_t net_wm_cm_s0;
97 xcb_atom_t net_wm_name;
98 xcb_atom_t net_wm_pid;
99 xcb_atom_t net_wm_icon;
100 xcb_atom_t net_wm_state;
101 xcb_atom_t net_wm_state_fullscreen;
102 xcb_atom_t net_wm_user_time;
103 xcb_atom_t net_wm_icon_name;
104 xcb_atom_t net_wm_window_type;
105 xcb_atom_t net_wm_window_type_desktop;
106 xcb_atom_t net_wm_window_type_dock;
107 xcb_atom_t net_wm_window_type_toolbar;
108 xcb_atom_t net_wm_window_type_menu;
109 xcb_atom_t net_wm_window_type_utility;
110 xcb_atom_t net_wm_window_type_splash;
111 xcb_atom_t net_wm_window_type_dialog;
112 xcb_atom_t net_wm_window_type_dropdown;
113 xcb_atom_t net_wm_window_type_popup;
114 xcb_atom_t net_wm_window_type_tooltip;
115 xcb_atom_t net_wm_window_type_notification;
116 xcb_atom_t net_wm_window_type_combo;
117 xcb_atom_t net_wm_window_type_dnd;
118 xcb_atom_t net_wm_window_type_normal;
119 xcb_atom_t net_wm_moveresize;
120 xcb_atom_t net_supporting_wm_check;
121 xcb_atom_t net_supported;
122 xcb_atom_t motif_wm_hints;
123 xcb_atom_t clipboard;
124 xcb_atom_t clipboard_manager;
126 xcb_atom_t utf8_string;
127 xcb_atom_t wl_selection;
129 xcb_atom_t timestamp;
131 xcb_atom_t compound_text;
134 xcb_atom_t text_plain_utf8;
135 xcb_atom_t text_plain;
136 xcb_atom_t xdnd_selection;
137 xcb_atom_t xdnd_aware;
138 xcb_atom_t xdnd_enter;
139 xcb_atom_t xdnd_leave;
140 xcb_atom_t xdnd_drop;
141 xcb_atom_t xdnd_status;
142 xcb_atom_t xdnd_finished;
143 xcb_atom_t xdnd_type_list;
144 xcb_atom_t xdnd_action_copy;
149 dump_property(struct weston_wm *wm, xcb_atom_t property,
150 xcb_get_property_reply_t *reply);
153 get_atom_name(xcb_connection_t *c, xcb_atom_t atom);
156 weston_wm_selection_init(struct weston_wm *wm);
158 weston_wm_handle_selection_event(struct weston_wm *wm,
159 xcb_generic_event_t *event);
161 extern const struct xserver_interface xserver_implementation;
164 weston_wm_create(struct weston_xserver *wxs);
166 weston_wm_destroy(struct weston_wm *wm);
169 weston_wm_pick_seat(struct weston_wm *wm);
172 weston_wm_handle_dnd_event(struct weston_wm *wm,
173 xcb_generic_event_t *event);
175 weston_wm_dnd_init(struct weston_wm *wm);