Kristian Høgsberg | 102bf03 | 2012-05-21 15:52:02 -0400 | [diff] [blame] | 1 | /* |
| 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 | |
| 30 | struct xserver { |
| 31 | struct wl_resource resource; |
| 32 | }; |
| 33 | |
| 34 | struct 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øgsberg | 102bf03 | 2012-05-21 15:52:02 -0400 | [diff] [blame] | 48 | struct wl_listener destroy_listener; |
| 49 | }; |
| 50 | |
| 51 | struct 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; |
Tiago Vignatti | ce1baa8 | 2012-07-20 23:09:55 +0300 | [diff] [blame] | 60 | struct weston_wm_window *focus_latest; |
Kristian Høgsberg | 102bf03 | 2012-05-21 15:52:02 -0400 | [diff] [blame] | 61 | struct theme *theme; |
Tiago Vignatti | 236b48d | 2012-07-16 12:09:19 -0400 | [diff] [blame] | 62 | xcb_cursor_t *cursors; |
| 63 | int last_cursor; |
Kristian Høgsberg | e89cef3 | 2012-07-16 11:57:08 -0400 | [diff] [blame] | 64 | xcb_render_pictforminfo_t format_rgb, format_rgba; |
Kristian Høgsberg | e10b124 | 2012-05-21 16:48:05 -0400 | [diff] [blame] | 65 | struct wl_listener activate_listener; |
Tiago Vignatti | 0d20d7c | 2012-09-27 17:48:37 +0300 | [diff] [blame^] | 66 | struct wl_listener kill_listener; |
Kristian Høgsberg | 102bf03 | 2012-05-21 15:52:02 -0400 | [diff] [blame] | 67 | |
| 68 | xcb_window_t selection_window; |
Kristian Høgsberg | 8056673 | 2012-06-01 00:08:12 -0400 | [diff] [blame] | 69 | xcb_window_t selection_owner; |
Kristian Høgsberg | 102bf03 | 2012-05-21 15:52:02 -0400 | [diff] [blame] | 70 | int incr; |
| 71 | int data_source_fd; |
| 72 | struct wl_event_source *property_source; |
| 73 | xcb_get_property_reply_t *property_reply; |
| 74 | int property_start; |
| 75 | struct wl_array source_data; |
| 76 | xcb_selection_request_event_t selection_request; |
| 77 | xcb_atom_t selection_target; |
| 78 | xcb_timestamp_t selection_timestamp; |
| 79 | int selection_property_set; |
| 80 | int flush_property_on_delete; |
| 81 | struct wl_listener selection_listener; |
| 82 | |
| 83 | struct { |
| 84 | xcb_atom_t wm_protocols; |
| 85 | xcb_atom_t wm_take_focus; |
| 86 | xcb_atom_t wm_delete_window; |
Kristian Høgsberg | a6d9a5e | 2012-05-30 12:15:44 -0400 | [diff] [blame] | 87 | xcb_atom_t wm_state; |
Kristian Høgsberg | 670b5d3 | 2012-06-04 11:00:40 -0400 | [diff] [blame] | 88 | xcb_atom_t wm_s0; |
Tiago Vignatti | 0d20d7c | 2012-09-27 17:48:37 +0300 | [diff] [blame^] | 89 | xcb_atom_t wm_client_machine; |
Kristian Høgsberg | 102bf03 | 2012-05-21 15:52:02 -0400 | [diff] [blame] | 90 | xcb_atom_t net_wm_name; |
Tiago Vignatti | 0d20d7c | 2012-09-27 17:48:37 +0300 | [diff] [blame^] | 91 | xcb_atom_t net_wm_pid; |
Kristian Høgsberg | 102bf03 | 2012-05-21 15:52:02 -0400 | [diff] [blame] | 92 | xcb_atom_t net_wm_icon; |
| 93 | xcb_atom_t net_wm_state; |
| 94 | xcb_atom_t net_wm_state_fullscreen; |
| 95 | xcb_atom_t net_wm_user_time; |
| 96 | xcb_atom_t net_wm_icon_name; |
| 97 | xcb_atom_t net_wm_window_type; |
| 98 | xcb_atom_t net_wm_window_type_desktop; |
| 99 | xcb_atom_t net_wm_window_type_dock; |
| 100 | xcb_atom_t net_wm_window_type_toolbar; |
| 101 | xcb_atom_t net_wm_window_type_menu; |
| 102 | xcb_atom_t net_wm_window_type_utility; |
| 103 | xcb_atom_t net_wm_window_type_splash; |
| 104 | xcb_atom_t net_wm_window_type_dialog; |
| 105 | xcb_atom_t net_wm_window_type_dropdown; |
| 106 | xcb_atom_t net_wm_window_type_popup; |
| 107 | xcb_atom_t net_wm_window_type_tooltip; |
| 108 | xcb_atom_t net_wm_window_type_notification; |
| 109 | xcb_atom_t net_wm_window_type_combo; |
| 110 | xcb_atom_t net_wm_window_type_dnd; |
| 111 | xcb_atom_t net_wm_window_type_normal; |
| 112 | xcb_atom_t net_wm_moveresize; |
| 113 | xcb_atom_t net_supporting_wm_check; |
| 114 | xcb_atom_t net_supported; |
| 115 | xcb_atom_t motif_wm_hints; |
| 116 | xcb_atom_t clipboard; |
Kristian Høgsberg | cba022a | 2012-06-04 10:11:45 -0400 | [diff] [blame] | 117 | xcb_atom_t clipboard_manager; |
Kristian Høgsberg | 102bf03 | 2012-05-21 15:52:02 -0400 | [diff] [blame] | 118 | xcb_atom_t targets; |
| 119 | xcb_atom_t utf8_string; |
| 120 | xcb_atom_t wl_selection; |
| 121 | xcb_atom_t incr; |
| 122 | xcb_atom_t timestamp; |
| 123 | xcb_atom_t multiple; |
| 124 | xcb_atom_t compound_text; |
| 125 | xcb_atom_t text; |
| 126 | xcb_atom_t string; |
| 127 | xcb_atom_t text_plain_utf8; |
| 128 | xcb_atom_t text_plain; |
| 129 | } atom; |
| 130 | }; |
| 131 | |
| 132 | void |
| 133 | dump_property(struct weston_wm *wm, xcb_atom_t property, |
| 134 | xcb_get_property_reply_t *reply); |
Kristian Høgsberg | 0273b57 | 2012-05-30 09:58:02 -0400 | [diff] [blame] | 135 | void |
| 136 | read_and_dump_property(struct weston_wm *wm, |
| 137 | xcb_window_t window, xcb_atom_t property); |
Kristian Høgsberg | 102bf03 | 2012-05-21 15:52:02 -0400 | [diff] [blame] | 138 | |
| 139 | const char * |
| 140 | get_atom_name(xcb_connection_t *c, xcb_atom_t atom); |
| 141 | |
Kristian Høgsberg | 4dec011 | 2012-06-03 09:18:06 -0400 | [diff] [blame] | 142 | void |
| 143 | weston_wm_selection_init(struct weston_wm *wm); |
Kristian Høgsberg | 102bf03 | 2012-05-21 15:52:02 -0400 | [diff] [blame] | 144 | int |
| 145 | weston_wm_handle_selection_event(struct weston_wm *wm, |
| 146 | xcb_generic_event_t *event); |
| 147 | |
| 148 | void |
| 149 | weston_wm_set_selection(struct wl_listener *listener, void *data); |
Kristian Høgsberg | e10b124 | 2012-05-21 16:48:05 -0400 | [diff] [blame] | 150 | |
| 151 | extern const struct xserver_interface xserver_implementation; |
| 152 | |
| 153 | struct weston_wm * |
| 154 | weston_wm_create(struct weston_xserver *wxs); |
| 155 | void |
| 156 | weston_wm_destroy(struct weston_wm *wm); |
| 157 | |
Kristian Høgsberg | 5ba3189 | 2012-08-10 10:06:59 -0400 | [diff] [blame] | 158 | struct weston_seat * |
| 159 | weston_wm_pick_seat(struct weston_wm *wm); |