1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*- 2 // EWMH.hh for Blackbox - an X11 Window manager 3 // Copyright (c) 2001 - 2005 Sean 'Shaleh' Perry <shaleh@debian.org> 4 // Copyright (c) 1997 - 2000, 2002 - 2005 5 // Bradley T Hughes <bhughes at trolltech.com> 6 // 7 // Permission is hereby granted, free of charge, to any person obtaining a 8 // copy of this software and associated documentation files (the "Software"), 9 // to deal in the Software without restriction, including without limitation 10 // the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 // and/or sell copies of the Software, and to permit persons to whom the 12 // Software is furnished to do so, subject to the following conditions: 13 // 14 // The above copyright notice and this permission notice shall be included in 15 // all copies or substantial portions of the Software. 16 // 17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 // DEALINGS IN THE SOFTWARE. 24 25 #ifndef __EWMH_hh 26 #define __EWMH_hh 27 28 #include "Display.hh" 29 #include "Unicode.hh" 30 #include "Util.hh" 31 32 #include <string> 33 #include <vector> 34 35 namespace bt { 36 37 class EWMH: public NoCopy { 38 public: 39 explicit EWMH(const Display &_display); 40 41 typedef std::vector<Atom> AtomList; 42 typedef std::vector<Window> WindowList; 43 44 struct Strut { 45 unsigned int left, right, top, bottom; Strutbt::EWMH::Strut46 inline Strut(void) 47 : left(0), right(0), top(0), bottom(0) 48 { } 49 }; 50 51 struct StrutPartial { 52 unsigned int left, right, top, bottom; 53 unsigned int left_start, left_end; 54 unsigned int right_start, right_end; 55 unsigned int top_start, top_end; 56 unsigned int bottom_start, bottom_end; StrutPartialbt::EWMH::StrutPartial57 inline StrutPartial(void) 58 : left(0u), right(0u), top(0u), bottom(0u), 59 left_start(0u), left_end(0u), 60 right_start(0u), right_end(0u), 61 top_start(0u), top_end(0u), 62 bottom_start(0u), bottom_end(0u) 63 { } 64 }; 65 utf8String(void) const66 inline Atom utf8String(void) const 67 { return utf8_string; } 68 69 // root window properties supported(void) const70 inline Atom supported(void) const 71 { return net_supported; } clientList(void) const72 inline Atom clientList(void) const 73 { return net_client_list; } clientListStacking(void) const74 inline Atom clientListStacking(void) const 75 { return net_client_list_stacking; } numberOfDesktops(void) const76 inline Atom numberOfDesktops(void) const 77 { return net_number_of_desktops; } desktopGeometry(void) const78 inline Atom desktopGeometry(void) const 79 { return net_desktop_geometry; } desktopViewport(void) const80 inline Atom desktopViewport(void) const 81 { return net_desktop_viewport; } currentDesktop(void) const82 inline Atom currentDesktop(void) const 83 { return net_current_desktop; } desktopNames(void) const84 inline Atom desktopNames(void) const 85 { return net_desktop_names; } activeWindow(void) const86 inline Atom activeWindow(void) const 87 { return net_active_window; } workarea(void) const88 inline Atom workarea(void) const 89 { return net_workarea; } supportingWMCheck(void) const90 inline Atom supportingWMCheck(void) const 91 { return net_supporting_wm_check; } virtualRoots(void) const92 inline Atom virtualRoots(void) const 93 { return net_virtual_roots; } desktopLayout(void) const94 inline Atom desktopLayout(void) const 95 { return net_desktop_layout; } showingDesktop(void) const96 inline Atom showingDesktop(void) const 97 { return net_showing_desktop; } 98 99 void setSupported(Window target, Atom atoms[], unsigned int count) const; 100 bool readSupported(Window target, AtomList& atoms) const; 101 void setClientList(Window target, WindowList& windows) const; 102 bool readClientList(Window target, WindowList& windows) const; 103 void setClientListStacking(Window target, WindowList& windows) const; 104 bool readClientListStacking(Window target, WindowList& windows) const; 105 void setNumberOfDesktops(Window target, unsigned int count) const; 106 bool readNumberOfDesktops(Window target, unsigned int* number) const; 107 void setDesktopGeometry(Window target, 108 unsigned int width, unsigned int height) const; 109 bool readDesktopGeometry(Window target, 110 unsigned int* width, unsigned int* height) const; 111 void setDesktopViewport(Window target, int x, int y) const; 112 bool readDesktopViewport(Window target, int *x, int *y) const; 113 void setCurrentDesktop(Window target, unsigned int number) const; 114 bool readCurrentDesktop(Window target, unsigned int* number) const; 115 void setDesktopNames(Window target, 116 const std::vector<bt::ustring> &names) const; 117 bool readDesktopNames(Window target, 118 std::vector<bt::ustring> &names) const; 119 void setActiveWindow(Window target, Window data) const; 120 void setWorkarea(Window target, unsigned long workareas[], 121 unsigned int count) const; 122 void setSupportingWMCheck(Window target, Window data) const; 123 bool readSupportingWMCheck(Window target, Window* window) const; 124 void setVirtualRoots(Window target, WindowList &windows) const; 125 bool readVirtualRoots(Window target, WindowList &windows) const; 126 // void setDesktopLayout(Window target, ...) const; 127 // void readDesktopLayout(Window target, ...) const; 128 129 // other root messages closeWindow(void) const130 inline Atom closeWindow(void) const 131 { return net_close_window; } moveresizeWindow(void) const132 inline Atom moveresizeWindow(void) const 133 { return net_moveresize_window; } wmMoveResize(void) const134 inline Atom wmMoveResize(void) const 135 { return net_wm_moveresize; } restackWindow(void) const136 inline Atom restackWindow(void) const 137 { return net_restack_window; } requestFrameExtents(void) const138 inline Atom requestFrameExtents(void) const 139 { return net_request_frame_extents; } 140 141 // application properties wmName(void) const142 inline Atom wmName(void) const 143 { return net_wm_name; } wmVisibleName(void) const144 inline Atom wmVisibleName(void) const 145 { return net_wm_visible_name; } wmIconName(void) const146 inline Atom wmIconName(void) const 147 { return net_wm_icon_name; } wmVisibleIconName(void) const148 inline Atom wmVisibleIconName(void) const 149 { return net_wm_visible_icon_name; } wmDesktop(void) const150 inline Atom wmDesktop(void) const 151 { return net_wm_desktop; } wmWindowType(void) const152 inline Atom wmWindowType(void) const 153 { return net_wm_window_type; } wmWindowTypeDesktop(void) const154 inline Atom wmWindowTypeDesktop(void) const 155 { return net_wm_window_type_desktop; } wmWindowTypeDock(void) const156 inline Atom wmWindowTypeDock(void) const 157 { return net_wm_window_type_dock; } wmWindowTypeToolbar(void) const158 inline Atom wmWindowTypeToolbar(void) const 159 { return net_wm_window_type_toolbar; } wmWindowTypeMenu(void) const160 inline Atom wmWindowTypeMenu(void) const 161 { return net_wm_window_type_menu; } wmWindowTypeUtility(void) const162 inline Atom wmWindowTypeUtility(void) const 163 { return net_wm_window_type_utility; } wmWindowTypeSplash(void) const164 inline Atom wmWindowTypeSplash(void) const 165 { return net_wm_window_type_splash; } wmWindowTypeDialog(void) const166 inline Atom wmWindowTypeDialog(void) const 167 { return net_wm_window_type_dialog; } wmWindowTypeNormal(void) const168 inline Atom wmWindowTypeNormal(void) const 169 { return net_wm_window_type_normal; } wmState(void) const170 inline Atom wmState(void) const 171 { return net_wm_state; } wmStateModal(void) const172 inline Atom wmStateModal(void) const 173 { return net_wm_state_modal; } wmStateSticky(void) const174 inline Atom wmStateSticky(void) const 175 { return net_wm_state_sticky; } wmStateMaximizedVert(void) const176 inline Atom wmStateMaximizedVert(void) const 177 { return net_wm_state_maximized_vert; } wmStateMaximizedHorz(void) const178 inline Atom wmStateMaximizedHorz(void) const 179 { return net_wm_state_maximized_horz; } wmStateShaded(void) const180 inline Atom wmStateShaded(void) const 181 { return net_wm_state_shaded; } wmStateSkipTaskbar(void) const182 inline Atom wmStateSkipTaskbar(void) const 183 { return net_wm_state_skip_taskbar; } wmStateSkipPager(void) const184 inline Atom wmStateSkipPager(void) const 185 { return net_wm_state_skip_pager; } wmStateHidden(void) const186 inline Atom wmStateHidden(void) const 187 { return net_wm_state_hidden; } wmStateFullscreen(void) const188 inline Atom wmStateFullscreen(void) const 189 { return net_wm_state_fullscreen; } wmStateAbove(void) const190 inline Atom wmStateAbove(void) const 191 { return net_wm_state_above; } wmStateBelow(void) const192 inline Atom wmStateBelow(void) const 193 { return net_wm_state_below; } wmStateDemandsAttention(void) const194 inline Atom wmStateDemandsAttention(void) const 195 { return net_wm_state_demands_attention; } wmStateRemove(void) const196 inline Atom wmStateRemove(void) const 197 { return 0; } wmStateAdd(void) const198 inline Atom wmStateAdd(void) const 199 { return 1; } wmStateToggle(void) const200 inline Atom wmStateToggle(void) const 201 { return 2; } wmAllowedActions(void) const202 inline Atom wmAllowedActions(void) const 203 { return net_wm_allowed_actions; } wmActionMove(void) const204 inline Atom wmActionMove(void) const 205 { return net_wm_action_move; } wmActionResize(void) const206 inline Atom wmActionResize(void) const 207 { return net_wm_action_resize; } wmActionMinimize(void) const208 inline Atom wmActionMinimize(void) const 209 { return net_wm_action_minimize; } wmActionShade(void) const210 inline Atom wmActionShade(void) const 211 { return net_wm_action_shade; } wmActionStick(void) const212 inline Atom wmActionStick(void) const 213 { return net_wm_action_stick; } wmActionMaximizeHorz(void) const214 inline Atom wmActionMaximizeHorz(void) const 215 { return net_wm_action_maximize_horz; } wmActionMaximizeVert(void) const216 inline Atom wmActionMaximizeVert(void) const 217 { return net_wm_action_maximize_vert; } wmActionFullscreen(void) const218 inline Atom wmActionFullscreen(void) const 219 { return net_wm_action_fullscreen; } wmActionChangeDesktop(void) const220 inline Atom wmActionChangeDesktop(void) const 221 { return net_wm_action_change_desktop; } wmActionClose(void) const222 inline Atom wmActionClose(void) const 223 { return net_wm_action_close; } wmStrut(void) const224 inline Atom wmStrut(void) const 225 { return net_wm_strut; } wmStrutPartial(void) const226 inline Atom wmStrutPartial(void) const 227 { return net_wm_strut_partial; } wmIconGeometry(void) const228 inline Atom wmIconGeometry(void) const 229 { return net_wm_icon_geometry; } wmIcon(void) const230 inline Atom wmIcon(void) const 231 { return net_wm_icon; } wmPid(void) const232 inline Atom wmPid(void) const 233 { return net_wm_pid; } wmHandledIcons(void) const234 inline Atom wmHandledIcons(void) const 235 { return net_wm_handled_icons; } wmUserTime(void) const236 inline Atom wmUserTime(void) const 237 { return net_wm_user_time; } 238 239 void setWMName(Window target, const bt::ustring &name) const; 240 bool readWMName(Window target, bt::ustring &name) const; 241 void setWMVisibleName(Window target, const bt::ustring &name) const; 242 bool readWMIconName(Window target, bt::ustring &name) const; 243 void setWMVisibleIconName(Window target, const bt::ustring &name) const; 244 void setWMDesktop(Window target, unsigned int desktop) const; 245 bool readWMDesktop(Window target, unsigned int& desktop) const; 246 bool readWMWindowType(Window target, AtomList& types) const; 247 void setWMState(Window target, AtomList& atoms) const; 248 bool readWMState(Window target, AtomList& states) const; 249 void setWMAllowedActions(Window target, AtomList& atoms) const; 250 bool readWMStrut(Window target, Strut* strut) const; 251 bool readWMStrutPartial(Window target, StrutPartial* strut) const; 252 bool readWMIconGeometry(Window target, int &x, int &y, 253 unsigned int &width, unsigned int &height) const; 254 // bool readWMIcon(Window target, ...) const; 255 bool readWMPid(Window target, unsigned int &pid) const; 256 // bool readWMHandledIcons(Window target, ...) const; 257 bool readWMUserTime(Window target, Time &user_time) const; 258 // void readFrameExtents(Window target, ...) const; 259 260 // Window Manager Protocols wmPing(void) const261 inline Atom wmPing(void) const 262 { return net_wm_ping; } wmSyncRequest(void) const263 inline Atom wmSyncRequest(void) const 264 { return net_wm_sync_request; } 265 266 // utility 267 void removeProperty(Window target, Atom atom) const; 268 bool isSupportedWMWindowType(Atom atom) const; 269 270 void setProperty(Window target, Atom type, Atom property, 271 const unsigned char *data, unsigned long count) const; 272 273 bool getProperty(Window target, Atom type, Atom property, 274 unsigned char** data) const; 275 bool getListProperty(Window target, Atom type, Atom property, 276 unsigned char** data, unsigned long* count) const; 277 278 private: 279 const Display &display; 280 Atom utf8_string, 281 net_supported, 282 net_client_list, 283 net_client_list_stacking, 284 net_number_of_desktops, 285 net_desktop_geometry, 286 net_desktop_viewport, 287 net_current_desktop, 288 net_desktop_names, 289 net_active_window, 290 net_workarea, 291 net_supporting_wm_check, 292 net_virtual_roots, 293 net_desktop_layout, 294 net_showing_desktop, 295 net_close_window, 296 net_moveresize_window, 297 net_wm_moveresize, 298 net_restack_window, 299 net_request_frame_extents, 300 net_wm_name, 301 net_wm_visible_name, 302 net_wm_icon_name, 303 net_wm_visible_icon_name, 304 net_wm_desktop, 305 net_wm_window_type, 306 net_wm_window_type_desktop, 307 net_wm_window_type_dock, 308 net_wm_window_type_toolbar, 309 net_wm_window_type_menu, 310 net_wm_window_type_utility, 311 net_wm_window_type_splash, 312 net_wm_window_type_dialog, 313 net_wm_window_type_normal, 314 net_wm_state, 315 net_wm_state_modal, 316 net_wm_state_sticky, 317 net_wm_state_maximized_vert, 318 net_wm_state_maximized_horz, 319 net_wm_state_shaded, 320 net_wm_state_skip_taskbar, 321 net_wm_state_skip_pager, 322 net_wm_state_hidden, 323 net_wm_state_fullscreen, 324 net_wm_state_above, 325 net_wm_state_below, 326 net_wm_state_demands_attention, 327 net_wm_state_remove, 328 net_wm_state_add, 329 net_wm_state_toggle, 330 net_wm_allowed_actions, 331 net_wm_action_move, 332 net_wm_action_resize, 333 net_wm_action_minimize, 334 net_wm_action_shade, 335 net_wm_action_stick, 336 net_wm_action_maximize_horz, 337 net_wm_action_maximize_vert, 338 net_wm_action_fullscreen, 339 net_wm_action_change_desktop, 340 net_wm_action_close, 341 net_wm_strut, 342 net_wm_strut_partial, 343 net_wm_icon_geometry, 344 net_wm_icon, 345 net_wm_pid, 346 net_wm_handled_icons, 347 net_wm_user_time, 348 net_frame_extents, 349 net_wm_ping, 350 net_wm_sync_request; 351 }; 352 353 } // namespace bt 354 355 #endif // __EWMH_hh 356