add an OBRootWindow class that watches events/properties on root windows
This commit is contained in:
parent
74cb09bb2c
commit
dca0c9f5a3
6 changed files with 162 additions and 5 deletions
|
@ -16,7 +16,7 @@ bin_PROGRAMS= openbox3
|
||||||
openbox3_LDADD=../otk/libotk.a @LIBINTL@
|
openbox3_LDADD=../otk/libotk.a @LIBINTL@
|
||||||
|
|
||||||
openbox3_SOURCES= client.cc frame.cc openbox.cc screen.cc \
|
openbox3_SOURCES= client.cc frame.cc openbox.cc screen.cc \
|
||||||
main.cc
|
main.cc rootwindow.cc
|
||||||
|
|
||||||
MAINTAINERCLEANFILES= Makefile.in
|
MAINTAINERCLEANFILES= Makefile.in
|
||||||
|
|
||||||
|
|
|
@ -434,11 +434,11 @@ public:
|
||||||
//! Returns the position and size of the client relative to the root window
|
//! Returns the position and size of the client relative to the root window
|
||||||
inline const otk::Rect &area() const { return _area; }
|
inline const otk::Rect &area() const { return _area; }
|
||||||
|
|
||||||
virtual void propertyHandler(const XPropertyEvent &);
|
virtual void propertyHandler(const XPropertyEvent &e);
|
||||||
|
|
||||||
virtual void clientMessageHandler(const XClientMessageEvent &);
|
virtual void clientMessageHandler(const XClientMessageEvent &e);
|
||||||
|
|
||||||
virtual void shapeHandler(const XShapeEvent &);
|
virtual void shapeHandler(const XShapeEvent &e);
|
||||||
|
|
||||||
//! Changes the stored positions and size of the OBClient window
|
//! Changes the stored positions and size of the OBClient window
|
||||||
/*!
|
/*!
|
||||||
|
|
83
src/rootwindow.cc
Normal file
83
src/rootwindow.cc
Normal file
|
@ -0,0 +1,83 @@
|
||||||
|
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "../config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "rootwindow.hh"
|
||||||
|
#include "openbox.hh"
|
||||||
|
#include "otk/display.hh"
|
||||||
|
|
||||||
|
namespace ob {
|
||||||
|
|
||||||
|
OBRootWindow::OBRootWindow(int screen)
|
||||||
|
: _info(otk::OBDisplay::screenInfo(screen))
|
||||||
|
{
|
||||||
|
updateDesktopNames();
|
||||||
|
|
||||||
|
Openbox::instance->registerHandler(_info->getRootWindow(), this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
OBRootWindow::~OBRootWindow()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void OBRootWindow::updateDesktopNames()
|
||||||
|
{
|
||||||
|
const int numWorkspaces = 1; // XXX: change this to the number of workspaces!
|
||||||
|
|
||||||
|
const otk::OBProperty *property = Openbox::instance->property();
|
||||||
|
|
||||||
|
unsigned long num = (unsigned) -1;
|
||||||
|
|
||||||
|
if (!property->get(_info->getRootWindow(),
|
||||||
|
otk::OBProperty::net_desktop_names,
|
||||||
|
otk::OBProperty::utf8, &num, &_names))
|
||||||
|
_names.clear();
|
||||||
|
for (int i = 0; i < numWorkspaces; ++i)
|
||||||
|
if (i <= static_cast<int>(_names.size()))
|
||||||
|
_names.push_back("Unnamed workspace");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void OBRootWindow::propertyHandler(const XPropertyEvent &e)
|
||||||
|
{
|
||||||
|
otk::OtkEventHandler::propertyHandler(e);
|
||||||
|
|
||||||
|
const otk::OBProperty *property = Openbox::instance->property();
|
||||||
|
|
||||||
|
if (e.atom == property->atom(otk::OBProperty::net_desktop_names))
|
||||||
|
updateDesktopNames();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void OBRootWindow::clientMessageHandler(const XClientMessageEvent &e)
|
||||||
|
{
|
||||||
|
otk::OtkEventHandler::clientMessageHandler(e);
|
||||||
|
|
||||||
|
if (e.format != 32) return;
|
||||||
|
|
||||||
|
//const otk::OBProperty *property = Openbox::instance->property();
|
||||||
|
|
||||||
|
// XXX: so many client messages to handle here!
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void OBRootWindow::setDesktopName(int i, const std::string &name)
|
||||||
|
{
|
||||||
|
const int numWorkspaces = 1; // XXX: change this to the number of workspaces!
|
||||||
|
assert(i >= 0);
|
||||||
|
assert(i < numWorkspaces);
|
||||||
|
|
||||||
|
const otk::OBProperty *property = Openbox::instance->property();
|
||||||
|
|
||||||
|
otk::OBProperty::StringVect newnames = _names;
|
||||||
|
newnames[i] = name;
|
||||||
|
property->set(_info->getRootWindow(), otk::OBProperty::net_desktop_names,
|
||||||
|
otk::OBProperty::utf8, newnames);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
69
src/rootwindow.hh
Normal file
69
src/rootwindow.hh
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
|
||||||
|
#ifndef __rootwindow_hh
|
||||||
|
#define __rootwindow_hh
|
||||||
|
|
||||||
|
/*! @file client.hh
|
||||||
|
@brief The OBClient class maintains the state of a client window by handling
|
||||||
|
property changes on the window and some client messages
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
|
||||||
|
#ifdef SHAPE
|
||||||
|
#include <X11/extensions/shape.h>
|
||||||
|
#endif // SHAPE
|
||||||
|
}
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "otk/screeninfo.hh"
|
||||||
|
#include "otk/eventhandler.hh"
|
||||||
|
#include "otk/property.hh"
|
||||||
|
|
||||||
|
namespace ob {
|
||||||
|
|
||||||
|
//! Maintains the state of a root window's properties.
|
||||||
|
/*!
|
||||||
|
OBRootWindow maintains the state of a root window. The state consists of the
|
||||||
|
hints that the wm sets on the window, such as the number of desktops,
|
||||||
|
gravity.
|
||||||
|
<p>
|
||||||
|
OBRootWindow also manages client messages for the root window.
|
||||||
|
*/
|
||||||
|
class OBRootWindow : public otk::OtkEventHandler {
|
||||||
|
private:
|
||||||
|
//! Information about this screen
|
||||||
|
const otk::ScreenInfo *_info;
|
||||||
|
|
||||||
|
//! The names of all desktops
|
||||||
|
otk::OBProperty::StringVect _names;
|
||||||
|
|
||||||
|
//! Get desktop names from the
|
||||||
|
void updateDesktopNames();
|
||||||
|
|
||||||
|
public:
|
||||||
|
//! Constructs a new OBRootWindow for a screen
|
||||||
|
/*!
|
||||||
|
@param screen The screen whose root window to wrap
|
||||||
|
*/
|
||||||
|
OBRootWindow(int screen);
|
||||||
|
//! Destroys the OBRootWindow object
|
||||||
|
virtual ~OBRootWindow();
|
||||||
|
|
||||||
|
virtual void propertyHandler(const XPropertyEvent &e);
|
||||||
|
|
||||||
|
virtual void clientMessageHandler(const XClientMessageEvent &e);
|
||||||
|
|
||||||
|
//! Sets the name of a desktop
|
||||||
|
/*!
|
||||||
|
@param i The index of the desktop to set the name for (base 0)
|
||||||
|
@param name The name to set for the desktop
|
||||||
|
*/
|
||||||
|
void setDesktopName(int i, const std::string &name);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // __client_hh
|
|
@ -37,7 +37,8 @@ namespace ob {
|
||||||
|
|
||||||
|
|
||||||
OBScreen::OBScreen(int screen, const otk::Configuration &config)
|
OBScreen::OBScreen(int screen, const otk::Configuration &config)
|
||||||
: _number(screen)
|
: _number(screen),
|
||||||
|
_root(screen)
|
||||||
{
|
{
|
||||||
assert(screen >= 0); assert(screen < ScreenCount(otk::OBDisplay::display));
|
assert(screen >= 0); assert(screen < ScreenCount(otk::OBDisplay::display));
|
||||||
_info = otk::OBDisplay::screenInfo(screen);
|
_info = otk::OBDisplay::screenInfo(screen);
|
||||||
|
|
|
@ -10,6 +10,7 @@ extern "C" {
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include "rootwindow.hh"
|
||||||
#include "otk/image.hh"
|
#include "otk/image.hh"
|
||||||
#include "otk/strut.hh"
|
#include "otk/strut.hh"
|
||||||
#include "otk/rect.hh"
|
#include "otk/rect.hh"
|
||||||
|
@ -21,6 +22,7 @@ extern "C" {
|
||||||
namespace ob {
|
namespace ob {
|
||||||
|
|
||||||
class OBClient;
|
class OBClient;
|
||||||
|
class OBRootWindow;
|
||||||
|
|
||||||
//! Manages a single screen
|
//! Manages a single screen
|
||||||
/*!
|
/*!
|
||||||
|
@ -57,6 +59,8 @@ private:
|
||||||
//! The style with which to render on the screen
|
//! The style with which to render on the screen
|
||||||
otk::Style _style;
|
otk::Style _style;
|
||||||
|
|
||||||
|
OBRootWindow _root;
|
||||||
|
|
||||||
//! Is the root colormap currently installed?
|
//! Is the root colormap currently installed?
|
||||||
bool _root_cmap_installed;
|
bool _root_cmap_installed;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue