blob: 438b7bec50f5cd9e264d2e6b4da572349eb094fa [file] [log] [blame]
Kristian Høgsberg102bf032012-05-21 15:52:02 -04001/*
2 * Copyright © 2012 Intel Corporation
3 *
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.
13 *
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.
21 */
22
23#include <wayland-server.h>
24#include <xcb/xcb.h>
25#include <xcb/xfixes.h>
26#include <cairo/cairo-xcb.h>
27
28#include "../compositor.h"
29
30struct xserver {
31 struct wl_resource resource;
32};
33
34struct weston_xserver {
35 struct wl_display *wl_display;
36 struct wl_event_loop *loop;
37 struct wl_event_source *sigchld_source;
38 int abstract_fd;
39 struct wl_event_source *abstract_source;
40 int unix_fd;
41 struct wl_event_source *unix_source;
42 int display;
43 struct weston_process process;
44 struct wl_resource *resource;
45 struct wl_client *client;
46 struct weston_compositor *compositor;
47 struct weston_wm *wm;
Kristian Høgsberg102bf032012-05-21 15:52:02 -040048 struct wl_listener destroy_listener;
49};
50
51struct weston_wm {
52 xcb_connection_t *conn;
53 const xcb_query_extension_reply_t *xfixes;
54 struct wl_event_source *source;
55 xcb_screen_t *screen;
56 struct hash_table *window_hash;
57 struct weston_xserver *server;
58 xcb_window_t wm_window;
59 struct weston_wm_window *focus_window;
60 struct theme *theme;
61 xcb_render_pictforminfo_t render_format;
Kristian Høgsberge10b1242012-05-21 16:48:05 -040062 struct wl_listener activate_listener;
Kristian Høgsberg102bf032012-05-21 15:52:02 -040063
64 xcb_window_t selection_window;
Kristian Høgsberg80566732012-06-01 00:08:12 -040065 xcb_window_t selection_owner;
Kristian Høgsberg102bf032012-05-21 15:52:02 -040066 int incr;
67 int data_source_fd;
68 struct wl_event_source *property_source;
69 xcb_get_property_reply_t *property_reply;
70 int property_start;
71 struct wl_array source_data;
72 xcb_selection_request_event_t selection_request;
73 xcb_atom_t selection_target;
74 xcb_timestamp_t selection_timestamp;
75 int selection_property_set;
76 int flush_property_on_delete;
77 struct wl_listener selection_listener;
78
79 struct {
80 xcb_atom_t wm_protocols;
81 xcb_atom_t wm_take_focus;
82 xcb_atom_t wm_delete_window;
Kristian Høgsberga6d9a5e2012-05-30 12:15:44 -040083 xcb_atom_t wm_state;
Kristian Høgsberg670b5d32012-06-04 11:00:40 -040084 xcb_atom_t wm_s0;
Kristian Høgsberg102bf032012-05-21 15:52:02 -040085 xcb_atom_t net_wm_name;
86 xcb_atom_t net_wm_icon;
87 xcb_atom_t net_wm_state;
88 xcb_atom_t net_wm_state_fullscreen;
89 xcb_atom_t net_wm_user_time;
90 xcb_atom_t net_wm_icon_name;
91 xcb_atom_t net_wm_window_type;
92 xcb_atom_t net_wm_window_type_desktop;
93 xcb_atom_t net_wm_window_type_dock;
94 xcb_atom_t net_wm_window_type_toolbar;
95 xcb_atom_t net_wm_window_type_menu;
96 xcb_atom_t net_wm_window_type_utility;
97 xcb_atom_t net_wm_window_type_splash;
98 xcb_atom_t net_wm_window_type_dialog;
99 xcb_atom_t net_wm_window_type_dropdown;
100 xcb_atom_t net_wm_window_type_popup;
101 xcb_atom_t net_wm_window_type_tooltip;
102 xcb_atom_t net_wm_window_type_notification;
103 xcb_atom_t net_wm_window_type_combo;
104 xcb_atom_t net_wm_window_type_dnd;
105 xcb_atom_t net_wm_window_type_normal;
106 xcb_atom_t net_wm_moveresize;
107 xcb_atom_t net_supporting_wm_check;
108 xcb_atom_t net_supported;
109 xcb_atom_t motif_wm_hints;
110 xcb_atom_t clipboard;
Kristian Høgsbergcba022a2012-06-04 10:11:45 -0400111 xcb_atom_t clipboard_manager;
Kristian Høgsberg102bf032012-05-21 15:52:02 -0400112 xcb_atom_t targets;
113 xcb_atom_t utf8_string;
114 xcb_atom_t wl_selection;
115 xcb_atom_t incr;
116 xcb_atom_t timestamp;
117 xcb_atom_t multiple;
118 xcb_atom_t compound_text;
119 xcb_atom_t text;
120 xcb_atom_t string;
121 xcb_atom_t text_plain_utf8;
122 xcb_atom_t text_plain;
123 } atom;
124};
125
126void
127dump_property(struct weston_wm *wm, xcb_atom_t property,
128 xcb_get_property_reply_t *reply);
Kristian Høgsberg0273b572012-05-30 09:58:02 -0400129void
130read_and_dump_property(struct weston_wm *wm,
131 xcb_window_t window, xcb_atom_t property);
Kristian Høgsberg102bf032012-05-21 15:52:02 -0400132
133const char *
134get_atom_name(xcb_connection_t *c, xcb_atom_t atom);
135
Kristian Høgsberg4dec0112012-06-03 09:18:06 -0400136void
137weston_wm_selection_init(struct weston_wm *wm);
Kristian Høgsberg102bf032012-05-21 15:52:02 -0400138int
139weston_wm_handle_selection_event(struct weston_wm *wm,
140 xcb_generic_event_t *event);
141
142void
143weston_wm_set_selection(struct wl_listener *listener, void *data);
Kristian Høgsberge10b1242012-05-21 16:48:05 -0400144
145extern const struct xserver_interface xserver_implementation;
146
147struct weston_wm *
148weston_wm_create(struct weston_xserver *wxs);
149void
150weston_wm_destroy(struct weston_wm *wm);
151