YggdrasilWM  0.1.1
A tiny window manager coded in C++
X11Wrapper Class Reference

#include <X11Wrapper.hpp>

Inheritance diagram for X11Wrapper:
Inheritance graph
Collaboration diagram for X11Wrapper:
Collaboration graph

Public Member Functions

 X11Wrapper ()=default
 
 ~X11Wrapper ()=default
 
Display * openDisplay () override
 
Display * openDisplay (const char *displayName) override
 
void closeDisplay (Display *display) override
 
int defaultScreen (Display *display) override
 
Window rootWindow (Display *display, int screen) override
 
Atom internAtom (Display *display, const char *atomName, bool onlyIfExists) override
 
int displayWidth (Display *display, int screen) override
 
int displayHeight (Display *display, int screen) override
 
int grabServer (Display *display) override
 
int ungrabServer (Display *display) override
 
int flush (Display *display) override
 
XErrorHandler setErrorHandler (XErrorHandler handler) override
 
int selectInput (Display *display, Window window, long eventMask) override
 
int sync (Display *display, bool discard) override
 
int queryTree (Display *display, Window window, Window *rootReturn, Window *parentReturn, Window **childrenReturn, unsigned int *nChildrenReturn) override
 
int freeX (void *data) override
 
int nextEvent (Display *display, XEvent *eventReturn) override
 
int sendEvent (Display *display, Window window, bool propagate, long eventMask, XEvent *event_send) override
 
int changeProperty (Display *display, Window window, Atom property, Atom type, int format, int mode, const unsigned char *data, int nelements) override
 
int getProperty (Display *display, Window window, Atom property, long longOffset, long longLength, bool delete_, Atom reqType, Atom *actualTypeReturn, int *actualFormatReturn, unsigned long *nitemsReturn, unsigned long *bytesAfterReturn, unsigned char **propReturn) override
 
int setInputFocus (Display *display, Window focus, int revertTo, Time time) override
 
int getErrorText (Display *display, int code, char *buffer_return, int length) override
 
int mapWindow (Display *display, Window window) override
 
int unmapWindow (Display *display, Window window) override
 
int configureWindow (Display *display, Window window, unsigned valueMask, XWindowChanges *changes) override
 
int setInputFocus (Display *display, Window focus, int revertTo) override
 
int raiseWindow (Display *display, Window window) override
 
int lowerWindow (Display *display, Window window) override
 
int setWindowBorder (Display *display, Window window, unsigned long border) override
 
int getWindowProperty (Display *display, Window window, Atom property, long long_offset, long long_length, bool delete_, Atom req_type, Atom *actual_type_return, int *actual_format_return, unsigned long *nitems_return, unsigned long *bytes_after_return, unsigned char **prop_return) override
 
int destroyWindow (Display *display, Window window) override
 
int getWindowAttributes (Display *display, Window window, XWindowAttributes *window_attributes_return) override
 
int addToSaveSet (Display *display, Window window) override
 
int removeFromSaveSet (Display *display, Window window) override
 
int reparentWindow (Display *display, Window window, Window parent, int x, int y) override
 
int grabButton (Display *display, unsigned int button, unsigned int modifiers, Window grabWindow, bool ownerEvents, unsigned int eventMask, int pointerMode, int keyboardMode, Window confineTo, Cursor cursor) override
 
int ungrabButton (Display *display, unsigned int button, unsigned int modifiers, Window grab_window) override
 
int grabKey (Display *display, int keycode, unsigned int modifiers, Window grabWindow, bool ownerEvents, int pointerMode, int keyboardMode) override
 
int ungrabKey (Display *display, int keycode, unsigned int modifiers, Window grabWindow) override
 
int moveWindow (Display *display, Window window, int x, int y) override
 
int resizeWindow (Display *display, Window window, unsigned int width, unsigned int height) override
 
int keysymToKeycode (Display *display, int keysym) override
 
KeySym stringToKeysym (const char *string) override
 
Window createWindow (Display *display, Window parent, int x, int y, unsigned int width, unsigned int height, unsigned int border_width, int depth, unsigned int _class, Visual *visual, unsigned long valuemask, XSetWindowAttributes *attributes) override
 
int clearWindow (Display *display, Window window) override
 
