YggdrasilWM  0.1.1
A tiny window manager coded in C++
ewmh Namespace Reference

ewmh namespace This namespace contains the EWMH related functions. More...

Functions

void initEwmh (Display *display, Window root)
 register the supported EWMH atoms. More...
 
void handleMessage (XClientMessageEvent *event, Display *display, Window root)
 
void updateNumberOfDesktops (Display *display, Window root)
 
void updateDesktopGeometry (Display *display, Window root)
 
void updateActiveWindow (Display *display, Window root, Window activeWindow)
 
void updateWmProperties (Display *display, Window root)
 

Detailed Description

ewmh namespace This namespace contains the EWMH related functions.

Function Documentation

◆ handleMessage()

void ewmh::handleMessage ( XClientMessageEvent *  event,
Display *  display,
Window  root 
)
60  {
61  Atom wmName = XInternAtom(display, "_NET_WM_NAME", False);
62  Atom wmDesktop = XInternAtom(display, "_NET_WM_DESKTOP", False);
63  Atom activeWindow = XInternAtom(display, "_NET_ACTIVE_WINDOW",False);
64  Atom numbersOfDesktops = XInternAtom(display, "_NET_NUMBER_OF_DESKTOPS",False);
65  Atom wmState = XInternAtom(display, "_NET_WM_STATE", False);
66  Atom desktopGeometry = XInternAtom(display, "_NET_DESKTOP_GEOMETRY",False);
67  if (wmName != None
68  && wmDesktop != None
69  && activeWindow != None
70  && numbersOfDesktops != None
71  && wmState != None
72  && desktopGeometry != None){
73  if (event->message_type == wmName) {
74  Logger::GetInstance()->Log("Received _NET_WM_NAME message", L_INFO);
75  // Handle _NET_WM_NAME
76  } else if (event->message_type == wmDesktop) {
77  Logger::GetInstance()->Log("Received _NET_WM_DESKTOP message", L_INFO);
78  // Handle _NET_WM_DESKTOP
79  } else if (event->message_type == activeWindow) {
80  Logger::GetInstance()->Log("Received _NET_ACTIVE_WINDOW message", L_INFO);
81  // Handle _NET_ACTIVE_WINDOW
82  } else if (event->message_type == numbersOfDesktops) {
83  Logger::GetInstance()->Log("Received _NET_NUMBER_OF_DESKTOPS message", L_INFO);
84  } else if (event->message_type == wmState) {
85  Logger::GetInstance()->Log("Received _NET_WM_STATE message", L_INFO);
86  // Handle _NET_WM_STATE
87  } else {
88  Logger::GetInstance()->Log("Unknown message type: " + std::to_string(event->message_type), L_WARNING);
89  }
90  }
91  }
@ L_WARNING
Definition: Logger.hpp:50
@ L_INFO
Definition: Logger.hpp:49
virtual void Log(const std::string &message, LogLevel level) const
Log a message This method logs a message to the log file or stream. The message is only logged if the...
Definition: Logger.cpp:73
static Logger * GetInstance()
Get the Logger object.
Definition: Logger.cpp:41

References Logger::GetInstance(), L_INFO, L_WARNING, and Logger::Log().

Referenced by EventHandler::handleClientMessage().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initEwmh()

void ewmh::initEwmh ( Display *  display,
Window  root 
)

register the supported EWMH atoms.

Parameters
displaymust be opened before call to this function.
rootroot window the wm is managing (usually the default root window)
Todo:
add x11wrapper to the parameters
34  {
35  Atom netSupported = XInternAtom(display, "_NET_SUPPORTED", False);
36  std::vector<Atom> supportedAtoms = {
37  XInternAtom(display, "_NET_WM_NAME", False),
38  XInternAtom(display, "_NET_WM_DESKTOP", False),
39  XInternAtom(display, "_NET_ACTIVE_WINDOW",False),
40  XInternAtom(display, "_NET_NUMBER_OF_DESKTOPS",False),
41  XInternAtom(display, "_NET_WM_STATE",False),
42  XInternAtom(display, "_NET_DESKTOP_GEOMETRY",False)
43  // Add other supported atoms here
44  };
45  // Register _NET_SUPPORTED property
46  XChangeProperty(
47  display, // Display
48  root, // Root window
49  netSupported, // Property to change
50  XA_ATOM, // Type of property
51  32, // Format of the property (32-bit)
52  PropModeReplace, // Replace existing property
53  reinterpret_cast<unsigned char*>(supportedAtoms.data()), // New value
54  supportedAtoms.size() // Number of elements in the new value
55  );
56  XFlush(display);
57  Logger::GetInstance()->Log("EWMH atoms registered", L_INFO);
58  }

References Logger::GetInstance(), L_INFO, and Logger::Log().

Referenced by WindowManager::init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateActiveWindow()

void ewmh::updateActiveWindow ( Display *  display,
Window  root,
Window  activeWindow 
)
113  {
114  Atom activeWindowAtom = XInternAtom(display, "_NET_ACTIVE_WINDOW",False);
115  XChangeProperty(display,
116  root,
117  activeWindowAtom,
118  XA_WINDOW,
119  32,
120  PropModeReplace,
121  (unsigned char*)&activeWindow,
122  1);
123  }

Referenced by EventHandler::handleFocusIn(), and EventHandler::handleFocusOut().

Here is the caller graph for this function:

◆ updateDesktopGeometry()

void ewmh::updateDesktopGeometry ( Display *  display,
Window  root 
)
99  {
100  Atom desktopGeometry = XInternAtom(display, "_NET_DESKTOP_GEOMETRY", False);
101  uint32_t size[2] = {static_cast<uint32_t>(WindowManager::getInstance()->getGeometryX()),
102  static_cast<uint32_t>(WindowManager::getInstance()->getGeometryY())};
103  Logger::GetInstance()->Log("Size registered :\t" + std::to_string(size[0]) + " x " + std::to_string(size[1]), L_INFO);
104  XChangeProperty(display,
105  root,
106  desktopGeometry,
107  XA_CARDINAL,
108  32,
109  PropModeReplace,
110  (unsigned char*)(size),
111  2);
112  }
unsigned int getGeometryY() const
Get the Geometry Y.
Definition: WindowManager.cpp:282
static WindowManager * getInstance()
Get the WindowManager instance this is a singleton class this function returns the instance of the Wi...
Definition: WindowManager.cpp:244
unsigned int getGeometryX() const
Get the Geometry X this function returns the width of the screen.
Definition: WindowManager.cpp:281

References WindowManager::getGeometryX(), WindowManager::getGeometryY(), Logger::GetInstance(), WindowManager::getInstance(), L_INFO, and Logger::Log().

Referenced by updateWmProperties().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateNumberOfDesktops()

void ewmh::updateNumberOfDesktops ( Display *  display,
Window  root 
)
92  {
93  Atom numbersOfDesktops = XInternAtom(display, "_NET_NUMBER_OF_DESKTOPS",False);
94  if (numbersOfDesktops != None) {
95  unsigned int n = WindowManager::getInstance()->getGroups().size();
96  XChangeProperty(display, root, numbersOfDesktops, XA_CARDINAL, 32, PropModeReplace,reinterpret_cast<unsigned char*>(&n), 1);
97  }
98  }
const std::vector< std::shared_ptr< Group > > & getGroups() const
Get the Groups vector this function returns the groups vector the groups vector contains all the grou...
Definition: WindowManager.cpp:279

References WindowManager::getGroups(), and WindowManager::getInstance().

Referenced by updateWmProperties().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateWmProperties()

void ewmh::updateWmProperties ( Display *  display,
Window  root 
)
124  {
125  updateNumberOfDesktops(display, root);
126  updateDesktopGeometry(display,root);
127  }
void updateDesktopGeometry(Display *display, Window root)
Definition: Ewmh.cpp:99
void updateNumberOfDesktops(Display *display, Window root)
Definition: Ewmh.cpp:92

References updateDesktopGeometry(), and updateNumberOfDesktops().

Referenced by WindowManager::init().

Here is the call graph for this function:
Here is the caller graph for this function: