awful.titlebar: do not build args
[awesome.git] / common / xembed.h
blob7f0eb45b193c1842096b0c8cad42a2f86048d92a
1 /*
2 * common/xembed.h - XEMBED functions header
4 * Copyright © 2007-2008 Julien Danjou <julien@danjou.info>
5 * Copyright © 2004 Matthew Reppert
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #ifndef AWESOME_COMMON_XEMBED_H
24 #define AWESOME_COMMON_XEMBED_H
26 #include <xcb/xcb.h>
28 #include <stdbool.h>
30 #include "common/list.h"
31 #include "common/util.h"
33 /** XEMBED information for a window.
35 typedef struct
37 unsigned long version;
38 unsigned long flags;
39 } xembed_info_t;
41 typedef struct xembed_window_t xembed_window_t;
42 struct xembed_window_t
44 xcb_window_t win;
45 int phys_screen;
46 xembed_info_t info;
47 xembed_window_t *prev, *next;
50 DO_SLIST(xembed_window_t, xembed_window, p_delete)
52 /** The version of the XEMBED protocol that this library supports. */
53 #define XEMBED_VERSION 0
55 /** Flags for _XEMBED_INFO */
56 #define XEMBED_MAPPED (1 << 0)
57 #define XEMBED_INFO_FLAGS_ALL 1
59 /** XEMBED messages */
60 #define XEMBED_EMBEDDED_NOTIFY 0
61 #define XEMBED_WINDOW_ACTIVATE 1
62 #define XEMBED_WINDOW_DEACTIVATE 2
63 #define XEMBED_REQUEST_FOCUS 3
64 #define XEMBED_FOCUS_IN 4
65 #define XEMBED_FOCUS_OUT 5
66 #define XEMBED_FOCUS_NEXT 6
67 #define XEMBED_FOCUS_PREV 7
68 /* 8-9 were used for XEMBED_GRAB_KEY/XEMBED_UNGRAB_KEY */
69 #define XEMBED_MODALITY_ON 10
70 #define XEMBED_MODALITY_OFF 11
71 #define XEMBED_REGISTER_ACCELERATOR 12
72 #define XEMBED_UNREGISTER_ACCELERATOR 13
73 #define XEMBED_ACTIVATE_ACCELERATOR 14
75 /** Details for XEMBED_FOCUS_IN */
76 #define XEMBED_FOCUS_CURRENT 0
77 #define XEMBED_FOCUS_FIRST 1
78 #define XEMBED_FOCUS_LAST 2
81 /** Modifiers field for XEMBED_REGISTER_ACCELERATOR */
82 #define XEMBED_MODIFIER_SHIFT (1 << 0)
83 #define XEMBED_MODIFIER_CONTROL (1 << 1)
84 #define XEMBED_MODIFIER_ALT (1 << 2)
85 #define XEMBED_MODIFIER_SUPER (1 << 3)
86 #define XEMBED_MODIFIER_HYPER (1 << 4)
89 /** Flags for XEMBED_ACTIVATE_ACCELERATOR */
90 #define XEMBED_ACCELERATOR_OVERLOADED (1 << 0)
93 void xembed_message_send(xcb_connection_t *, xcb_window_t, long, long, long, long);
94 xembed_window_t * xembed_getbywin(xembed_window_t *, xcb_window_t);
95 void xembed_property_update(xcb_connection_t *, xembed_window_t *, xcb_get_property_reply_t *);
96 xcb_get_property_cookie_t xembed_info_get_unchecked(xcb_connection_t *,
97 xcb_window_t);
98 bool xembed_info_get_reply(xcb_connection_t *connection,
99 xcb_get_property_cookie_t cookie,
100 xembed_info_t *info);
103 /** Indicate to an embedded window that it has focus.
104 * \param c The X connection.
105 * \param client The client.
106 * \param focus_type The type of focus.
108 static inline void
109 xembed_focus_in(xcb_connection_t *c, xcb_window_t client, long focus_type)
111 xembed_message_send(c, client, XEMBED_FOCUS_IN, focus_type, 0, 0);
114 /** Notify a window that it has become active.
115 * \param c The X connection.
116 * \param client The window to notify.
118 static inline void
119 xembed_window_activate(xcb_connection_t *c, xcb_window_t client)
121 xembed_message_send(c, client, XEMBED_WINDOW_ACTIVATE, 0, 0, 0);
124 /** Notify a window that it has become inactive.
125 * \param c The X connection.
126 * \param client The window to notify.
128 static inline
129 void xembed_window_deactivate(xcb_connection_t *c, xcb_window_t client)
131 xembed_message_send(c, client, XEMBED_WINDOW_DEACTIVATE, 0, 0, 0);
134 /** Notify a window that its embed request has been received and accepted.
135 * \param c The X connection.
136 * \param client The client to send message to.
137 * \param embedder The embedder window.
138 * \param version The version.
140 static inline void
141 xembed_embedded_notify(xcb_connection_t *c,
142 xcb_window_t client, xcb_window_t embedder,
143 long version)
145 xembed_message_send(c, client, XEMBED_EMBEDDED_NOTIFY, 0, embedder, version);
148 /** Have the embedder end XEMBED protocol communication with a child.
149 * \param connection The X connection.
150 * \param child The window to unembed.
151 * \param root The root window to reparent to.
153 static inline void
154 xembed_window_unembed(xcb_connection_t *connection, xcb_window_t child, xcb_window_t root)
156 xcb_reparent_window(connection, child, root, 0, 0);
159 /** Indicate to an embedded window that it has lost focus.
160 * \param c The X connection.
161 * \param client The client to send message to.
163 static inline void
164 xembed_focus_out(xcb_connection_t *c, xcb_window_t client)
166 xembed_message_send(c, client, XEMBED_FOCUS_OUT, 0, 0, 0);
170 #endif
171 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80