int drawString (Display *display, Window window, GC gc, int x, int y, const char *string, int length) override
 
Window createSimpleWindow (Display *display, Window parent, int x, int y, unsigned int width, unsigned int height, unsigned int border_width, unsigned long border, unsigned long background) override
 

Constructor & Destructor Documentation

◆ X11Wrapper()

X11Wrapper::X11Wrapper ( )
default

◆ ~X11Wrapper()

X11Wrapper::~X11Wrapper ( )
default

Member Function Documentation

◆ addToSaveSet()

int X11Wrapper::addToSaveSet ( Display *  display,
Window  window 
)
overridevirtual

Implements BaseX11Wrapper.

291  {
292  return XAddToSaveSet(display, window);
293 }

◆ changeProperty()

int X11Wrapper::changeProperty ( Display *  display,
Window  window,
Atom  property,
Atom  type,
int  format,
int  mode,
const unsigned char *  data,
int  nelements 
)
overridevirtual

Implements BaseX11Wrapper.

152  {
153  int r = XChangeProperty(display,
154  window,
155  property,
156  type,
157  format,
158  mode,
159  data,
160  nelements);
161  if (r != 0) {
162  throw X11Exception("Failed to change property");
163  }
164  return r;
165 }
Definition: YggdrasilExceptions.hpp:36

◆ clearWindow()

int X11Wrapper::clearWindow ( Display *  display,
Window  window 
)
overridevirtual

Implements BaseX11Wrapper.

426  {
427  int r = XClearWindow(display, window);
428  if (r != 0) {
429  throw X11Exception("Failed to clear window");
430  }
431  return r;
432 }

◆ closeDisplay()

void X11Wrapper::closeDisplay ( Display *  display)
overridevirtual

Implements BaseX11Wrapper.

47  {
48  int r = XCloseDisplay(display);
49  if (r == 0) {
50  throw X11Exception("Failed to close display");
51  }
52 }

◆ configureWindow()

int X11Wrapper::configureWindow ( Display *  display,
Window  window,
unsigned  valueMask,
XWindowChanges *  changes 
)
overridevirtual

Implements BaseX11Wrapper.

219  {
220  return XConfigureWindow(display, window, valueMask, changes);
221 }

◆ createSimpleWindow()

Window X11Wrapper::createSimpleWindow ( Display *  display,
Window  parent,
int  x,
int  y,
unsigned int  width,
unsigned int  height,
unsigned int  border_width,
unsigned long  border,
unsigned long  background 
)
overridevirtual

Implements BaseX11Wrapper.

453  {
454  Window r = XCreateSimpleWindow(display,
455  parent,
456  x, y,
457  width, height,
458  border_width,
459  border,
460  background);
461  if (r == 0) {
462  throw X11Exception("Failed to create simple window");
463  }
464  return r;
465 }

◆ createWindow()

Window X11Wrapper::createWindow ( Display *  display,
Window  parent,
int  x,
int  y,
unsigned int  width,
unsigned int  height,
unsigned int  border_width,
int  depth,
unsigned int  _class,
Visual *  visual,
unsigned long  valuemask,
XSetWindowAttributes *  attributes 
)
overridevirtual

Implements BaseX11Wrapper.

409  {
410  Window r = XCreateWindow(display,
411  parent,
412  x, y,
413  width, height,
414  border_width,
415  depth,
416  _class,
417  visual,
418  valuemask,
419  attributes);
420  if (r == 0) {
421  throw X11Exception("Failed to create window");
422  }
423  return r;
424 }

◆ defaultScreen()

int X11Wrapper::defaultScreen ( Display *  display)
overridevirtual

Implements BaseX11Wrapper.

54  {
55  return DefaultScreen(display);
56 }

◆ destroyWindow()

int X11Wrapper::destroyWindow ( Display *  display,
Window  window 
)
overridevirtual

Implements BaseX11Wrapper.

277  {
278  return XDestroyWindow(display, window);
279 }

◆ displayHeight()

int X11Wrapper::displayHeight ( Display *  display,
int  screen 
)
overridevirtual

Implements BaseX11Wrapper.

74  {
75  return DisplayHeight(display, screen);
76 }

◆ displayWidth()

int X11Wrapper::displayWidth ( Display *  display,
int  screen 
)
overridevirtual

Implements BaseX11Wrapper.

70  {
71  return DisplayWidth(display, screen);
72 }

◆ drawString()

int X11Wrapper::drawString ( Display *  display,
Window  window,
GC  gc,
int  x,
int  y,
const char *  string,
int  length 
)
overridevirtual

Implements BaseX11Wrapper.

439  {
440  int r = XDrawString(display, window, gc, x, y, string, length);
441  if (r != 0) {
442  throw X11Exception("Failed to draw string");
443  }
444  return r;
445 }

◆ flush()

int X11Wrapper::flush ( Display *  display)
overridevirtual

Implements BaseX11Wrapper.

86  {
87  return XFlush(display);
88 }

◆ freeX()

int X11Wrapper::freeX ( void *  data)
overridevirtual

Implements BaseX11Wrapper.

125  {
126  return XFree(data);
127 }

◆ getErrorText()

int X11Wrapper::getErrorText ( Display *  display,
int  code,
char *  buffer_return,
int  length 
)
overridevirtual

Implements BaseX11Wrapper.

208  {
209  return XGetErrorText(display, code, buffer_return, length);
210 }

◆ getProperty()

int X11Wrapper::getProperty ( Display *  display,
Window  window,
Atom  property,
long  longOffset,
long  longLength,
bool  delete_,
Atom  reqType,
Atom *  actualTypeReturn,
int *  actualFormatReturn,
unsigned long *  nitemsReturn,
unsigned long *  bytesAfterReturn,
unsigned char **  propReturn 
)
overridevirtual

Implements BaseX11Wrapper.

179  {
180  int r = XGetWindowProperty(display,
181  window,
182  property,
183  longOffset,
184  longLength,
185  delete_,
186  reqType,
187  actualTypeReturn,
188  actualFormatReturn,
189  nitemsReturn,
190  bytesAfterReturn,
191  propReturn);
192  if (r != 0) {
193  throw X11Exception("Failed to get property");
194  }
195  return r;
196 }

◆ getWindowAttributes()

int X11Wrapper::getWindowAttributes ( Display *  display,
Window  window,
XWindowAttributes *  window_attributes_return 
)
overridevirtual

Implements BaseX11Wrapper.

283  {
284  int r = XGetWindowAttributes(display, window, window_attributes_return);
285  if (r == 0) {
286  throw X11Exception("Failed to get window attributes");
287  }
288  return r;
289 }

◆ getWindowProperty()

int X11Wrapper::getWindowProperty ( Display *  display,
Window  window,
Atom  property,
long  long_offset,
long  long_length,
bool  delete_,
Atom  req_type,
Atom *  actual_type_return,
int *  actual_format_return,
unsigned long *  nitems_return,
unsigned long *  bytes_after_return,
unsigned char **  prop_return 
)
overridevirtual

Implements BaseX11Wrapper.

262  {
263  return XGetWindowProperty(display,
264  window,
265  property,
266  long_offset,
267  long_length,
268  delete_,
269  req_type,
270  actual_type_return,
271  actual_format_return,
272  nitems_return,
273  bytes_after_return,
274  prop_return);
275 }

◆ grabButton()

int X11Wrapper::grabButton ( Display *  display,
unsigned int  button,
unsigned int  modifiers,
Window  grabWindow,
bool  ownerEvents,
unsigned int  eventMask,
int  pointerMode,
int  keyboardMode,
Window  confineTo,
Cursor  cursor 
)
overridevirtual

Implements BaseX11Wrapper.

316  {
317  return XGrabButton(display,
318  button,
319  modifiers,
320  grabWindow,
321  ownerEvents,
322  eventMask,
323  pointerMode,
324  keyboardMode,
325  confineTo,
326  cursor);
327 }

◆ grabKey()

int X11Wrapper::grabKey ( Display *  display,
int  keycode,
unsigned int  modifiers,
Window  grabWindow,
bool  ownerEvents,
int  pointerMode,
int  keyboardMode 
)
overridevirtual

Implements BaseX11Wrapper.

346  {
347  int r = XGrabKey(display,
348  keycode,
349  modifiers,
350  grabWindow,
351  ownerEvents,
352  pointerMode,
353  keyboardMode);
354  if (r != 0) {
355  throw X11Exception("Failed to grab key");
356  }
357  return r;
358 }

◆ grabServer()

int X11Wrapper::grabServer ( Display *  display)
overridevirtual

Implements BaseX11Wrapper.

78  {
79  return XGrabServer(display);
80 }

◆ internAtom()

Atom X11Wrapper::internAtom ( Display *  display,
const char *  atomName,
bool  onlyIfExists 
)
overridevirtual

Implements BaseX11Wrapper.

62  {
63  Atom r = XInternAtom(display, atomName, onlyIfExists);
64  if (r == None) {
65  throw X11Exception("Failed to intern atom");
66  }
67  return r;
68 }

◆ keysymToKeycode()

int X11Wrapper::keysymToKeycode ( Display *  display,
int  keysym 
)
overridevirtual

Implements BaseX11Wrapper.

382  {
383  int r = XKeysymToKeycode(display, keysym);
384  if (r == 0) {
385  throw X11Exception("Failed to get keycode from keysym");
386  }
387  return r;
388 }

◆ lowerWindow()

int X11Wrapper::lowerWindow ( Display *  display,
Window  window 
)
overridevirtual

Implements BaseX11Wrapper.

239  {
240  int r = XLowerWindow(display, window);
241  if (r != 0) {
242  throw X11Exception("Failed to lower window");
243  }
244  return r;
245 }

◆ mapWindow()

int X11Wrapper::mapWindow ( Display *  display,
Window  window 
)
overridevirtual

Implements BaseX11Wrapper.

212  {
213  return XMapWindow(display, window);
214 }

◆ moveWindow()

int X11Wrapper::moveWindow ( Display *  display,
Window  window,
int  x,
int  y 
)
overridevirtual

Implements BaseX11Wrapper.

371  {
372  return XMoveWindow(display, window, x, y);
373 }

◆ nextEvent()

int X11Wrapper::nextEvent ( Display *  display,
XEvent *  eventReturn 
)
overridevirtual

Implements BaseX11Wrapper.

129  {
130  int r = XNextEvent(display, eventReturn);
131  if (r != 0) {
132  throw X11Exception("Failed to get next event");
133  }
134  return r;
135 }

◆ openDisplay() [1/2]

Display * X11Wrapper::openDisplay ( )
overridevirtual

Implements BaseX11Wrapper.

31  {
32  Display * r = XOpenDisplay(nullptr);
33  if (r == nullptr) {
34  throw X11Exception("Failed to open display");
35  }
36  return r;
37 }

◆ openDisplay() [2/2]

Display * X11Wrapper::openDisplay ( const char *  displayName)
overridevirtual

Implements BaseX11Wrapper.

39  {
40  Display * r = XOpenDisplay(displayName);
41  if (r == nullptr) {
42  throw X11Exception("Failed to open display");
43  }
44  return r;
45 }

◆ queryTree()

int X11Wrapper::queryTree ( Display *  display,
Window  window,
Window *  rootReturn,
Window *  parentReturn,
Window **  childrenReturn,
unsigned int *  nChildrenReturn 
)
overridevirtual

Implements BaseX11Wrapper.

112  {
113  int r = XQueryTree(display,
114  window,
115  rootReturn,
116  parentReturn,
117  childrenReturn,
118  nChildrenReturn);
119  if (r == 0) {
120  throw X11Exception("Failed to query tree");
121  }
122  return r;
123 }

◆ raiseWindow()

int X11Wrapper::raiseWindow ( Display *  display,
Window  window 
)
overridevirtual

Implements BaseX11Wrapper.

235  {
236  return XRaiseWindow(display, window);
237 }

◆ removeFromSaveSet()

int X11Wrapper::removeFromSaveSet ( Display *  display,
Window  window 
)
overridevirtual

Implements BaseX11Wrapper.

295  {
296  int r = XRemoveFromSaveSet(display, window);
297  if (r != 0) {
298  throw X11Exception("Failed to remove from save set");
299  }
300  return r;
301 }

◆ reparentWindow()

int X11Wrapper::reparentWindow ( Display *  display,
Window  window,
Window  parent,
int  x,
int  y 
)
overridevirtual

Implements BaseX11Wrapper.

303  {
304  return XReparentWindow(display, window, parent, x, y);
305 }

◆ resizeWindow()

