add a Config class with config data from the scripts.
set up the functions for loading a style from a file. use the Config class throughout instead of reading out of the python namespace all the time.
This commit is contained in:
parent
1431cd1958
commit
059bc4dc24
15 changed files with 663 additions and 436 deletions
|
@ -17,8 +17,10 @@ void RenderStyle::initialize()
|
|||
{
|
||||
int screens = ScreenCount(**display);
|
||||
_styles = new RenderStyle*[screens];
|
||||
for (int i = 0; i < screens; ++i)
|
||||
_styles[i] = new RenderStyle(i, ""); // XXX get a path
|
||||
for (int i = 0; i < screens; ++i) {
|
||||
_styles[i] = new RenderStyle();
|
||||
defaultStyle(_styles[i], i);
|
||||
}
|
||||
_notifies = new std::list<StyleNotify*>[screens];
|
||||
}
|
||||
|
||||
|
@ -49,31 +51,48 @@ RenderStyle *RenderStyle::style(int screen)
|
|||
return _styles[screen];
|
||||
}
|
||||
|
||||
RenderStyle::RenderStyle(int screen, const std::string &stylefile)
|
||||
: _screen(screen),
|
||||
_file(stylefile)
|
||||
bool RenderStyle::setStyle(int screen, const ustring &stylefile)
|
||||
{
|
||||
RenderStyle *s = new RenderStyle();
|
||||
if (!loadStyle(s, screen, stylefile)) {
|
||||
delete s;
|
||||
return false;
|
||||
}
|
||||
delete _styles[screen];
|
||||
_styles[screen] = s;
|
||||
|
||||
std::list<StyleNotify*>::iterator it, end = _notifies[screen].end();
|
||||
for (it = _notifies[screen].begin(); it != end; ++it)
|
||||
(*it)->styleChanged(*s);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RenderStyle::loadStyle(RenderStyle *s, int screen,
|
||||
const ustring &stylefile)
|
||||
{
|
||||
s->_screen = screen;
|
||||
s->_file = stylefile;
|
||||
// pick one..
|
||||
//#define FIERON
|
||||
#define MERRY
|
||||
|
||||
#ifdef FIERON
|
||||
_root_color = new RenderColor(_screen, 0x272a2f);
|
||||
s->_root_color = new RenderColor(screen, 0x272a2f);
|
||||
|
||||
_text_color_focus = new RenderColor(_screen, 0x272a2f);
|
||||
_text_color_unfocus = new RenderColor(_screen, 0x676869);
|
||||
s->_text_color_focus = new RenderColor(screen, 0x272a2f);
|
||||
s->_text_color_unfocus = new RenderColor(screen, 0x676869);
|
||||
|
||||
_button_color_focus = new RenderColor(_screen, 0x96ba86);
|
||||
_button_color_unfocus = new RenderColor(_screen, 0x676869);
|
||||
s->_button_color_focus = new RenderColor(screen, 0x96ba86);
|
||||
s->_button_color_unfocus = new RenderColor(screen, 0x676869);
|
||||
|
||||
_frame_border_color = new RenderColor(_screen, 0x181f24);
|
||||
_frame_border_width = 1;
|
||||
s->_frame_border_color = new RenderColor(screen, 0x181f24);
|
||||
s->_frame_border_width = 1;
|
||||
|
||||
_client_border_color_focus = new RenderColor(_screen, 0x858687);
|
||||
_client_border_color_unfocus = new RenderColor(_screen, 0x555657);
|
||||
_client_border_width = 1;
|
||||
s->_client_border_color_focus = new RenderColor(screen, 0x858687);
|
||||
s->_client_border_color_unfocus = new RenderColor(screen, 0x555657);
|
||||
s->_client_border_width = 1;
|
||||
|
||||
_titlebar_focus = new RenderTexture(_screen,
|
||||
s->_titlebar_focus = new RenderTexture(screen,
|
||||
false,
|
||||
RenderTexture::Flat,
|
||||
RenderTexture::Bevel1,
|
||||
|
@ -84,7 +103,7 @@ RenderStyle::RenderStyle(int screen, const std::string &stylefile)
|
|||
0x373a3f,
|
||||
0x0,
|
||||
0x0);
|
||||
_titlebar_unfocus = new RenderTexture(_screen,
|
||||
s->_titlebar_unfocus = new RenderTexture(screen,
|
||||
false,
|
||||
RenderTexture::Flat,
|
||||
RenderTexture::Bevel1,
|
||||
|
@ -96,7 +115,7 @@ RenderStyle::RenderStyle(int screen, const std::string &stylefile)
|
|||
0x0,
|
||||
0x0);
|
||||
|
||||
_label_focus = new RenderTexture(_screen,
|
||||
s->_label_focus = new RenderTexture(screen,
|
||||
false,
|
||||
RenderTexture::Flat,
|
||||
RenderTexture::Bevel1,
|
||||
|
@ -107,7 +126,7 @@ RenderStyle::RenderStyle(int screen, const std::string &stylefile)
|
|||
0x5a724c,
|
||||
0x181f24,
|
||||
0x0);
|
||||
_label_unfocus = new RenderTexture(_screen,
|
||||
s->_label_unfocus = new RenderTexture(screen,
|
||||
false,
|
||||
RenderTexture::Sunken,
|
||||
RenderTexture::Bevel1,
|
||||
|
@ -119,8 +138,7 @@ RenderStyle::RenderStyle(int screen, const std::string &stylefile)
|
|||
0x0,
|
||||
0x0);
|
||||
|
||||
|
||||
_handle_focus = new RenderTexture(_screen,
|
||||
s->_handle_focus = new RenderTexture(screen,
|
||||
false,
|
||||
RenderTexture::Flat,
|
||||
RenderTexture::Bevel1,
|
||||
|
@ -131,7 +149,7 @@ RenderStyle::RenderStyle(int screen, const std::string &stylefile)
|
|||
0x373a3f,
|
||||
0x0,
|
||||
0x0);
|
||||
_handle_unfocus = new RenderTexture(_screen,
|
||||
s->_handle_unfocus = new RenderTexture(screen,
|
||||
false,
|
||||
RenderTexture::Flat,
|
||||
RenderTexture::Bevel1,
|
||||
|
@ -143,8 +161,7 @@ RenderStyle::RenderStyle(int screen, const std::string &stylefile)
|
|||
0x0,
|
||||
0x0);
|
||||
|
||||
|
||||
_button_unpress_focus = new RenderTexture(_screen,
|
||||
s->_button_unpress_focus = new RenderTexture(screen,
|
||||
false,
|
||||
RenderTexture::Raised,
|
||||
RenderTexture::Bevel2,
|
||||
|
@ -155,7 +172,7 @@ RenderStyle::RenderStyle(int screen, const std::string &stylefile)
|
|||
0x272a2f,
|
||||
0x0,
|
||||
0x0);
|
||||
_button_unpress_unfocus = new RenderTexture(_screen,
|
||||
s->_button_unpress_unfocus = new RenderTexture(screen,
|
||||
false,
|
||||
RenderTexture::Raised,
|
||||
RenderTexture::Bevel2,
|
||||
|
@ -167,7 +184,7 @@ RenderStyle::RenderStyle(int screen, const std::string &stylefile)
|
|||
0x0,
|
||||
0x0);
|
||||
|
||||
_button_press_focus = new RenderTexture(_screen,
|
||||
s->_button_press_focus = new RenderTexture(screen,
|
||||
false,
|
||||
RenderTexture::Sunken,
|
||||
RenderTexture::Bevel2,
|
||||
|
@ -178,7 +195,7 @@ RenderStyle::RenderStyle(int screen, const std::string &stylefile)
|
|||
0x5a724c,
|
||||
0x0,
|
||||
0x0);
|
||||
_button_press_unfocus = new RenderTexture(_screen,
|
||||
s->_button_press_unfocus = new RenderTexture(screen,
|
||||
false,
|
||||
RenderTexture::Sunken,
|
||||
RenderTexture::Bevel2,
|
||||
|
@ -190,7 +207,7 @@ RenderStyle::RenderStyle(int screen, const std::string &stylefile)
|
|||
0x0,
|
||||
0x0);
|
||||
|
||||
_grip_focus = new RenderTexture(_screen,
|
||||
s->_grip_focus = new RenderTexture(screen,
|
||||
false,
|
||||
RenderTexture::Flat,
|
||||
RenderTexture::Bevel1,
|
||||
|
@ -201,7 +218,7 @@ RenderStyle::RenderStyle(int screen, const std::string &stylefile)
|
|||
0x5a724c,
|
||||
0x0,
|
||||
0x0);
|
||||
_grip_unfocus = new RenderTexture(_screen,
|
||||
s->_grip_unfocus = new RenderTexture(screen,
|
||||
false,
|
||||
RenderTexture::Flat,
|
||||
RenderTexture::Bevel1,
|
||||
|
@ -213,73 +230,73 @@ RenderStyle::RenderStyle(int screen, const std::string &stylefile)
|
|||
0x0,
|
||||
0x0);
|
||||
|
||||
_label_font = new Font(_screen, "Arial,Sans-9:bold", true, 1, 0x40);
|
||||
_label_justify = RightBottomJustify;
|
||||
s->_label_font = new Font(screen, "Arial,Sans-9:bold", true, 1, 0x40);
|
||||
s->_label_justify = RightBottomJustify;
|
||||
|
||||
_max_mask = new PixmapMask();
|
||||
_max_mask->w = _max_mask->h = 8;
|
||||
s->_max_mask = new PixmapMask();
|
||||
s->_max_mask->w = s->_max_mask->h = 8;
|
||||
{
|
||||
//char data[] = { 0x7e, 0xff, 0xc3, 0xc3, 0xc3, 0xc3, 0xff, 0x7e };
|
||||
char data [] = {0x00, 0x00, 0x18, 0x3c, 0x66, 0x42, 0x00, 0x00 };
|
||||
_max_mask->mask =
|
||||
s->_max_mask->mask =
|
||||
XCreateBitmapFromData(**display,
|
||||
display->screenInfo(_screen)->rootWindow(),
|
||||
display->screenInfo(screen)->rootWindow(),
|
||||
data, 8, 8);
|
||||
}
|
||||
|
||||
_icon_mask = new PixmapMask();
|
||||
_icon_mask->w = _icon_mask->h = 8;
|
||||
s->_icon_mask = new PixmapMask();
|
||||
s->_icon_mask->w = s->_icon_mask->h = 8;
|
||||
{
|
||||
//char data[] = { 0x00, 0x00, 0xc3, 0xe7, 0x7e, 0x3c, 0x18, 0x00 };
|
||||
char data[] = { 0x00, 0x00, 0x42, 0x66, 0x3c, 0x18, 0x00, 0x00 };
|
||||
_icon_mask->mask =
|
||||
s->_icon_mask->mask =
|
||||
XCreateBitmapFromData(**display,
|
||||
display->screenInfo(_screen)->rootWindow(),
|
||||
display->screenInfo(screen)->rootWindow(),
|
||||
data, 8, 8);
|
||||
}
|
||||
|
||||
_alldesk_mask = new PixmapMask();
|
||||
_alldesk_mask->w = _alldesk_mask->h = 8;
|
||||
s->_alldesk_mask = new PixmapMask();
|
||||
s->_alldesk_mask->w = s->_alldesk_mask->h = 8;
|
||||
{
|
||||
//char data[] = { 0x00, 0x00, 0x18, 0x3c, 0x3c, 0x18, 0x00, 0x00 };
|
||||
char data[] = { 0x00, 0x66, 0x66, 0x00, 0x00, 0x66, 0x66, 0x00 };
|
||||
_alldesk_mask->mask =
|
||||
s->_alldesk_mask->mask =
|
||||
XCreateBitmapFromData(**display,
|
||||
display->screenInfo(_screen)->rootWindow(),
|
||||
display->screenInfo(screen)->rootWindow(),
|
||||
data, 8, 8);
|
||||
}
|
||||
|
||||
_close_mask = new PixmapMask();
|
||||
_close_mask->w = _close_mask->h = 8;
|
||||
s->_close_mask = new PixmapMask();
|
||||
s->_close_mask->w = s->_close_mask->h = 8;
|
||||
{
|
||||
//char data[] = { 0xc3, 0xe7, 0x7e, 0x3c, 0x3c, 0x7e, 0xe7, 0xc3 };
|
||||
char data[] = { 0x00, 0xc3, 0x66, 0x3c, 0x3c, 0x66, 0xc3, 0x00 };
|
||||
_close_mask->mask =
|
||||
s->_close_mask->mask =
|
||||
XCreateBitmapFromData(**display,
|
||||
display->screenInfo(_screen)->rootWindow(),
|
||||
display->screenInfo(screen)->rootWindow(),
|
||||
data, 8, 8);
|
||||
}
|
||||
|
||||
_bevel_width = 1;
|
||||
_handle_width = 4;
|
||||
s->_bevel_width = 1;
|
||||
s->_handle_width = 4;
|
||||
#else
|
||||
# ifdef MERRY
|
||||
_root_color = new RenderColor(_screen, 0x7b756a);
|
||||
s->_root_color = new RenderColor(screen, 0x7b756a);
|
||||
|
||||
_text_color_focus = new RenderColor(_screen, 0xffffff);
|
||||
_text_color_unfocus = new RenderColor(_screen, 0xffffff);
|
||||
s->_text_color_focus = new RenderColor(screen, 0xffffff);
|
||||
s->_text_color_unfocus = new RenderColor(screen, 0xffffff);
|
||||
|
||||
_button_color_focus = new RenderColor(_screen, 0x222222);
|
||||
_button_color_unfocus = new RenderColor(_screen, 0x333333);
|
||||
s->_button_color_focus = new RenderColor(screen, 0x222222);
|
||||
s->_button_color_unfocus = new RenderColor(screen, 0x333333);
|
||||
|
||||
_frame_border_color = new RenderColor(_screen, 0x222222);
|
||||
_frame_border_width = 1;
|
||||
s->_frame_border_color = new RenderColor(screen, 0x222222);
|
||||
s->_frame_border_width = 1;
|
||||
|
||||
_client_border_color_focus = new RenderColor(_screen, 0x858687);
|
||||
_client_border_color_unfocus = new RenderColor(_screen, 0x555657);
|
||||
_client_border_width = 0;
|
||||
s->_client_border_color_focus = new RenderColor(screen, 0x858687);
|
||||
s->_client_border_color_unfocus = new RenderColor(screen, 0x555657);
|
||||
s->_client_border_width = 0;
|
||||
|
||||
_titlebar_focus = new RenderTexture(_screen,
|
||||
s->_titlebar_focus = new RenderTexture(screen,
|
||||
false,
|
||||
RenderTexture::Flat,
|
||||
RenderTexture::Bevel1,
|
||||
|
@ -290,7 +307,7 @@ RenderStyle::RenderStyle(int screen, const std::string &stylefile)
|
|||
0xe6e6e6,
|
||||
0x0,
|
||||
0x0);
|
||||
_titlebar_unfocus = new RenderTexture(_screen,
|
||||
s->_titlebar_unfocus = new RenderTexture(screen,
|
||||
false,
|
||||
RenderTexture::Flat,
|
||||
RenderTexture::Bevel1,
|
||||
|
@ -302,7 +319,7 @@ RenderStyle::RenderStyle(int screen, const std::string &stylefile)
|
|||
0x0,
|
||||
0x0);
|
||||
|
||||
_label_focus = new RenderTexture(_screen,
|
||||
s->_label_focus = new RenderTexture(screen,
|
||||
false,
|
||||
RenderTexture::Flat,
|
||||
RenderTexture::Bevel1,
|
||||
|
@ -316,7 +333,7 @@ RenderStyle::RenderStyle(int screen, const std::string &stylefile)
|
|||
0x222222,
|
||||
0x0);
|
||||
//urg this ain't so hot
|
||||
_label_unfocus = new RenderTexture(_screen,
|
||||
s->_label_unfocus = new RenderTexture(screen,
|
||||
false,
|
||||
RenderTexture::Flat,
|
||||
RenderTexture::Bevel1,
|
||||
|
@ -329,7 +346,7 @@ _label_unfocus = new RenderTexture(_screen,
|
|||
0x0);
|
||||
|
||||
|
||||
_handle_focus = new RenderTexture(_screen,
|
||||
s->_handle_focus = new RenderTexture(screen,
|
||||
false,
|
||||
RenderTexture::Flat,
|
||||
RenderTexture::Bevel1,
|
||||
|
@ -340,7 +357,7 @@ _label_unfocus = new RenderTexture(_screen,
|
|||
0xd9d9d9,
|
||||
0x0,
|
||||
0x0);
|
||||
_handle_unfocus = new RenderTexture(_screen,
|
||||
s->_handle_unfocus = new RenderTexture(screen,
|
||||
false,
|
||||
RenderTexture::Flat,
|
||||
RenderTexture::Bevel1,
|
||||
|
@ -353,7 +370,7 @@ _label_unfocus = new RenderTexture(_screen,
|
|||
0x0);
|
||||
|
||||
|
||||
_button_unpress_focus = new RenderTexture(_screen,
|
||||
s->_button_unpress_focus = new RenderTexture(screen,
|
||||
false,
|
||||
RenderTexture::Flat,
|
||||
RenderTexture::Bevel1,
|
||||
|
@ -364,7 +381,7 @@ _label_unfocus = new RenderTexture(_screen,
|
|||
0xe6e6e6,
|
||||
0x0,
|
||||
0x0);
|
||||
_button_unpress_unfocus = new RenderTexture(_screen,
|
||||
s->_button_unpress_unfocus = new RenderTexture(screen,
|
||||
false,
|
||||
RenderTexture::Flat,
|
||||
RenderTexture::Bevel1,
|
||||
|
@ -376,7 +393,7 @@ _label_unfocus = new RenderTexture(_screen,
|
|||
0x0,
|
||||
0x0);
|
||||
|
||||
_button_press_focus = new RenderTexture(_screen,
|
||||
s->_button_press_focus = new RenderTexture(screen,
|
||||
false,
|
||||
RenderTexture::Sunken,
|
||||
RenderTexture::Bevel2,
|
||||
|
@ -387,7 +404,7 @@ _label_unfocus = new RenderTexture(_screen,
|
|||
0xe6e6e6,
|
||||
0x0,
|
||||
0x0);
|
||||
_button_press_unfocus = new RenderTexture(_screen,
|
||||
s->_button_press_unfocus = new RenderTexture(screen,
|
||||
false,
|
||||
RenderTexture::Sunken,
|
||||
RenderTexture::Bevel2,
|
||||
|
@ -399,7 +416,7 @@ _label_unfocus = new RenderTexture(_screen,
|
|||
0x0,
|
||||
0x0);
|
||||
|
||||
_grip_focus = new RenderTexture(_screen,
|
||||
s->_grip_focus = new RenderTexture(screen,
|
||||
false,
|
||||
RenderTexture::Flat,
|
||||
RenderTexture::Bevel1,
|
||||
|
@ -410,7 +427,7 @@ _label_unfocus = new RenderTexture(_screen,
|
|||
0xd9d9d9,
|
||||
0x0,
|
||||
0x0);
|
||||
_grip_unfocus = new RenderTexture(_screen,
|
||||
s->_grip_unfocus = new RenderTexture(screen,
|
||||
false,
|
||||
RenderTexture::Flat,
|
||||
RenderTexture::Bevel1,
|
||||
|
@ -422,94 +439,261 @@ _label_unfocus = new RenderTexture(_screen,
|
|||
0x0,
|
||||
0x0);
|
||||
|
||||
_label_font = new Font(_screen, "Arial,Sans-8", true, 1, 0x3e);
|
||||
_label_justify = CenterJustify;
|
||||
s->_label_font = new Font(screen, "Arial,Sans-8", true, 1, 0x3e);
|
||||
s->_label_justify = CenterJustify;
|
||||
|
||||
_max_mask = new PixmapMask();
|
||||
_max_mask->w = _max_mask->h = 7;
|
||||
s->_max_mask = new PixmapMask();
|
||||
s->_max_mask->w = s->_max_mask->h = 7;
|
||||
{
|
||||
char data [] = {0x7c, 0x44, 0x47, 0x47, 0x7f, 0x1f, 0x1f };
|
||||
_max_mask->mask =
|
||||
s->_max_mask->mask =
|
||||
XCreateBitmapFromData(**display,
|
||||
display->screenInfo(_screen)->rootWindow(),
|
||||
display->screenInfo(screen)->rootWindow(),
|
||||
data, 7, 7);
|
||||
}
|
||||
|
||||
_icon_mask = new PixmapMask();
|
||||
_icon_mask->w = _icon_mask->h = 7;
|
||||
s->_icon_mask = new PixmapMask();
|
||||
s->_icon_mask->w = s->_icon_mask->h = 7;
|
||||
{
|
||||
char data[] = {0x00, 0x00, 0x00, 0x00, 0x3e, 0x3e, 0x3e };
|
||||
_icon_mask->mask =
|
||||
s->_icon_mask->mask =
|
||||
XCreateBitmapFromData(**display,
|
||||
display->screenInfo(_screen)->rootWindow(),
|
||||
display->screenInfo(screen)->rootWindow(),
|
||||
data, 7, 7);
|
||||
}
|
||||
|
||||
_alldesk_mask = new PixmapMask();
|
||||
_alldesk_mask->w = _alldesk_mask->h = 7;
|
||||
s->_alldesk_mask = new PixmapMask();
|
||||
s->_alldesk_mask->w = s->_alldesk_mask->h = 7;
|
||||
{
|
||||
char data[] = {0x00, 0x36, 0x36, 0x00, 0x36, 0x36, 0x00 };
|
||||
_alldesk_mask->mask =
|
||||
s->_alldesk_mask->mask =
|
||||
XCreateBitmapFromData(**display,
|
||||
display->screenInfo(_screen)->rootWindow(),
|
||||
display->screenInfo(screen)->rootWindow(),
|
||||
data, 7, 7);
|
||||
}
|
||||
|
||||
_close_mask = new PixmapMask();
|
||||
_close_mask->w = _close_mask->h = 7;
|
||||
s->_close_mask = new PixmapMask();
|
||||
s->_close_mask->w = s->_close_mask->h = 7;
|
||||
{
|
||||
char data[] = { 0x22, 0x77, 0x3e, 0x1c, 0x3e, 0x77, 0x22 };
|
||||
_close_mask->mask =
|
||||
s->_close_mask->mask =
|
||||
XCreateBitmapFromData(**display,
|
||||
display->screenInfo(_screen)->rootWindow(),
|
||||
display->screenInfo(screen)->rootWindow(),
|
||||
data, 7, 7);
|
||||
}
|
||||
|
||||
_bevel_width = 1;
|
||||
_handle_width = 3;
|
||||
s->_bevel_width = 1;
|
||||
s->_handle_width = 3;
|
||||
# else
|
||||
# error 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void RenderStyle::defaultStyle(RenderStyle *s, int screen)
|
||||
{
|
||||
s->_screen = screen;
|
||||
s->_file = "";
|
||||
|
||||
s->_root_color = new RenderColor(screen, 0);
|
||||
s->_text_color_focus = new RenderColor(screen, 0xffffff);
|
||||
s->_text_color_unfocus = new RenderColor(screen, 0xffffff);
|
||||
s->_button_color_focus = new RenderColor(screen, 0);
|
||||
s->_button_color_unfocus = new RenderColor(screen, 0);
|
||||
s->_frame_border_color = new RenderColor(screen, 0);
|
||||
s->_frame_border_width = 1;
|
||||
s->_client_border_color_focus = new RenderColor(screen, 0);
|
||||
s->_client_border_color_unfocus = new RenderColor(screen, 0);
|
||||
s->_client_border_width = 1;
|
||||
s->_titlebar_focus = new RenderTexture(screen,
|
||||
false,
|
||||
RenderTexture::Flat,
|
||||
RenderTexture::Bevel1,
|
||||
false,
|
||||
RenderTexture::Solid,
|
||||
false,
|
||||
0, 0, 0, 0);
|
||||
s->_titlebar_unfocus = new RenderTexture(screen,
|
||||
false,
|
||||
RenderTexture::Flat,
|
||||
RenderTexture::Bevel1,
|
||||
false,
|
||||
RenderTexture::Solid,
|
||||
false,
|
||||
0, 0, 0, 0);
|
||||
|
||||
s->_label_focus = new RenderTexture(screen,
|
||||
false,
|
||||
RenderTexture::Flat,
|
||||
RenderTexture::Bevel1,
|
||||
true,
|
||||
RenderTexture::Solid,
|
||||
false,
|
||||
0, 0, 0, 0);
|
||||
s->_label_unfocus = new RenderTexture(screen,
|
||||
false,
|
||||
RenderTexture::Flat,
|
||||
RenderTexture::Bevel1,
|
||||
false,
|
||||
RenderTexture::Solid,
|
||||
false,
|
||||
0, 0, 0, 0);
|
||||
|
||||
s->_handle_focus = new RenderTexture(screen,
|
||||
false,
|
||||
RenderTexture::Flat,
|
||||
RenderTexture::Bevel1,
|
||||
false,
|
||||
RenderTexture::Solid,
|
||||
false,
|
||||
0, 0, 0, 0);
|
||||
s->_handle_unfocus = new RenderTexture(screen,
|
||||
false,
|
||||
RenderTexture::Flat,
|
||||
RenderTexture::Bevel1,
|
||||
false,
|
||||
RenderTexture::Solid,
|
||||
false,
|
||||
0, 0, 0, 0);
|
||||
|
||||
s->_button_unpress_focus = new RenderTexture(screen,
|
||||
false,
|
||||
RenderTexture::Flat,
|
||||
RenderTexture::Bevel1,
|
||||
false,
|
||||
RenderTexture::Solid,
|
||||
false,
|
||||
0, 0, 0, 0);
|
||||
s->_button_unpress_unfocus = new RenderTexture(screen,
|
||||
false,
|
||||
RenderTexture::Flat,
|
||||
RenderTexture::Bevel1,
|
||||
false,
|
||||
RenderTexture::Solid,
|
||||
false,
|
||||
0, 0, 0, 0);
|
||||
|
||||
s->_button_press_focus = new RenderTexture(screen,
|
||||
false,
|
||||
RenderTexture::Flat,
|
||||
RenderTexture::Bevel1,
|
||||
false,
|
||||
RenderTexture::Solid,
|
||||
false,
|
||||
0, 0, 0, 0);
|
||||
s->_button_press_unfocus = new RenderTexture(screen,
|
||||
false,
|
||||
RenderTexture::Flat,
|
||||
RenderTexture::Bevel1,
|
||||
false,
|
||||
RenderTexture::Solid,
|
||||
false,
|
||||
0, 0, 0, 0);
|
||||
|
||||
s->_grip_focus = new RenderTexture(screen,
|
||||
false,
|
||||
RenderTexture::Flat,
|
||||
RenderTexture::Bevel1,
|
||||
false,
|
||||
RenderTexture::Solid,
|
||||
false,
|
||||
0, 0, 0, 0);
|
||||
s->_grip_unfocus = new RenderTexture(screen,
|
||||
false,
|
||||
RenderTexture::Flat,
|
||||
RenderTexture::Bevel1,
|
||||
false,
|
||||
RenderTexture::Solid,
|
||||
false,
|
||||
0, 0, 0, 0);
|
||||
|
||||
s->_label_font = new Font(screen, "Sans-9", false, 0, 0);
|
||||
s->_label_justify = LeftTopJustify;
|
||||
|
||||
s->_max_mask = new PixmapMask();
|
||||
s->_max_mask->w = s->_max_mask->h = 0;
|
||||
s->_max_mask->mask = None;
|
||||
|
||||
s->_icon_mask = new PixmapMask();
|
||||
s->_icon_mask->w = s->_icon_mask->h = 0;
|
||||
s->_icon_mask->mask = None;
|
||||
|
||||
s->_alldesk_mask = new PixmapMask();
|
||||
s->_alldesk_mask->w = s->_alldesk_mask->h = 0;
|
||||
s->_alldesk_mask->mask = 0;
|
||||
|
||||
s->_close_mask = new PixmapMask();
|
||||
s->_close_mask->w = s->_close_mask->h = 8;
|
||||
s->_close_mask->mask = 0;
|
||||
|
||||
s->_bevel_width = 1;
|
||||
s->_handle_width = 4;
|
||||
}
|
||||
|
||||
RenderStyle::~RenderStyle()
|
||||
{
|
||||
assert(_root_color);
|
||||
delete _root_color;
|
||||
|
||||
assert(_text_color_focus);
|
||||
delete _text_color_focus;
|
||||
assert(_text_color_unfocus);
|
||||
delete _text_color_unfocus;
|
||||
|
||||
assert(_button_color_focus);
|
||||
delete _button_color_focus;
|
||||
assert(_button_color_unfocus);
|
||||
delete _button_color_unfocus;
|
||||
|
||||
assert(_frame_border_color);
|
||||
delete _frame_border_color;
|
||||
|
||||
assert(_client_border_color_focus);
|
||||
delete _client_border_color_focus;
|
||||
assert(_client_border_color_unfocus);
|
||||
delete _client_border_color_unfocus;
|
||||
|
||||
assert(_titlebar_focus);
|
||||
delete _titlebar_focus;
|
||||
assert(_titlebar_unfocus);
|
||||
delete _titlebar_unfocus;
|
||||
|
||||
assert(_label_focus);
|
||||
delete _label_focus;
|
||||
assert(_label_unfocus);
|
||||
delete _label_unfocus;
|
||||
|
||||
assert(_handle_focus);
|
||||
delete _handle_focus;
|
||||
assert(_handle_unfocus);
|
||||
delete _handle_unfocus;
|
||||
|
||||
assert(_button_unpress_focus);
|
||||
delete _button_unpress_focus;
|
||||
assert(_button_unpress_unfocus);
|
||||
delete _button_unpress_unfocus;
|
||||
assert(_button_press_focus);
|
||||
delete _button_press_focus;
|
||||
assert(_button_press_unfocus);
|
||||
delete _button_press_unfocus;
|
||||
|
||||
assert(_grip_focus);
|
||||
delete _grip_focus;
|
||||
assert(_grip_unfocus);
|
||||
delete _grip_unfocus;
|
||||
|
||||
assert(_label_font);
|
||||
delete _label_font;
|
||||
|
||||
assert(_max_mask);
|
||||
delete _max_mask;
|
||||
assert(_icon_mask);
|
||||
delete _icon_mask;
|
||||
assert(_alldesk_mask);
|
||||
delete _alldesk_mask;
|
||||
assert(_close_mask);
|
||||
delete _close_mask;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
#include "rendertexture.hh"
|
||||
#include "rendercolor.hh"
|
||||
#include "font.hh"
|
||||
#include "ustring.hh"
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
|
||||
namespace otk {
|
||||
|
@ -34,6 +34,7 @@ public:
|
|||
static void registerNotify(int screen, StyleNotify *n);
|
||||
static void unregisterNotify(int screen, StyleNotify *n);
|
||||
static RenderStyle *style(int screen);
|
||||
static bool setStyle(int screen, const ustring &stylefile);
|
||||
|
||||
enum Justify {
|
||||
LeftTopJustify,
|
||||
|
@ -42,8 +43,11 @@ public:
|
|||
};
|
||||
|
||||
private:
|
||||
static bool loadStyle(RenderStyle *s, int screen, const ustring &stylefile);
|
||||
static void defaultStyle(RenderStyle *s, int screen);
|
||||
|
||||
int _screen;
|
||||
std::string _file;
|
||||
ustring _file;
|
||||
|
||||
RenderColor *_root_color;
|
||||
|
||||
|
@ -89,7 +93,6 @@ private:
|
|||
int _bevel_width;
|
||||
|
||||
public:
|
||||
RenderStyle(int screen, const std::string &stylefile);
|
||||
virtual ~RenderStyle();
|
||||
|
||||
inline int screen() const { return _screen; }
|
||||
|
|
|
@ -6,7 +6,7 @@ THEME = "/usr/local/share/openbox/styles/fieron2"
|
|||
"""The theme used to decorate everything."""
|
||||
|
||||
#TITLEBAR_LAYOUT = [ "icon", "title", "alldesktops", "iconify", "maximize", "close" ]
|
||||
TITLEBAR_LAYOUT = [ "alldesktops", "iconify", "title", "maximize", "close" ]
|
||||
TITLEBAR_LAYOUT = "NTIMC"
|
||||
"""The layout of the buttons/label on client titlebars, can be made up of the
|
||||
following:
|
||||
I - iconify button
|
||||
|
|
|
@ -16,9 +16,9 @@ bin_PROGRAMS= openbox3
|
|||
openbox3_LDADD=-L../otk -lotk @LIBINTL@
|
||||
openbox3_LDFLAGS=-export-dynamic
|
||||
openbox3_SOURCES= actions.cc client.cc frame.cc openbox.cc screen.cc \
|
||||
main.cc python.cc bindings.cc
|
||||
main.cc python.cc bindings.cc config.cc
|
||||
noinst_HEADERS= actions.hh bindings.hh client.hh frame.hh openbox.hh \
|
||||
python.hh screen.hh
|
||||
python.hh screen.hh config.hh
|
||||
|
||||
MAINTAINERCLEANFILES= Makefile.in
|
||||
|
||||
|
|
|
@ -165,12 +165,7 @@ void Actions::buttonReleaseHandler(const XButtonEvent &e)
|
|||
data.action = MouseAction::Click;
|
||||
openbox->bindings()->fireButton(&data);
|
||||
|
||||
|
||||
// XXX: dont load this every time!!@*
|
||||
long dblclick;
|
||||
if (!python_get_long("DOUBLE_CLICK_DELAY", &dblclick))
|
||||
dblclick = 300;
|
||||
|
||||
long dblclick = openbox->screen(screen)->config().double_click_delay;
|
||||
if (e.time - _release.time < (unsigned)dblclick &&
|
||||
_release.win == e.window && _release.button == e.button) {
|
||||
|
||||
|
@ -318,13 +313,17 @@ void Actions::motionHandler(const XMotionEvent &e)
|
|||
y_root = e.y_root;
|
||||
}
|
||||
|
||||
int screen;
|
||||
Client *c = openbox->findClient(e.window);
|
||||
if (c)
|
||||
screen = c->screen();
|
||||
else
|
||||
screen = otk::display->findScreen(e.root)->screen();
|
||||
|
||||
if (!_dragging) {
|
||||
long threshold;
|
||||
int dx = x_root - _posqueue[0]->pos.x();
|
||||
int dy = y_root - _posqueue[0]->pos.y();
|
||||
// XXX: dont get this from python every time!
|
||||
if (!python_get_long("DRAG_THRESHOLD", &threshold))
|
||||
threshold = 0;
|
||||
long threshold = openbox->screen(screen)->config().drag_threshold;
|
||||
if (!(std::abs(dx) >= threshold || std::abs(dy) >= threshold))
|
||||
return; // not at the threshold yet
|
||||
}
|
||||
|
@ -337,12 +336,6 @@ void Actions::motionHandler(const XMotionEvent &e)
|
|||
unsigned int state = e.state & (ControlMask | ShiftMask | Mod1Mask |
|
||||
Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask);
|
||||
unsigned int button = _posqueue[0]->button;
|
||||
int screen;
|
||||
Client *c = openbox->findClient(e.window);
|
||||
if (c)
|
||||
screen = c->screen();
|
||||
else
|
||||
screen = otk::display->findScreen(e.root)->screen();
|
||||
MouseData data(screen, c, e.time, state, button, context,
|
||||
MouseAction::Motion, x_root, y_root,
|
||||
_posqueue[0]->pos, _posqueue[0]->clientarea);
|
||||
|
|
|
@ -446,7 +446,7 @@ void Client::calcLayer() {
|
|||
}
|
||||
c = c->_transient_for;
|
||||
}
|
||||
if (!fs) {
|
||||
if (!fs && _fullscreen) {
|
||||
// is one of our transients focused?
|
||||
c = searchFocusTree(this, this);
|
||||
if (c) fs = true;
|
||||
|
@ -738,8 +738,6 @@ void Client::updateIcons()
|
|||
i += w * h;
|
||||
assert(i <= num);
|
||||
}
|
||||
printf("i: %lu\n", i);
|
||||
printf("bleffffffff\n");
|
||||
|
||||
delete [] data;
|
||||
}
|
||||
|
|
72
src/config.cc
Normal file
72
src/config.cc
Normal file
|
@ -0,0 +1,72 @@
|
|||
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "config.hh"
|
||||
|
||||
extern "C" {
|
||||
#include <Python.h>
|
||||
}
|
||||
|
||||
namespace ob {
|
||||
|
||||
static PyObject *obdict = NULL;
|
||||
|
||||
bool python_get_long(const char *name, long *value)
|
||||
{
|
||||
PyObject *val = PyDict_GetItemString(obdict, const_cast<char*>(name));
|
||||
if (!(val && PyInt_Check(val))) return false;
|
||||
|
||||
*value = PyInt_AsLong(val);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool python_get_string(const char *name, otk::ustring *value)
|
||||
{
|
||||
PyObject *val = PyDict_GetItemString(obdict, const_cast<char*>(name));
|
||||
if (!(val && PyString_Check(val))) return false;
|
||||
|
||||
*value = PyString_AsString(val);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool python_get_stringlist(const char *name, std::vector<otk::ustring> *value)
|
||||
{
|
||||
PyObject *val = PyDict_GetItemString(obdict, const_cast<char*>(name));
|
||||
if (!(val && PyList_Check(val))) return false;
|
||||
|
||||
value->clear();
|
||||
|
||||
for (int i = 0, end = PyList_Size(val); i < end; ++i) {
|
||||
PyObject *str = PyList_GetItem(val, i);
|
||||
if (PyString_Check(str))
|
||||
value->push_back(PyString_AsString(str));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Config::Config()
|
||||
{
|
||||
PyRun_SimpleString("import config;");
|
||||
// set up access to the python global variables
|
||||
PyObject *obmodule = PyImport_AddModule("config");
|
||||
obdict = PyModule_GetDict(obmodule);
|
||||
|
||||
std::vector<otk::ustring> names;
|
||||
python_get_stringlist("DESKTOP_NAMES", &names);
|
||||
|
||||
python_get_string("THEME", &theme);
|
||||
|
||||
if (!python_get_string("TITLEBAR_LAYOUT", &titlebar_layout))
|
||||
titlebar_layout = "NTIMC";
|
||||
printf("LAYOUT %s\n", titlebar_layout.c_str());
|
||||
|
||||
if (!python_get_long("DOUBLE_CLICK_DELAY", &double_click_delay))
|
||||
double_click_delay = 300;
|
||||
if (!python_get_long("DRAG_THRESHOLD", &drag_threshold))
|
||||
drag_threshold = 3;
|
||||
if (!python_get_long("NUMBER_OF_DESKTOPS", (long*)&num_desktops))
|
||||
num_desktops = 1;
|
||||
}
|
||||
|
||||
}
|
29
src/config.hh
Normal file
29
src/config.hh
Normal file
|
@ -0,0 +1,29 @@
|
|||
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
|
||||
#ifndef __config_hh
|
||||
#define __config_hh
|
||||
|
||||
/*! @file config.hh
|
||||
@brief The Config class contains configuration options set by the user's
|
||||
scripts
|
||||
*/
|
||||
|
||||
#include "otk/ustring.hh"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace ob {
|
||||
|
||||
struct Config {
|
||||
std::vector<otk::ustring> desktop_names;
|
||||
otk::ustring theme;
|
||||
otk::ustring titlebar_layout;
|
||||
long double_click_delay;
|
||||
long drag_threshold;
|
||||
long num_desktops;
|
||||
|
||||
Config();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __config_hh
|
|
@ -99,7 +99,7 @@ Frame::Frame(Client *client)
|
|||
|
||||
applyStyle(*otk::RenderStyle::style(_client->screen()));
|
||||
|
||||
_layout = "NDITMC";
|
||||
_layout = openbox->screen(_client->screen())->config().titlebar_layout;
|
||||
|
||||
// register all of the windows with the event dispatcher
|
||||
Window *w = allWindows();
|
||||
|
|
|
@ -95,7 +95,7 @@ private:
|
|||
otk::Surface *_icon_sur;
|
||||
otk::Surface *_close_sur;
|
||||
|
||||
std::string _layout; // layout of the titlebar
|
||||
otk::ustring _layout; // layout of the titlebar
|
||||
|
||||
bool _max_press;
|
||||
bool _desk_press;
|
||||
|
|
|
@ -14,8 +14,6 @@ extern "C" {
|
|||
|
||||
namespace ob {
|
||||
|
||||
static PyObject *obdict = NULL;
|
||||
|
||||
void python_init(char *argv0)
|
||||
{
|
||||
// start the python engine
|
||||
|
@ -27,15 +25,6 @@ void python_init(char *argv0)
|
|||
PyRun_SimpleString(const_cast<char*>(("sys.path.insert(0, '" +
|
||||
otk::expandTilde("~/.openbox/python") +
|
||||
"')").c_str()));
|
||||
//PyRun_SimpleString("import ob; import otk; import config;");
|
||||
PyRun_SimpleString("import config;");
|
||||
// set up convenience global variables
|
||||
//PyRun_SimpleString("ob.openbox = ob.Openbox_instance()");
|
||||
//PyRun_SimpleString("otk.display = otk.Display_instance()");
|
||||
|
||||
// set up access to the python global variables
|
||||
PyObject *obmodule = PyImport_AddModule("config");
|
||||
obdict = PyModule_GetDict(obmodule);
|
||||
}
|
||||
|
||||
void python_destroy()
|
||||
|
@ -55,37 +44,4 @@ bool python_exec(const std::string &path)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool python_get_long(const char *name, long *value)
|
||||
{
|
||||
PyObject *val = PyDict_GetItemString(obdict, const_cast<char*>(name));
|
||||
if (!(val && PyInt_Check(val))) return false;
|
||||
|
||||
*value = PyInt_AsLong(val);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool python_get_string(const char *name, otk::ustring *value)
|
||||
{
|
||||
PyObject *val = PyDict_GetItemString(obdict, const_cast<char*>(name));
|
||||
if (!(val && PyString_Check(val))) return false;
|
||||
|
||||
*value = PyString_AsString(val);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool python_get_stringlist(const char *name, std::vector<otk::ustring> *value)
|
||||
{
|
||||
PyObject *val = PyDict_GetItemString(obdict, const_cast<char*>(name));
|
||||
if (!(val && PyList_Check(val))) return false;
|
||||
|
||||
value->clear();
|
||||
|
||||
for (int i = 0, end = PyList_Size(val); i < end; ++i) {
|
||||
PyObject *str = PyList_GetItem(val, i);
|
||||
if (PyString_Check(str))
|
||||
value->push_back(PyString_AsString(str));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -233,10 +233,6 @@ void python_init(char *argv0);
|
|||
void python_destroy();
|
||||
bool python_exec(const std::string &path);
|
||||
|
||||
bool python_get_long(const char *name, long *value);
|
||||
bool python_get_string(const char *name, otk::ustring *value);
|
||||
bool python_get_stringlist(const char *name, std::vector<otk::ustring> *value);
|
||||
|
||||
#endif // SWIG
|
||||
|
||||
}
|
||||
|
|
|
@ -66,21 +66,8 @@ Screen::Screen(int screen)
|
|||
XDefineCursor(**otk::display, _info->rootWindow(),
|
||||
openbox->cursors().session);
|
||||
|
||||
// XXX: initialize the screen's style
|
||||
/*
|
||||
otk::ustring stylepath;
|
||||
python_get_string("THEME", &stylepath);
|
||||
otk::Configuration sconfig(false);
|
||||
sconfig.setFile(otk::expandTilde(stylepath.c_str()));
|
||||
if (!sconfig.load()) {
|
||||
sconfig.setFile(otk::expandTilde(DEFAULTSTYLE));
|
||||
if (!sconfig.load()) {
|
||||
printf(_("Unable to load default style: %s. Aborting.\n"), DEFAULTSTYLE);
|
||||
::exit(1);
|
||||
}
|
||||
}
|
||||
_style.load(sconfig);
|
||||
*/
|
||||
// initialize the screen's style
|
||||
otk::RenderStyle::setStyle(_number, _config.theme);
|
||||
otk::display->renderControl(_number)->
|
||||
drawRoot(*otk::RenderStyle::style(_number)->rootColor());
|
||||
|
||||
|
@ -95,19 +82,15 @@ Screen::Screen(int screen)
|
|||
otk::Property::atoms.cardinal, geometry, 2);
|
||||
|
||||
// Set the net_desktop_names property
|
||||
std::vector<otk::ustring> names;
|
||||
python_get_stringlist("DESKTOP_NAMES", &names);
|
||||
otk::Property::set(_info->rootWindow(),
|
||||
otk::Property::atoms.net_desktop_names,
|
||||
otk::Property::utf8, names);
|
||||
otk::Property::utf8, _config.desktop_names);
|
||||
// the above set() will cause the updateDesktopNames to fire right away so
|
||||
// we have a list of desktop names
|
||||
|
||||
_desktop = 0;
|
||||
|
||||
if (!python_get_long("NUMBER_OF_DESKTOPS", (long*)&_num_desktops))
|
||||
_num_desktops = 1;
|
||||
changeNumDesktops(_num_desktops); // set the hint
|
||||
changeNumDesktops(_config.num_desktops); // set the hint
|
||||
|
||||
changeDesktop(0); // set the hint
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ extern "C" {
|
|||
#include <X11/Xlib.h>
|
||||
}
|
||||
|
||||
#include "config.hh"
|
||||
#include "otk/strut.hh"
|
||||
#include "otk/rect.hh"
|
||||
#include "otk/screeninfo.hh"
|
||||
|
@ -68,6 +69,9 @@ private:
|
|||
//! Information about this screen
|
||||
const otk::ScreenInfo *_info;
|
||||
|
||||
//! Configuration options from the user scripts
|
||||
Config _config;
|
||||
|
||||
//! Area usable for placement etc (total - struts), one per desktop,
|
||||
//! plus one extra for windows on all desktops
|
||||
RectList _area;
|
||||
|
@ -159,6 +163,10 @@ public:
|
|||
used.
|
||||
*/
|
||||
inline bool managed() const { return _managed; }
|
||||
|
||||
//! Returns the config options set by the user scripts
|
||||
const Config& config() const { return _config; }
|
||||
|
||||
//! An offscreen window which gets focus when nothing else has it
|
||||
inline Window focuswindow() const { return _focuswindow; }
|
||||
//! Returns the desktop being displayed
|
||||
|
@ -176,6 +184,8 @@ public:
|
|||
*/
|
||||
const otk::Rect& area(unsigned int desktop) const;
|
||||
|
||||
//! Gives the layout of how the desktops are being displayed, the number of
|
||||
//! rows and columns etc.
|
||||
const DesktopLayout& desktopLayout() const { return _layout; }
|
||||
|
||||
//! Shows and focuses the desktop and hides all the client windows, or
|
||||
|
|
|
@ -48,6 +48,9 @@
|
|||
// do this through events
|
||||
%ignore ob::Screen::showDesktop(bool);
|
||||
|
||||
%ignore ob::Screen::managed;
|
||||
%ignore ob::Screen::config;
|
||||
|
||||
%import "otk.i"
|
||||
|
||||
%import "actions.hh"
|
||||
|
|
Loading…
Reference in a new issue