display icons in the frame titlebar!
This commit is contained in:
parent
1e58c863bb
commit
07305ec718
4 changed files with 216 additions and 38 deletions
|
@ -19,6 +19,7 @@ extern "C" {
|
||||||
#define _(str) gettext(str)
|
#define _(str) gettext(str)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include <cstring> // for memcpy
|
||||||
#include <climits>
|
#include <climits>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
@ -46,6 +47,7 @@ Client::Client(int screen, Window window)
|
||||||
_disabled_decorations = 0;
|
_disabled_decorations = 0;
|
||||||
_group = None;
|
_group = None;
|
||||||
_desktop = 0;
|
_desktop = 0;
|
||||||
|
_nicons = 0;
|
||||||
|
|
||||||
getArea();
|
getArea();
|
||||||
getDesktop();
|
getDesktop();
|
||||||
|
@ -74,6 +76,7 @@ Client::Client(int screen, Window window)
|
||||||
updateIconTitle();
|
updateIconTitle();
|
||||||
updateClass();
|
updateClass();
|
||||||
updateStrut();
|
updateStrut();
|
||||||
|
updateIcons();
|
||||||
|
|
||||||
// this makes sure that these windows appear on all desktops
|
// this makes sure that these windows appear on all desktops
|
||||||
if (/*_type == Type_Dock ||*/ _type == Type_Desktop)
|
if (/*_type == Type_Dock ||*/ _type == Type_Desktop)
|
||||||
|
@ -89,6 +92,11 @@ Client::Client(int screen, Window window)
|
||||||
|
|
||||||
Client::~Client()
|
Client::~Client()
|
||||||
{
|
{
|
||||||
|
assert(_nicons > 0); // there should always be a default..
|
||||||
|
for (int j = 0; j < _nicons; ++j)
|
||||||
|
delete [] _icons[j].data;
|
||||||
|
delete [] _icons;
|
||||||
|
|
||||||
// clean up childrens' references
|
// clean up childrens' references
|
||||||
while (!_transients.empty()) {
|
while (!_transients.empty()) {
|
||||||
_transients.front()->_transient_for = 0;
|
_transients.front()->_transient_for = 0;
|
||||||
|
@ -207,7 +215,7 @@ void Client::getType()
|
||||||
void Client::setupDecorAndFunctions()
|
void Client::setupDecorAndFunctions()
|
||||||
{
|
{
|
||||||
// start with everything (cept fullscreen)
|
// start with everything (cept fullscreen)
|
||||||
_decorations = Decor_Titlebar | Decor_Handle | Decor_Border |
|
_decorations = Decor_Titlebar | Decor_Handle | Decor_Border | Decor_Icon |
|
||||||
Decor_AllDesktops | Decor_Iconify | Decor_Maximize;
|
Decor_AllDesktops | Decor_Iconify | Decor_Maximize;
|
||||||
_functions = Func_Resize | Func_Move | Func_Iconify | Func_Maximize |
|
_functions = Func_Resize | Func_Move | Func_Iconify | Func_Maximize |
|
||||||
Func_Shade;
|
Func_Shade;
|
||||||
|
@ -677,6 +685,62 @@ void Client::updateTransientFor()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Client::updateIcons()
|
||||||
|
{
|
||||||
|
unsigned long num = (unsigned) -1;
|
||||||
|
unsigned long *data;
|
||||||
|
unsigned long w, h, i = 0;
|
||||||
|
|
||||||
|
for (int j = 0; j < _nicons; ++j)
|
||||||
|
delete [] _icons[j].data;
|
||||||
|
if (_nicons > 0)
|
||||||
|
delete [] _icons;
|
||||||
|
_nicons = 0;
|
||||||
|
|
||||||
|
if (otk::Property::get(_window, otk::Property::atoms.net_wm_icon,
|
||||||
|
otk::Property::atoms.cardinal, &num, &data)) {
|
||||||
|
// figure out how man valid icons are in here
|
||||||
|
while (num - i > 2) {
|
||||||
|
w = data[i++];
|
||||||
|
h = data[i++];
|
||||||
|
i += w * h;
|
||||||
|
if (i > num) break;
|
||||||
|
++_nicons;
|
||||||
|
}
|
||||||
|
|
||||||
|
_icons = new Icon[_nicons];
|
||||||
|
|
||||||
|
// store the icons
|
||||||
|
i = 0;
|
||||||
|
for (int j = 0; j < _nicons; ++j) {
|
||||||
|
w = _icons[j].w = data[i++];
|
||||||
|
h = _icons[j].h = data[i++];
|
||||||
|
_icons[j].data = new unsigned long[w * h];
|
||||||
|
::memcpy(_icons[j].data, &data[i], w * h * sizeof(unsigned long));
|
||||||
|
i += w * h;
|
||||||
|
assert(i <= num);
|
||||||
|
}
|
||||||
|
printf("i: %lu\n", i);
|
||||||
|
printf("bleffffffff\n");
|
||||||
|
|
||||||
|
delete [] data;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_nicons <= 0) {
|
||||||
|
// set the default icon(s) XXX load these from the py
|
||||||
|
_nicons = 1;
|
||||||
|
_icons = new Icon[1];
|
||||||
|
_icons[i].w = 0;
|
||||||
|
_icons[i].h = 0;
|
||||||
|
_icons[i].data = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(_nicons > 0); // there should always be a default..
|
||||||
|
|
||||||
|
if (frame) frame->adjustIcon();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Client::propertyHandler(const XPropertyEvent &e)
|
void Client::propertyHandler(const XPropertyEvent &e)
|
||||||
{
|
{
|
||||||
otk::EventHandler::propertyHandler(e);
|
otk::EventHandler::propertyHandler(e);
|
||||||
|
@ -720,6 +784,8 @@ void Client::propertyHandler(const XPropertyEvent &e)
|
||||||
}
|
}
|
||||||
else if (e.atom == otk::Property::atoms.net_wm_strut)
|
else if (e.atom == otk::Property::atoms.net_wm_strut)
|
||||||
updateStrut();
|
updateStrut();
|
||||||
|
else if (e.atom == otk::Property::atoms.net_wm_icon)
|
||||||
|
updateIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1140,6 +1206,29 @@ void Client::internal_resize(Corner anchor, int w, int h,
|
||||||
internal_move(x, y);
|
internal_move(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Icon *Client::icon(const otk::Size &s) const
|
||||||
|
{
|
||||||
|
unsigned long req = s.width() * s.height();
|
||||||
|
// si is the smallest image >= req
|
||||||
|
// li is the largest image < req
|
||||||
|
unsigned long smallest = 0xffffffff, largest = 0, si = 0, li = 0;
|
||||||
|
|
||||||
|
assert(_nicons > 0); // there should always be a default..
|
||||||
|
for (int i = 0; i < _nicons; ++i) {
|
||||||
|
unsigned long size = _icons[i].w * _icons[i].h;
|
||||||
|
if (size < smallest && size >= req) {
|
||||||
|
smallest = size;
|
||||||
|
si = i;
|
||||||
|
}
|
||||||
|
if (size > largest && size <= req) {
|
||||||
|
largest = size;
|
||||||
|
li = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (smallest == 0xffffffff) // didnt find one bigger than us...
|
||||||
|
return &_icons[li];
|
||||||
|
return &_icons[si];
|
||||||
|
}
|
||||||
|
|
||||||
void Client::move(int x, int y)
|
void Client::move(int x, int y)
|
||||||
{
|
{
|
||||||
|
|
|
@ -141,12 +141,13 @@ public:
|
||||||
enum Decoration { Decor_Titlebar = 1 << 0, //!< Display a titlebar
|
enum Decoration { Decor_Titlebar = 1 << 0, //!< Display a titlebar
|
||||||
Decor_Handle = 1 << 1, //!< Display a handle (bottom)
|
Decor_Handle = 1 << 1, //!< Display a handle (bottom)
|
||||||
Decor_Border = 1 << 2, //!< Display a border
|
Decor_Border = 1 << 2, //!< Display a border
|
||||||
Decor_Iconify = 1 << 3, //!< Display an iconify button
|
Decor_Icon = 1 << 3, //!< Display the window's icon
|
||||||
Decor_Maximize = 1 << 4, //!< Display a maximize button
|
Decor_Iconify = 1 << 4, //!< Display an iconify button
|
||||||
|
Decor_Maximize = 1 << 5, //!< Display a maximize button
|
||||||
//! Display a button to toggle the window's placement on
|
//! Display a button to toggle the window's placement on
|
||||||
//! all desktops
|
//! all desktops
|
||||||
Decor_AllDesktops = 1 << 5,
|
Decor_AllDesktops = 1 << 6,
|
||||||
Decor_Close = 1 << 6 //!< Display a close button
|
Decor_Close = 1 << 7 //!< Display a close button
|
||||||
};
|
};
|
||||||
//! Holds a bitmask of Client::Decoration values
|
//! Holds a bitmask of Client::Decoration values
|
||||||
typedef unsigned char DecorationFlags;
|
typedef unsigned char DecorationFlags;
|
||||||
|
@ -342,6 +343,11 @@ private:
|
||||||
*/
|
*/
|
||||||
FunctionFlags _functions;
|
FunctionFlags _functions;
|
||||||
|
|
||||||
|
//! Icons for the client as specified on the client window
|
||||||
|
Icon *_icons;
|
||||||
|
//! The number of icons in _icons
|
||||||
|
int _nicons;
|
||||||
|
|
||||||
//! Retrieves the window's initial gravity
|
//! Retrieves the window's initial gravity
|
||||||
void getGravity();
|
void getGravity();
|
||||||
//! Retrieves the desktop hint's value and sets Client::_desktop
|
//! Retrieves the desktop hint's value and sets Client::_desktop
|
||||||
|
@ -406,6 +412,8 @@ private:
|
||||||
void updateStrut();
|
void updateStrut();
|
||||||
//! Updates the window's transient status, and any parents of it
|
//! Updates the window's transient status, and any parents of it
|
||||||
void updateTransientFor();
|
void updateTransientFor();
|
||||||
|
//! Updates the window's icons
|
||||||
|
void updateIcons();
|
||||||
|
|
||||||
//! Change the client's state hints to match the class' data
|
//! Change the client's state hints to match the class' data
|
||||||
void changeState();
|
void changeState();
|
||||||
|
@ -639,6 +647,15 @@ BB @param window The window id that the Client class should handle
|
||||||
//! Returns the client's strut definition
|
//! Returns the client's strut definition
|
||||||
inline const otk::Strut &strut() const { return _strut; }
|
inline const otk::Strut &strut() const { return _strut; }
|
||||||
|
|
||||||
|
//! Returns an icon for the window
|
||||||
|
/*!
|
||||||
|
The icon chosen will be the smallest icon available that is still bigger or
|
||||||
|
equal to the specified Size.<br>
|
||||||
|
If none that meet the requirements is found, the largest icon that is
|
||||||
|
smaller than the specified size will be returned.
|
||||||
|
*/
|
||||||
|
const Icon *icon(const otk::Size &s) const;
|
||||||
|
|
||||||
//! Move the window (actually, its frame) to a position.
|
//! Move the window (actually, its frame) to a position.
|
||||||
/*!
|
/*!
|
||||||
This moves the window so that the top-left corner of its frame will be at
|
This moves the window so that the top-left corner of its frame will be at
|
||||||
|
|
129
src/frame.cc
129
src/frame.cc
|
@ -9,7 +9,6 @@ extern "C" {
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "frame.hh"
|
#include "frame.hh"
|
||||||
#include "client.hh"
|
|
||||||
#include "openbox.hh"
|
#include "openbox.hh"
|
||||||
#include "otk/display.hh"
|
#include "otk/display.hh"
|
||||||
#include "otk/surface.hh"
|
#include "otk/surface.hh"
|
||||||
|
@ -312,10 +311,10 @@ static void render(int screen, const otk::Size &size, Window win,
|
||||||
|
|
||||||
void Frame::adjustSize()
|
void Frame::adjustSize()
|
||||||
{
|
{
|
||||||
Client::DecorationFlags decorations = _client->decorations();
|
_decorations = _client->decorations();
|
||||||
const otk::RenderStyle *style = otk::RenderStyle::style(_client->screen());
|
const otk::RenderStyle *style = otk::RenderStyle::style(_client->screen());
|
||||||
|
|
||||||
if (decorations & Client::Decor_Border) {
|
if (_decorations & Client::Decor_Border) {
|
||||||
geom.bwidth = style->frameBorderWidth();
|
geom.bwidth = style->frameBorderWidth();
|
||||||
geom.cbwidth = style->clientBorderWidth();
|
geom.cbwidth = style->clientBorderWidth();
|
||||||
} else {
|
} else {
|
||||||
|
@ -336,7 +335,7 @@ void Frame::adjustSize()
|
||||||
|
|
||||||
// position/size and map/unmap all the windows
|
// position/size and map/unmap all the windows
|
||||||
|
|
||||||
if (decorations & Client::Decor_Titlebar) {
|
if (_decorations & Client::Decor_Titlebar) {
|
||||||
XMoveResizeWindow(**otk::display, _title, -geom.bwidth, -geom.bwidth,
|
XMoveResizeWindow(**otk::display, _title, -geom.bwidth, -geom.bwidth,
|
||||||
geom.width, geom.title_height());
|
geom.width, geom.title_height());
|
||||||
_innersize.top += geom.title_height() + geom.bwidth;
|
_innersize.top += geom.title_height() + geom.bwidth;
|
||||||
|
@ -344,10 +343,15 @@ void Frame::adjustSize()
|
||||||
|
|
||||||
// layout the title bar elements
|
// layout the title bar elements
|
||||||
layoutTitle();
|
layoutTitle();
|
||||||
} else
|
} else {
|
||||||
XUnmapWindow(**otk::display, _title);
|
XUnmapWindow(**otk::display, _title);
|
||||||
|
// make all the titlebar stuff not render
|
||||||
|
_decorations &= ~(Client::Decor_Icon | Client::Decor_Iconify |
|
||||||
|
Client::Decor_Maximize | Client::Decor_Close |
|
||||||
|
Client::Decor_AllDesktops);
|
||||||
|
}
|
||||||
|
|
||||||
if (decorations & Client::Decor_Handle) {
|
if (_decorations & Client::Decor_Handle) {
|
||||||
geom.handle_y = _innersize.top + _client->area().height() + geom.cbwidth;
|
geom.handle_y = _innersize.top + _client->area().height() + geom.cbwidth;
|
||||||
XMoveResizeWindow(**otk::display, _handle, -geom.bwidth, geom.handle_y,
|
XMoveResizeWindow(**otk::display, _handle, -geom.bwidth, geom.handle_y,
|
||||||
geom.width, geom.handle_height);
|
geom.width, geom.handle_height);
|
||||||
|
@ -385,7 +389,7 @@ void Frame::adjustSize()
|
||||||
// render all the elements
|
// render all the elements
|
||||||
int screen = _client->screen();
|
int screen = _client->screen();
|
||||||
bool focus = _client->focused();
|
bool focus = _client->focused();
|
||||||
if (decorations & Client::Decor_Titlebar) {
|
if (_decorations & Client::Decor_Titlebar) {
|
||||||
render(screen, otk::Size(geom.width, geom.title_height()), _title,
|
render(screen, otk::Size(geom.width, geom.title_height()), _title,
|
||||||
&_title_sur, *(focus ? style->titlebarFocusBackground() :
|
&_title_sur, *(focus ? style->titlebarFocusBackground() :
|
||||||
style->titlebarUnfocusBackground()), false);
|
style->titlebarUnfocusBackground()), false);
|
||||||
|
@ -398,7 +402,7 @@ void Frame::adjustSize()
|
||||||
renderClose();
|
renderClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (decorations & Client::Decor_Handle) {
|
if (_decorations & Client::Decor_Handle) {
|
||||||
render(screen, otk::Size(geom.width, geom.handle_height), _handle,
|
render(screen, otk::Size(geom.width, geom.handle_height), _handle,
|
||||||
&_handle_sur, *(focus ? style->handleFocusBackground() :
|
&_handle_sur, *(focus ? style->handleFocusBackground() :
|
||||||
style->handleUnfocusBackground()));
|
style->handleUnfocusBackground()));
|
||||||
|
@ -495,11 +499,13 @@ static void renderButton(int screen, bool focus, bool press, Window win,
|
||||||
XSetWindowBackgroundPixmap(**otk::display, win, s->pixmap());
|
XSetWindowBackgroundPixmap(**otk::display, win, s->pixmap());
|
||||||
XClearWindow(**otk::display, win);
|
XClearWindow(**otk::display, win);
|
||||||
if (*sur) delete *sur;
|
if (*sur) delete *sur;
|
||||||
|
s->freePixelData();
|
||||||
*sur = s;
|
*sur = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Frame::renderMax()
|
void Frame::renderMax()
|
||||||
{
|
{
|
||||||
|
if (!(_decorations & Client::Decor_Maximize)) return;
|
||||||
bool press = _max_press || _client->maxVert() || _client->maxHorz();
|
bool press = _max_press || _client->maxVert() || _client->maxHorz();
|
||||||
renderButton(_client->screen(), _client->focused(), press, _max,
|
renderButton(_client->screen(), _client->focused(), press, _max,
|
||||||
&_max_sur, geom.button_size,
|
&_max_sur, geom.button_size,
|
||||||
|
@ -508,6 +514,7 @@ void Frame::renderMax()
|
||||||
|
|
||||||
void Frame::renderDesk()
|
void Frame::renderDesk()
|
||||||
{
|
{
|
||||||
|
if (!(_decorations & Client::Decor_AllDesktops)) return;
|
||||||
bool press = _desk_press || _client->desktop() == 0xffffffff;
|
bool press = _desk_press || _client->desktop() == 0xffffffff;
|
||||||
renderButton(_client->screen(), _client->focused(), press, _desk,
|
renderButton(_client->screen(), _client->focused(), press, _desk,
|
||||||
&_desk_sur, geom.button_size,
|
&_desk_sur, geom.button_size,
|
||||||
|
@ -516,6 +523,7 @@ void Frame::renderDesk()
|
||||||
|
|
||||||
void Frame::renderIconify()
|
void Frame::renderIconify()
|
||||||
{
|
{
|
||||||
|
if (!(_decorations & Client::Decor_Iconify)) return;
|
||||||
renderButton(_client->screen(), _client->focused(), _iconify_press, _iconify,
|
renderButton(_client->screen(), _client->focused(), _iconify_press, _iconify,
|
||||||
&_iconify_sur, geom.button_size,
|
&_iconify_sur, geom.button_size,
|
||||||
otk::RenderStyle::style(_client->screen())->iconifyMask());
|
otk::RenderStyle::style(_client->screen())->iconifyMask());
|
||||||
|
@ -523,6 +531,7 @@ void Frame::renderIconify()
|
||||||
|
|
||||||
void Frame::renderClose()
|
void Frame::renderClose()
|
||||||
{
|
{
|
||||||
|
if (!(_decorations & Client::Decor_Close)) return;
|
||||||
renderButton(_client->screen(), _client->focused(), _close_press, _close,
|
renderButton(_client->screen(), _client->focused(), _close_press, _close,
|
||||||
&_close_sur, geom.button_size,
|
&_close_sur, geom.button_size,
|
||||||
otk::RenderStyle::style(_client->screen())->closeMask());
|
otk::RenderStyle::style(_client->screen())->closeMask());
|
||||||
|
@ -530,6 +539,7 @@ void Frame::renderClose()
|
||||||
|
|
||||||
void Frame::renderIcon()
|
void Frame::renderIcon()
|
||||||
{
|
{
|
||||||
|
if (!(_decorations & Client::Decor_Icon)) return;
|
||||||
const int screen = _client->screen();
|
const int screen = _client->screen();
|
||||||
const otk::RenderControl *control = otk::display->renderControl(screen);
|
const otk::RenderControl *control = otk::display->renderControl(screen);
|
||||||
|
|
||||||
|
@ -544,7 +554,10 @@ void Frame::renderIcon()
|
||||||
for (int y = 0; y < geom.button_size; ++y, src += w - geom.button_size)
|
for (int y = 0; y < geom.button_size; ++y, src += w - geom.button_size)
|
||||||
for (int x = 0; x < geom.button_size; ++x, ++dest, ++src)
|
for (int x = 0; x < geom.button_size; ++x, ++dest, ++src)
|
||||||
*dest = *src;
|
*dest = *src;
|
||||||
control->drawImage(*s, 0, 0, 0);
|
// draw the icon over it
|
||||||
|
const Icon *icon = _client->icon(otk::Size(geom.button_size,
|
||||||
|
geom.button_size));
|
||||||
|
control->drawImage(*s, icon->w, icon->h, icon->data);
|
||||||
|
|
||||||
XSetWindowBackgroundPixmap(**otk::display, _icon, s->pixmap());
|
XSetWindowBackgroundPixmap(**otk::display, _icon, s->pixmap());
|
||||||
XClearWindow(**otk::display, _icon);
|
XClearWindow(**otk::display, _icon);
|
||||||
|
@ -554,69 +567,124 @@ void Frame::renderIcon()
|
||||||
|
|
||||||
void Frame::layoutTitle()
|
void Frame::layoutTitle()
|
||||||
{
|
{
|
||||||
geom.label_width = geom.width - geom.bevel * 2 -
|
// figure out whats being shown, and the width of the label
|
||||||
(geom.button_size + geom.bevel) * (_layout.size() - 1);
|
geom.label_width = geom.width - geom.bevel * 2;
|
||||||
|
bool n, d, i, t, m ,c;
|
||||||
|
n = d = i = t = m = c = false;
|
||||||
|
for (const char *l = _layout.c_str(); *l; ++l) {
|
||||||
|
switch (*l) {
|
||||||
|
case 'n':
|
||||||
|
case 'N':
|
||||||
|
if (!(_decorations & Client::Decor_Icon)) break;
|
||||||
|
n = true;
|
||||||
|
geom.label_width -= geom.button_size + geom.bevel;
|
||||||
|
break;
|
||||||
|
case 'd':
|
||||||
|
case 'D':
|
||||||
|
if (!(_decorations & Client::Decor_AllDesktops)) break;
|
||||||
|
d = true;
|
||||||
|
geom.label_width -= geom.button_size + geom.bevel;
|
||||||
|
break;
|
||||||
|
case 'i':
|
||||||
|
case 'I':
|
||||||
|
if (!(_decorations & Client::Decor_Iconify)) break;
|
||||||
|
i = true;
|
||||||
|
geom.label_width -= geom.button_size + geom.bevel;
|
||||||
|
break;
|
||||||
|
case 't':
|
||||||
|
case 'T':
|
||||||
|
t = true;
|
||||||
|
break;
|
||||||
|
case 'm':
|
||||||
|
case 'M':
|
||||||
|
if (!(_decorations & Client::Decor_Maximize)) break;
|
||||||
|
m = true;
|
||||||
|
geom.label_width -= geom.button_size + geom.bevel;
|
||||||
|
break;
|
||||||
|
case 'c':
|
||||||
|
case 'C':
|
||||||
|
if (!(_decorations & Client::Decor_Close)) break;
|
||||||
|
c = true;
|
||||||
|
geom.label_width -= geom.button_size + geom.bevel;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (geom.label_width < 1) geom.label_width = 1;
|
if (geom.label_width < 1) geom.label_width = 1;
|
||||||
|
|
||||||
XResizeWindow(**otk::display, _label, geom.label_width, geom.font_height);
|
XResizeWindow(**otk::display, _label, geom.label_width, geom.font_height);
|
||||||
|
|
||||||
|
if (!n) {
|
||||||
|
_decorations &= ~Client::Decor_Icon;
|
||||||
|
XUnmapWindow(**otk::display, _icon);
|
||||||
|
}
|
||||||
|
if (!d) {
|
||||||
|
_decorations &= ~Client::Decor_AllDesktops;
|
||||||
|
XUnmapWindow(**otk::display, _desk);
|
||||||
|
}
|
||||||
|
if (!i) {
|
||||||
|
_decorations &= ~Client::Decor_Iconify;
|
||||||
|
XUnmapWindow(**otk::display, _iconify);
|
||||||
|
}
|
||||||
|
if (!t)
|
||||||
|
XUnmapWindow(**otk::display, _label);
|
||||||
|
if (!m) {
|
||||||
|
_decorations &= ~Client::Decor_Maximize;
|
||||||
|
XUnmapWindow(**otk::display, _max);
|
||||||
|
}
|
||||||
|
if (!c) {
|
||||||
|
_decorations &= ~Client::Decor_Close;
|
||||||
|
XUnmapWindow(**otk::display, _close);
|
||||||
|
}
|
||||||
|
|
||||||
int x = geom.bevel;
|
int x = geom.bevel;
|
||||||
bool n, d, i, l, m ,c;
|
|
||||||
n = d = i = l = m = c = false;
|
|
||||||
for (const char *lc = _layout.c_str(); *lc; ++lc) {
|
for (const char *lc = _layout.c_str(); *lc; ++lc) {
|
||||||
switch (*lc) {
|
switch (*lc) {
|
||||||
case 'n':
|
case 'n':
|
||||||
case 'N':
|
case 'N':
|
||||||
|
if (!n) break;
|
||||||
geom.icon_x = x;
|
geom.icon_x = x;
|
||||||
XMapWindow(**otk::display, _icon);
|
XMapWindow(**otk::display, _icon);
|
||||||
XMoveWindow(**otk::display, _icon, x, geom.bevel + 1);
|
XMoveWindow(**otk::display, _icon, x, geom.bevel + 1);
|
||||||
n = true;
|
|
||||||
x += geom.button_size;
|
x += geom.button_size;
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
case 'D':
|
case 'D':
|
||||||
|
if (!d) break;
|
||||||
XMapWindow(**otk::display, _desk);
|
XMapWindow(**otk::display, _desk);
|
||||||
XMoveWindow(**otk::display, _desk, x, geom.bevel + 1);
|
XMoveWindow(**otk::display, _desk, x, geom.bevel + 1);
|
||||||
d = true;
|
|
||||||
x += geom.button_size;
|
x += geom.button_size;
|
||||||
break;
|
break;
|
||||||
case 'i':
|
case 'i':
|
||||||
case 'I':
|
case 'I':
|
||||||
|
if (!i) break;
|
||||||
XMapWindow(**otk::display, _iconify);
|
XMapWindow(**otk::display, _iconify);
|
||||||
XMoveWindow(**otk::display, _iconify, x, geom.bevel + 1);
|
XMoveWindow(**otk::display, _iconify, x, geom.bevel + 1);
|
||||||
i = true;
|
|
||||||
x += geom.button_size;
|
x += geom.button_size;
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
case 'T':
|
case 'T':
|
||||||
|
if (!t) break;
|
||||||
XMapWindow(**otk::display, _label);
|
XMapWindow(**otk::display, _label);
|
||||||
XMoveWindow(**otk::display, _label, x, geom.bevel);
|
XMoveWindow(**otk::display, _label, x, geom.bevel);
|
||||||
l = true;
|
|
||||||
x += geom.label_width;
|
x += geom.label_width;
|
||||||
break;
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
case 'M':
|
case 'M':
|
||||||
|
if (!m) break;
|
||||||
XMapWindow(**otk::display, _max);
|
XMapWindow(**otk::display, _max);
|
||||||
XMoveWindow(**otk::display, _max, x, geom.bevel + 1);
|
XMoveWindow(**otk::display, _max, x, geom.bevel + 1);
|
||||||
m = true;
|
|
||||||
x += geom.button_size;
|
x += geom.button_size;
|
||||||
break;
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
case 'C':
|
case 'C':
|
||||||
|
if (!c) break;
|
||||||
XMapWindow(**otk::display, _close);
|
XMapWindow(**otk::display, _close);
|
||||||
XMoveWindow(**otk::display, _close, x, geom.bevel + 1);
|
XMoveWindow(**otk::display, _close, x, geom.bevel + 1);
|
||||||
c = true;
|
|
||||||
x += geom.button_size;
|
x += geom.button_size;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
x += geom.bevel;
|
x += geom.bevel;
|
||||||
}
|
}
|
||||||
if (!n) XUnmapWindow(**otk::display, _icon);
|
|
||||||
if (!d) XUnmapWindow(**otk::display, _desk);
|
|
||||||
if (!i) XUnmapWindow(**otk::display, _iconify);
|
|
||||||
if (!l) XUnmapWindow(**otk::display, _label);
|
|
||||||
if (!m) XUnmapWindow(**otk::display, _max);
|
|
||||||
if (!c) XUnmapWindow(**otk::display, _close);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Frame::adjustPosition()
|
void Frame::adjustPosition()
|
||||||
|
@ -633,8 +701,6 @@ void Frame::adjustPosition()
|
||||||
void Frame::adjustShape()
|
void Frame::adjustShape()
|
||||||
{
|
{
|
||||||
#ifdef SHAPE
|
#ifdef SHAPE
|
||||||
Client::DecorationFlags decorations = _client->decorations();
|
|
||||||
|
|
||||||
if (!_client->shaped()) {
|
if (!_client->shaped()) {
|
||||||
// clear the shape on the frame window
|
// clear the shape on the frame window
|
||||||
XShapeCombineMask(**otk::display, _frame, ShapeBounding,
|
XShapeCombineMask(**otk::display, _frame, ShapeBounding,
|
||||||
|
@ -651,7 +717,7 @@ void Frame::adjustShape()
|
||||||
int num = 0;
|
int num = 0;
|
||||||
XRectangle xrect[2];
|
XRectangle xrect[2];
|
||||||
|
|
||||||
if (decorations & Client::Decor_Titlebar) {
|
if (_decorations & Client::Decor_Titlebar) {
|
||||||
xrect[0].x = -geom.bevel;
|
xrect[0].x = -geom.bevel;
|
||||||
xrect[0].y = -geom.bevel;
|
xrect[0].y = -geom.bevel;
|
||||||
xrect[0].width = geom.width + geom.bwidth * 2;
|
xrect[0].width = geom.width + geom.bwidth * 2;
|
||||||
|
@ -659,7 +725,7 @@ void Frame::adjustShape()
|
||||||
++num;
|
++num;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (decorations & Client::Decor_Handle) {
|
if (_decorations & Client::Decor_Handle) {
|
||||||
xrect[1].x = -geom.bevel;
|
xrect[1].x = -geom.bevel;
|
||||||
xrect[1].y = geom.handle_y;
|
xrect[1].y = geom.handle_y;
|
||||||
xrect[1].width = geom.width + geom.bwidth * 2;
|
xrect[1].width = geom.width + geom.bwidth * 2;
|
||||||
|
@ -674,13 +740,16 @@ void Frame::adjustShape()
|
||||||
#endif // SHAPE
|
#endif // SHAPE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Frame::adjustState()
|
void Frame::adjustState()
|
||||||
{
|
{
|
||||||
renderDesk();
|
renderDesk();
|
||||||
renderMax();
|
renderMax();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Frame::adjustIcon()
|
||||||
|
{
|
||||||
|
renderIcon();
|
||||||
|
}
|
||||||
|
|
||||||
void Frame::grabClient()
|
void Frame::grabClient()
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,6 +9,7 @@ extern "C" {
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include "client.hh"
|
||||||
#include "python.hh"
|
#include "python.hh"
|
||||||
#include "otk/strut.hh"
|
#include "otk/strut.hh"
|
||||||
#include "otk/rect.hh"
|
#include "otk/rect.hh"
|
||||||
|
@ -22,8 +23,6 @@ extern "C" {
|
||||||
|
|
||||||
namespace ob {
|
namespace ob {
|
||||||
|
|
||||||
class Client;
|
|
||||||
|
|
||||||
//! Varius geometry settings in the frame decorations
|
//! Varius geometry settings in the frame decorations
|
||||||
struct FrameGeometry {
|
struct FrameGeometry {
|
||||||
int width; // title and handle
|
int width; // title and handle
|
||||||
|
@ -67,6 +66,9 @@ private:
|
||||||
|
|
||||||
bool _visible;
|
bool _visible;
|
||||||
|
|
||||||
|
//! The decorations that are being displayed in the frame.
|
||||||
|
Client::DecorationFlags _decorations;
|
||||||
|
|
||||||
// decoration windows
|
// decoration windows
|
||||||
Window _frame; // sits under everything
|
Window _frame; // sits under everything
|
||||||
Window _plate; // sits entirely under the client window
|
Window _plate; // sits entirely under the client window
|
||||||
|
@ -144,6 +146,7 @@ public:
|
||||||
void adjustState();
|
void adjustState();
|
||||||
void adjustFocus();
|
void adjustFocus();
|
||||||
void adjustTitle();
|
void adjustTitle();
|
||||||
|
void adjustIcon();
|
||||||
|
|
||||||
//! Applies gravity to the client's position to find where the frame should
|
//! Applies gravity to the client's position to find where the frame should
|
||||||
//! be positioned.
|
//! be positioned.
|
||||||
|
|
Loading…
Reference in a new issue