int X11Wrapper::resizeWindow ( Display *  display,
Window  window,
unsigned int  width,
unsigned int  height 
)
overridevirtual

Implements BaseX11Wrapper.

378  {
379  return XResizeWindow(display, window, width, height);
380 }

◆ rootWindow()

Window X11Wrapper::rootWindow ( Display *  display,
int  screen 
)
overridevirtual

Implements BaseX11Wrapper.

58  {
59  return RootWindow(display, screen);
60 }

◆ selectInput()

int X11Wrapper::selectInput ( Display *  display,
Window  window,
long  eventMask 
)
overridevirtual

Implements BaseX11Wrapper.

94  {
95  int r = XSelectInput(display, window, eventMask);
96  if (r == 0) {
97  throw X11Exception("Failed to select input");
98  }
99  return r;
100 }

◆ sendEvent()

int X11Wrapper::sendEvent ( Display *  display,
Window  window,
bool  propagate,
long  eventMask,
XEvent *  event_send 
)
overridevirtual

Implements BaseX11Wrapper.

137  {
138  int r = XSendEvent(display, window, propagate, eventMask, event_send);
139  if (r == 0) {
140  throw X11Exception("Failed to send event");
141  }
142  return r;
143 }

◆ setErrorHandler()

XErrorHandler X11Wrapper::setErrorHandler ( XErrorHandler  handler)
overridevirtual

Implements BaseX11Wrapper.

90  {
91  return XSetErrorHandler(handler);
92 }

◆ setInputFocus() [1/2]

int X11Wrapper::setInputFocus ( Display *  display,
Window  focus,
int  revertTo 
)
overridevirtual

Implements BaseX11Wrapper.

227  {
228  int r = XSetInputFocus(display, focus, revertTo, CurrentTime);
229  if (r != 0) {
230  throw X11Exception("Failed to set input focus");
231  }
232  return r;
233 }

◆ setInputFocus() [2/2]

int X11Wrapper::setInputFocus ( Display *  display,
Window  focus,
int  revertTo,
Time  time 
)
overridevirtual

Implements BaseX11Wrapper.

201  {
202  return XSetInputFocus(display, focus, revertTo, time);
203 }

◆ setWindowBorder()

int X11Wrapper::setWindowBorder ( Display *  display,
Window  window,
unsigned long  border 
)
overridevirtual

Implements BaseX11Wrapper.

247  {
248  return XSetWindowBorder(display, window, border);
249 }

◆ stringToKeysym()

KeySym X11Wrapper::stringToKeysym ( const char *  string)
overridevirtual

Implements BaseX11Wrapper.

390  {
391  KeySym r = XStringToKeysym(string);
392  if (r == NoSymbol) {
393  throw X11Exception("Failed to get keysym from string");
394  }
395  return r;
396 }

◆ sync()

int X11Wrapper::sync ( Display *  display,
bool  discard 
)
overridevirtual

Implements BaseX11Wrapper.

102  {
103  return XSync(display, discard);
104 }

◆ ungrabButton()

int X11Wrapper::ungrabButton ( Display *  display,
unsigned int  button,
unsigned int  modifiers,
Window  grab_window 
)
overridevirtual

Implements BaseX11Wrapper.

332  {
333  int r = XUngrabButton(display, button, modifiers, grab_window);
334  if (r != 0) {
335  throw X11Exception("Failed to ungrab button");
336  }
337  return r;
338 }

◆ ungrabKey()

int X11Wrapper::ungrabKey ( Display *  display,
int  keycode,
unsigned int  modifiers,
Window  grabWindow 
)
overridevirtual

Implements BaseX11Wrapper.

363  {
364  int r = XUngrabKey(display, keycode, modifiers, grabWindow);
365  if (r != 0) {
366  throw X11Exception("Failed to ungrab key");
367  }
368  return r;
369 }

◆ ungrabServer()

int X11Wrapper::ungrabServer ( Display *  display)
overridevirtual

Implements BaseX11Wrapper.

82  {
83  return XUngrabServer(display);
84 }

◆ unmapWindow()

int X11Wrapper::unmapWindow ( Display *  display,
Window  window 
)
overridevirtual

Implements BaseX11Wrapper.

223  {
224  return XUnmapWindow(display, window);
225 }

The documentation for this class was generated from the following files: