add support for the openbox_restack_window message.

use the state_add/remove/toggle values from otk::Property::atoms
This commit is contained in:
Dana Jansens 2003-02-17 15:11:03 +00:00
parent c15dced3b9
commit 0dd7ebcba9
2 changed files with 37 additions and 27 deletions

View file

@ -881,15 +881,16 @@ void Client::showhide()
else frame->hide(); else frame->hide();
} }
void Client::setState(StateAction action, long data1, long data2) void Client::setState(Atom action, long data1, long data2)
{ {
bool shadestate = _shaded; bool shadestate = _shaded;
bool fsstate = _fullscreen; bool fsstate = _fullscreen;
bool maxh = _max_horz; bool maxh = _max_horz;
bool maxv = _max_vert; bool maxv = _max_vert;
if (!(action == State_Add || action == State_Remove || if (!(action == otk::Property::atoms.net_wm_state_add ||
action == State_Toggle)) action == otk::Property::atoms.net_wm_state_remove ||
action == otk::Property::atoms.net_wm_state_toggle))
return; // an invalid action was passed to the client message, ignore it return; // an invalid action was passed to the client message, ignore it
for (int i = 0; i < 2; ++i) { for (int i = 0; i < 2; ++i) {
@ -898,28 +899,37 @@ void Client::setState(StateAction action, long data1, long data2)
if (! state) continue; if (! state) continue;
// if toggling, then pick whether we're adding or removing // if toggling, then pick whether we're adding or removing
if (action == State_Toggle) { if (action == otk::Property::atoms.net_wm_state_toggle) {
if (state == otk::Property::atoms.net_wm_state_modal) if (state == otk::Property::atoms.net_wm_state_modal)
action = _modal ? State_Remove : State_Add; action = _modal ? otk::Property::atoms.net_wm_state_remove :
otk::Property::atoms.net_wm_state_add;
else if (state == otk::Property::atoms.net_wm_state_maximized_vert) else if (state == otk::Property::atoms.net_wm_state_maximized_vert)
action = _max_vert ? State_Remove : State_Add; action = _max_vert ? otk::Property::atoms.net_wm_state_remove :
otk::Property::atoms.net_wm_state_add;
else if (state == otk::Property::atoms.net_wm_state_maximized_horz) else if (state == otk::Property::atoms.net_wm_state_maximized_horz)
action = _max_horz ? State_Remove : State_Add; action = _max_horz ? otk::Property::atoms.net_wm_state_remove :
otk::Property::atoms.net_wm_state_add;
else if (state == otk::Property::atoms.net_wm_state_shaded) else if (state == otk::Property::atoms.net_wm_state_shaded)
action = _shaded ? State_Remove : State_Add; action = _shaded ? otk::Property::atoms.net_wm_state_remove :
otk::Property::atoms.net_wm_state_add;
else if (state == otk::Property::atoms.net_wm_state_skip_taskbar) else if (state == otk::Property::atoms.net_wm_state_skip_taskbar)
action = _skip_taskbar ? State_Remove : State_Add; action = _skip_taskbar ? otk::Property::atoms.net_wm_state_remove :
otk::Property::atoms.net_wm_state_add;
else if (state == otk::Property::atoms.net_wm_state_skip_pager) else if (state == otk::Property::atoms.net_wm_state_skip_pager)
action = _skip_pager ? State_Remove : State_Add; action = _skip_pager ? otk::Property::atoms.net_wm_state_remove :
otk::Property::atoms.net_wm_state_add;
else if (state == otk::Property::atoms.net_wm_state_fullscreen) else if (state == otk::Property::atoms.net_wm_state_fullscreen)
action = _fullscreen ? State_Remove : State_Add; action = _fullscreen ? otk::Property::atoms.net_wm_state_remove :
otk::Property::atoms.net_wm_state_add;
else if (state == otk::Property::atoms.net_wm_state_above) else if (state == otk::Property::atoms.net_wm_state_above)
action = _above ? State_Remove : State_Add; action = _above ? otk::Property::atoms.net_wm_state_remove :
otk::Property::atoms.net_wm_state_add;
else if (state == otk::Property::atoms.net_wm_state_below) else if (state == otk::Property::atoms.net_wm_state_below)
action = _below ? State_Remove : State_Add; action = _below ? otk::Property::atoms.net_wm_state_remove :
otk::Property::atoms.net_wm_state_add;
} }
if (action == State_Add) { if (action == otk::Property::atoms.net_wm_state_add) {
if (state == otk::Property::atoms.net_wm_state_modal) { if (state == otk::Property::atoms.net_wm_state_modal) {
if (_modal) continue; if (_modal) continue;
_modal = true; _modal = true;
@ -944,7 +954,7 @@ void Client::setState(StateAction action, long data1, long data2)
_below = true; _below = true;
} }
} else { // action == State_Remove } else { // action == otk::Property::atoms.net_wm_state_remove
if (state == otk::Property::atoms.net_wm_state_modal) { if (state == otk::Property::atoms.net_wm_state_modal) {
if (!_modal) continue; if (!_modal) continue;
_modal = false; _modal = false;
@ -1108,7 +1118,7 @@ void Client::clientMessageHandler(const XClientMessageEvent &e)
e.data.l[0] == 2 ? "Toggle" : "INVALID"), e.data.l[0] == 2 ? "Toggle" : "INVALID"),
e.data.l[1], e.data.l[2], _window); e.data.l[1], e.data.l[2], _window);
#endif #endif
setState((StateAction)e.data.l[0], e.data.l[1], e.data.l[2]); setState(e.data.l[0], e.data.l[1], e.data.l[2]);
} else if (e.message_type == otk::Property::atoms.net_close_window) { } else if (e.message_type == otk::Property::atoms.net_close_window) {
#ifdef DEBUG #ifdef DEBUG
printf("net_close_window for 0x%lx\n", _window); printf("net_close_window for 0x%lx\n", _window);
@ -1140,6 +1150,14 @@ void Client::clientMessageHandler(const XClientMessageEvent &e)
focus(); focus();
if (e.data.l[1]) if (e.data.l[1])
openbox->screen(_screen)->raiseWindow(this); openbox->screen(_screen)->raiseWindow(this);
} else if (e.message_type == otk::Property::atoms.openbox_restack_window) {
#ifdef DEBUG
printf("openbox_restack_window for 0x%lx\n", _window);
#endif
if (e.data.l[0] == 0)
openbox->screen(_screen)->raiseWindow(this);
else if (e.data.l[0] == 1)
openbox->screen(_screen)->lowerWindow(this);
} }
} }

View file

@ -152,12 +152,6 @@ public:
//! Holds a bitmask of Client::Decoration values //! Holds a bitmask of Client::Decoration values
typedef unsigned char DecorationFlags; typedef unsigned char DecorationFlags;
//! Possible actions that can be made with the _NET_WM_STATE client message
enum StateAction { State_Remove = 0, //!< _NET_WM_STATE_REMOVE
State_Add, //!< _NET_WM_STATE_ADD
State_Toggle //!< _NET_WM_STATE_TOGGLE
};
//! The event mask to grab on client windows //! The event mask to grab on client windows
static const long event_mask = PropertyChangeMask | FocusChangeMask | static const long event_mask = PropertyChangeMask | FocusChangeMask |
StructureNotifyMask; StructureNotifyMask;
@ -385,7 +379,7 @@ private:
Client::applyStartupState is used to do the same things during the mapping Client::applyStartupState is used to do the same things during the mapping
process. process.
*/ */
void setState(StateAction action, long data1, long data2); void setState(Atom action, long data1, long data2);
//! Sends the window to the specified desktop //! Sends the window to the specified desktop
void setDesktop(unsigned int desktop); void setDesktop(unsigned int desktop);
@ -520,16 +514,14 @@ private:
void applyStartupState(); void applyStartupState();
public: public:
#ifndef SWIG
//! Constructs a new Client object around a specified window id //! Constructs a new Client object around a specified window id
/*! /*!
BB @param window The window id that the Client class should handle @param window The window id that the Client class should handle
@param screen The screen on which the window resides @param screen The screen on which the window resides
*/ */
Client(int screen, Window window); Client(int screen, Window window);
//! Destroys the Client object //! Destroys the Client object
virtual ~Client(); virtual ~Client();
#endif
//! Returns the screen on which the clien resides //! Returns the screen on which the clien resides
inline int screen() const { return _screen; } inline int screen() const { return _screen; }
@ -616,7 +608,7 @@ BB @param window The window id that the Client class should handle
inline bool skipPager() const { return _skip_pager; } inline bool skipPager() const { return _skip_pager; }
//! The window should not be displayed by taskbars //! The window should not be displayed by taskbars
inline bool skipTaskbar() const { return _skip_taskbar; } inline bool skipTaskbar() const { return _skip_taskbar; }
//! Returns if the window is shaded //! Returns if the window is shaded
/*! /*!
When the window is shaded, only its titlebar is visible. When the window is shaded, only its titlebar is visible.
*/ */