omg, fat commit
pulled the style crap out of screen, i think the reconfigure case needs to be handled still. moved util and config into otk, changed everything else accordingly. code compiles and runs
This commit is contained in:
parent
35fcb62ddd
commit
37be3ef924
9 changed files with 87 additions and 400 deletions
|
@ -15,8 +15,8 @@ bin_PROGRAMS= openbox3
|
|||
|
||||
openbox3_LDADD=../otk/libotk.a @LIBINTL@
|
||||
|
||||
openbox3_SOURCES= client.cc configuration.cc screen.cc openbox.cc \
|
||||
util.cc bbwindow.cc workspace.cc blackbox.cc \
|
||||
openbox3_SOURCES= client.cc screen.cc openbox.cc \
|
||||
bbwindow.cc workspace.cc blackbox.cc \
|
||||
main.cc xeventhandler.cc
|
||||
|
||||
MAINTAINERCLEANFILES= Makefile.in
|
||||
|
|
|
@ -59,7 +59,7 @@ using std::string;
|
|||
#include "basedisplay.hh"
|
||||
#include "gccache.hh"
|
||||
#include "timer.hh"
|
||||
#include "util.hh"
|
||||
#include "otk/util.hh"
|
||||
|
||||
|
||||
// X error handler to handle any and all X errors while the application is
|
||||
|
|
|
@ -28,10 +28,12 @@ extern "C" {
|
|||
#include "gccache.hh"
|
||||
#include "image.hh"
|
||||
#include "screen.hh"
|
||||
#include "util.hh"
|
||||
#include "bbwindow.hh"
|
||||
#include "workspace.hh"
|
||||
|
||||
#include "otk/util.hh"
|
||||
#include "otk/style.hh"
|
||||
|
||||
using std::string;
|
||||
using std::abs;
|
||||
|
||||
|
@ -94,7 +96,7 @@ BlackboxWindow::BlackboxWindow(Blackbox *b, Window w, BScreen *s) {
|
|||
flags.skip_pager = flags.fullscreen = False;
|
||||
flags.maximized = 0;
|
||||
|
||||
blackbox_attrib.workspace = window_number = BSENTINEL;
|
||||
blackbox_attrib.workspace = window_number = otk::BSENTINEL;
|
||||
|
||||
blackbox_attrib.flags = blackbox_attrib.attrib = blackbox_attrib.stack = 0l;
|
||||
blackbox_attrib.decoration = DecorNormal;
|
||||
|
@ -1830,7 +1832,7 @@ void BlackboxWindow::show(void) {
|
|||
|
||||
void BlackboxWindow::deiconify(bool reassoc, bool raise) {
|
||||
if (flags.iconic || reassoc)
|
||||
screen->reassociateWindow(this, BSENTINEL, False);
|
||||
screen->reassociateWindow(this, otk::BSENTINEL, False);
|
||||
else if (blackbox_attrib.workspace != screen->getCurrentWorkspaceID())
|
||||
return;
|
||||
|
||||
|
@ -2033,7 +2035,7 @@ void BlackboxWindow::remaximize(void) {
|
|||
void BlackboxWindow::setWorkspace(unsigned int n) {
|
||||
blackbox_attrib.flags |= AttribWorkspace;
|
||||
blackbox_attrib.workspace = n;
|
||||
if (n == BSENTINEL) { // iconified window
|
||||
if (n == otk::BSENTINEL) { // iconified window
|
||||
/*
|
||||
we set the workspace to 'all workspaces' so that taskbars will show the
|
||||
window. otherwise, it made uniconifying a window imposible without the
|
||||
|
@ -2092,7 +2094,7 @@ void BlackboxWindow::stick(void) {
|
|||
screen->getWorkspace(i)->removeWindow(this, True);
|
||||
|
||||
if (! flags.iconic)
|
||||
screen->reassociateWindow(this, BSENTINEL, True);
|
||||
screen->reassociateWindow(this, otk::BSENTINEL, True);
|
||||
// temporary fix since sticky windows suck. set the hint to what we
|
||||
// actually hold in our data.
|
||||
xatom->set(client.window, otk::OBProperty::net_wm_desktop,
|
||||
|
@ -2564,7 +2566,7 @@ void BlackboxWindow::redrawLabel(void) const {
|
|||
}
|
||||
XClearWindow(otk::OBDisplay::display, frame.label);
|
||||
|
||||
WindowStyle *style = screen->getWindowStyle();
|
||||
otk::Style *style = screen->getWindowStyle();
|
||||
|
||||
int pos = frame.bevel_w * 2;
|
||||
style->doJustify(client.title.c_str(), pos, frame.label_w, frame.bevel_w * 4);
|
||||
|
@ -2627,7 +2629,7 @@ void BlackboxWindow::redrawIconifyButton(bool pressed) const {
|
|||
otk::BPen pen((flags.focused) ? screen->getWindowStyle()->b_pic_focus :
|
||||
screen->getWindowStyle()->b_pic_unfocus);
|
||||
|
||||
PixmapMask pm = screen->getWindowStyle()->icon_button;
|
||||
otk::Style::PixmapMask pm = screen->getWindowStyle()->icon_button;
|
||||
|
||||
if (screen->getWindowStyle()->icon_button.mask != None) {
|
||||
XSetClipMask(otk::OBDisplay::display, pen.gc(), pm.mask);
|
||||
|
@ -2659,7 +2661,7 @@ void BlackboxWindow::redrawMaximizeButton(bool pressed) const {
|
|||
otk::BPen pen((flags.focused) ? screen->getWindowStyle()->b_pic_focus :
|
||||
screen->getWindowStyle()->b_pic_unfocus);
|
||||
|
||||
PixmapMask pm = screen->getWindowStyle()->max_button;
|
||||
otk::Style::PixmapMask pm = screen->getWindowStyle()->max_button;
|
||||
|
||||
if (pm.mask != None) {
|
||||
XSetClipMask(otk::OBDisplay::display, pen.gc(), pm.mask);
|
||||
|
@ -2693,7 +2695,7 @@ void BlackboxWindow::redrawCloseButton(bool pressed) const {
|
|||
otk::BPen pen((flags.focused) ? screen->getWindowStyle()->b_pic_focus :
|
||||
screen->getWindowStyle()->b_pic_unfocus);
|
||||
|
||||
PixmapMask pm = screen->getWindowStyle()->close_button;
|
||||
otk::Style::PixmapMask pm = screen->getWindowStyle()->close_button;
|
||||
|
||||
if (pm.mask != None) {
|
||||
XSetClipMask(otk::OBDisplay::display, pen.gc(), pm.mask);
|
||||
|
@ -2727,7 +2729,7 @@ void BlackboxWindow::redrawStickyButton(bool pressed) const {
|
|||
otk::BPen pen((flags.focused) ? screen->getWindowStyle()->b_pic_focus :
|
||||
screen->getWindowStyle()->b_pic_unfocus);
|
||||
|
||||
PixmapMask pm = screen->getWindowStyle()->stick_button;
|
||||
otk::Style::PixmapMask pm = screen->getWindowStyle()->stick_button;
|
||||
|
||||
if (pm.mask != None) {
|
||||
XSetClipMask(otk::OBDisplay::display, pen.gc(), pm.mask);
|
||||
|
@ -3988,12 +3990,12 @@ void BlackboxWindow::changeBlackboxHints(const BlackboxHints *net) {
|
|||
* window's dimensions.
|
||||
*/
|
||||
void BlackboxWindow::upsize(void) {
|
||||
frame.bevel_w = screen->getBevelWidth();
|
||||
frame.bevel_w = screen->getWindowStyle()->getBevelWidth();
|
||||
|
||||
if (decorations & Decor_Border) {
|
||||
frame.border_w = screen->getBorderWidth();
|
||||
frame.border_w = screen->getWindowStyle()->getBorderWidth();
|
||||
if (! isTransient())
|
||||
frame.mwm_border_w = screen->getFrameWidth();
|
||||
frame.mwm_border_w = screen->getWindowSty2le()->getFrameWidth();
|
||||
else
|
||||
frame.mwm_border_w = 0;
|
||||
} else {
|
||||
|
@ -4003,7 +4005,7 @@ void BlackboxWindow::upsize(void) {
|
|||
if (decorations & Decor_Titlebar) {
|
||||
// the height of the titlebar is based upon the height of the font being
|
||||
// used to display the window's title
|
||||
WindowStyle *style = screen->getWindowStyle();
|
||||
otk::Style *style = screen->getWindowStyle();
|
||||
frame.title_h = style->font->height() + (frame.bevel_w * 2) + 2;
|
||||
|
||||
frame.label_h = frame.title_h - (frame.bevel_w * 2);
|
||||
|
@ -4026,7 +4028,7 @@ void BlackboxWindow::upsize(void) {
|
|||
|
||||
if (decorations & Decor_Handle) {
|
||||
frame.grip_w = frame.button_w * 2;
|
||||
frame.handle_h = screen->getHandleWidth();
|
||||
frame.handle_h = screen->getWindowStyle()->getHandleWidth();
|
||||
|
||||
// set the bottom frame margin
|
||||
frame.margin.bottom = frame.border_w + frame.handle_h +
|
||||
|
@ -4157,32 +4159,6 @@ void BlackboxWindow::constrain(Corner anchor,
|
|||
}
|
||||
|
||||
|
||||
void WindowStyle::doJustify(const std::string &text, int &start_pos,
|
||||
unsigned int max_length,
|
||||
unsigned int modifier) const {
|
||||
size_t text_len = text.size();
|
||||
unsigned int length;
|
||||
|
||||
do {
|
||||
length = font->measureString(string(text, 0, text_len)) + modifier;
|
||||
} while (length > max_length && text_len-- > 0);
|
||||
|
||||
switch (justify) {
|
||||
case RightJustify:
|
||||
start_pos += max_length - length;
|
||||
break;
|
||||
|
||||
case CenterJustify:
|
||||
start_pos += (max_length - length) / 2;
|
||||
break;
|
||||
|
||||
case LeftJustify:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BWindowGroup::BWindowGroup(Blackbox *b, Window _group)
|
||||
: blackbox(b), group(_group) {
|
||||
XWindowAttributes wattrib;
|
||||
|
|
|
@ -17,7 +17,7 @@ extern "C" {
|
|||
#include "otk/rect.hh"
|
||||
#include "otk/strut.hh"
|
||||
#include "blackbox.hh"
|
||||
#include "util.hh"
|
||||
#include "otk/util.hh"
|
||||
|
||||
#define MwmHintsFunctions (1l << 0)
|
||||
#define MwmHintsDecorations (1l << 1)
|
||||
|
|
|
@ -80,7 +80,7 @@ using std::string;
|
|||
#include "otk/image.hh"
|
||||
#include "otk/assassin.hh"
|
||||
#include "screen.hh"
|
||||
#include "util.hh"
|
||||
#include "otk/util.hh"
|
||||
#include "bbwindow.hh"
|
||||
#include "workspace.hh"
|
||||
|
||||
|
@ -102,12 +102,12 @@ Blackbox::Blackbox(int argc, char **m_argv, char *rc)
|
|||
argv = m_argv;
|
||||
|
||||
// try to make sure the ~/.openbox directory exists
|
||||
mkdir(expandTilde("~/.openbox").c_str(), S_IREAD | S_IWRITE | S_IEXEC |
|
||||
mkdir(otk::expandTilde("~/.openbox").c_str(), S_IREAD | S_IWRITE | S_IEXEC |
|
||||
S_IRGRP | S_IWGRP | S_IXGRP |
|
||||
S_IROTH | S_IWOTH | S_IXOTH);
|
||||
|
||||
if (! rc) rc = "~/.openbox/rc3";
|
||||
rc_file = expandTilde(rc);
|
||||
rc_file = otk::expandTilde(rc);
|
||||
config.setFile(rc_file);
|
||||
|
||||
no_focus = False;
|
||||
|
@ -1062,7 +1062,7 @@ void Blackbox::load_rc(void) {
|
|||
else if (resource.colors_per_channel > 6) resource.colors_per_channel = 6;
|
||||
|
||||
if (config.getValue("session.styleFile", s))
|
||||
resource.style_file = expandTilde(s);
|
||||
resource.style_file = otk::expandTilde(s);
|
||||
else
|
||||
resource.style_file = DEFAULTSTYLE;
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ extern "C" {
|
|||
#include "otk/timer.hh"
|
||||
#include "otk/property.hh"
|
||||
#include "openbox.hh"
|
||||
#include "configuration.hh"
|
||||
#include "otk/configuration.hh"
|
||||
#include "timer.hh"
|
||||
|
||||
#define AttribShaded (1l << 0)
|
||||
|
@ -111,7 +111,7 @@ private:
|
|||
BScreen *active_screen;
|
||||
BlackboxWindow *focused_window, *changing_window;
|
||||
otk::OBTimer *timer;
|
||||
Configuration config;
|
||||
otk::Configuration config;
|
||||
otk::OBProperty *xatom;
|
||||
|
||||
bool no_focus, reconfigure_wait;
|
||||
|
@ -163,7 +163,7 @@ public:
|
|||
inline BlackboxWindow *getFocusedWindow(void) { return focused_window; }
|
||||
inline BlackboxWindow *getChangingWindow(void) { return changing_window; }
|
||||
|
||||
inline Configuration *getConfig() { return &config; }
|
||||
inline otk::Configuration *getConfig() { return &config; }
|
||||
inline const Time &getDoubleClickInterval(void) const
|
||||
{ return resource.double_click_interval; }
|
||||
inline const Time &getLastTime(void) const { return last_time; }
|
||||
|
|
332
src/screen.cc
332
src/screen.cc
|
@ -59,11 +59,10 @@ using std::string;
|
|||
#include "otk/gccache.hh"
|
||||
#include "otk/image.hh"
|
||||
#include "otk/assassin.hh"
|
||||
#include "otk/util.hh"
|
||||
#include "openbox.hh"
|
||||
#include "util.hh"
|
||||
#include "bbwindow.hh"
|
||||
#include "workspace.hh"
|
||||
#include "util.hh"
|
||||
|
||||
#ifndef FONT_ELEMENT_SIZE
|
||||
#define FONT_ELEMENT_SIZE 50
|
||||
|
@ -87,7 +86,7 @@ static int anotherWMRunning(Display *display, XErrorEvent *) {
|
|||
|
||||
BScreen::BScreen(Blackbox *bb, unsigned int scrn) : ScreenInfo(scrn) {
|
||||
blackbox = bb;
|
||||
screenstr = "session.screen" + itostring(scrn) + '.';
|
||||
screenstr = "session.screen" + otk::itostring(scrn) + '.';
|
||||
config = blackbox->getConfig();
|
||||
xatom = blackbox->getXAtom();
|
||||
|
||||
|
@ -139,6 +138,10 @@ BScreen::BScreen(Blackbox *bb, unsigned int scrn) : ScreenInfo(scrn) {
|
|||
root_colormap_installed = True;
|
||||
|
||||
load_rc();
|
||||
|
||||
// XXX: ugh
|
||||
resource.wstyle.setImageControl(image_control);
|
||||
resource.wstyle.setScreenNumber(scrn);
|
||||
LoadStyle();
|
||||
|
||||
XGCValues gcv;
|
||||
|
@ -150,8 +153,8 @@ BScreen::BScreen(Blackbox *bb, unsigned int scrn) : ScreenInfo(scrn) {
|
|||
GCForeground | GCFunction | GCSubwindowMode, &gcv);
|
||||
|
||||
const char *s = "0: 0000 x 0: 0000";
|
||||
geom_w = resource.wstyle.font->measureString(s) + resource.bevel_width * 2;
|
||||
geom_h = resource.wstyle.font->height() + resource.bevel_width * 2;
|
||||
geom_w = resource.wstyle.font->measureString(s) + resource.wstyle.bevel_width * 2;
|
||||
geom_h = resource.wstyle.font->height() + resource.wstyle.bevel_width * 2;
|
||||
|
||||
XSetWindowAttributes attrib;
|
||||
unsigned long mask = CWBorderPixel | CWColormap | CWSaveUnder;
|
||||
|
@ -159,8 +162,10 @@ BScreen::BScreen(Blackbox *bb, unsigned int scrn) : ScreenInfo(scrn) {
|
|||
attrib.colormap = getColormap();
|
||||
attrib.save_under = True;
|
||||
|
||||
// XXX -- move this geom_* crap out of here
|
||||
|
||||
geom_window = XCreateWindow(otk::OBDisplay::display, getRootWindow(),
|
||||
0, 0, geom_w, geom_h, resource.border_width,
|
||||
0, 0, geom_w, geom_h, resource.wstyle.border_width,
|
||||
getDepth(), InputOutput, getVisual(),
|
||||
mask, &attrib);
|
||||
geom_visible = False;
|
||||
|
@ -188,6 +193,9 @@ BScreen::BScreen(Blackbox *bb, unsigned int scrn) : ScreenInfo(scrn) {
|
|||
Workspace *wkspc = new Workspace(this, workspacesList.size());
|
||||
workspacesList.push_back(wkspc);
|
||||
}
|
||||
|
||||
// /GEOM_PIXMAP
|
||||
|
||||
saveWorkspaceNames();
|
||||
|
||||
updateNetizenWorkspaceCount();
|
||||
|
@ -272,26 +280,31 @@ BScreen::~BScreen(void) {
|
|||
|
||||
delete image_control;
|
||||
|
||||
if (resource.wstyle.font)
|
||||
delete resource.wstyle.font;
|
||||
|
||||
if (resource.wstyle.close_button.mask != None)
|
||||
XFreePixmap(otk::OBDisplay::display, resource.wstyle.close_button.mask);
|
||||
if (resource.wstyle.max_button.mask != None)
|
||||
XFreePixmap(otk::OBDisplay::display, resource.wstyle.max_button.mask);
|
||||
if (resource.wstyle.icon_button.mask != None)
|
||||
XFreePixmap(otk::OBDisplay::display, resource.wstyle.icon_button.mask);
|
||||
if (resource.wstyle.stick_button.mask != None)
|
||||
XFreePixmap(otk::OBDisplay::display, resource.wstyle.stick_button.mask);
|
||||
|
||||
resource.wstyle.max_button.mask = resource.wstyle.close_button.mask =
|
||||
resource.wstyle.icon_button.mask =
|
||||
resource.wstyle.stick_button.mask = None;
|
||||
// delete style
|
||||
|
||||
XFreeGC(otk::OBDisplay::display, opGC);
|
||||
}
|
||||
|
||||
|
||||
void BScreen::LoadStyle(void) {
|
||||
otk::Configuration style_conf(False);
|
||||
|
||||
const char *sfile = blackbox->getStyleFilename();
|
||||
if (sfile != NULL) {
|
||||
style_conf.setFile(sfile);
|
||||
if (! style_conf.load()) {
|
||||
style_conf.setFile(DEFAULTSTYLE);
|
||||
if (! style_conf.load())
|
||||
style_conf.create(); // hardcoded default values will be used.
|
||||
}
|
||||
}
|
||||
|
||||
// merge in the rc file
|
||||
style_conf.merge(config->file(), True);
|
||||
|
||||
resource.wstyle.load(style_conf);
|
||||
}
|
||||
|
||||
void BScreen::saveSloppyFocus(bool s) {
|
||||
resource.sloppy_focus = s;
|
||||
|
||||
|
@ -744,8 +757,8 @@ void BScreen::reconfigure(void) {
|
|||
|
||||
const char *s = "0: 0000 x 0: 0000";
|
||||
|
||||
geom_w = resource.wstyle.font->measureString(s) + resource.bevel_width * 2;
|
||||
geom_h = resource.wstyle.font->height() + resource.bevel_width * 2;
|
||||
geom_w = resource.wstyle.font->measureString(s) + resource.wstyle.bevel_width * 2;
|
||||
geom_h = resource.wstyle.font->height() + resource.wstyle.bevel_width * 2;
|
||||
|
||||
otk::BTexture* texture = &(resource.wstyle.l_focus);
|
||||
geom_pixmap = texture->render(geom_w, geom_h, geom_pixmap);
|
||||
|
@ -761,9 +774,9 @@ void BScreen::reconfigure(void) {
|
|||
geom_window, geom_pixmap);
|
||||
|
||||
XSetWindowBorderWidth(otk::OBDisplay::display, geom_window,
|
||||
resource.border_width);
|
||||
resource.wstyle.border_width);
|
||||
XSetWindowBorder(otk::OBDisplay::display, geom_window,
|
||||
resource.border_color.pixel());
|
||||
resource.wstyle.border_color.pixel());
|
||||
|
||||
typedef std::vector<int> SubList;
|
||||
SubList remember_subs;
|
||||
|
@ -784,150 +797,11 @@ void BScreen::reconfigure(void) {
|
|||
}
|
||||
|
||||
|
||||
void BScreen::LoadStyle(void) {
|
||||
Configuration style(False);
|
||||
|
||||
const char *sfile = blackbox->getStyleFilename();
|
||||
if (sfile != NULL) {
|
||||
style.setFile(sfile);
|
||||
if (! style.load()) {
|
||||
style.setFile(DEFAULTSTYLE);
|
||||
if (! style.load())
|
||||
style.create(); // hardcoded default values will be used.
|
||||
}
|
||||
}
|
||||
|
||||
// merge in the rc file
|
||||
style.merge(config->file(), True);
|
||||
|
||||
string s;
|
||||
|
||||
// load fonts/fontsets
|
||||
if (resource.wstyle.font)
|
||||
delete resource.wstyle.font;
|
||||
|
||||
resource.wstyle.font = readDatabaseFont("window.", style);
|
||||
|
||||
// load window config
|
||||
resource.wstyle.t_focus =
|
||||
readDatabaseTexture("window.title.focus", "white", style);
|
||||
resource.wstyle.t_unfocus =
|
||||
readDatabaseTexture("window.title.unfocus", "black", style);
|
||||
resource.wstyle.l_focus =
|
||||
readDatabaseTexture("window.label.focus", "white", style);
|
||||
resource.wstyle.l_unfocus =
|
||||
readDatabaseTexture("window.label.unfocus", "black", style);
|
||||
resource.wstyle.h_focus =
|
||||
readDatabaseTexture("window.handle.focus", "white", style);
|
||||
resource.wstyle.h_unfocus =
|
||||
readDatabaseTexture("window.handle.unfocus", "black", style);
|
||||
resource.wstyle.g_focus =
|
||||
readDatabaseTexture("window.grip.focus", "white", style);
|
||||
resource.wstyle.g_unfocus =
|
||||
readDatabaseTexture("window.grip.unfocus", "black", style);
|
||||
resource.wstyle.b_focus =
|
||||
readDatabaseTexture("window.button.focus", "white", style);
|
||||
resource.wstyle.b_unfocus =
|
||||
readDatabaseTexture("window.button.unfocus", "black", style);
|
||||
resource.wstyle.b_pressed =
|
||||
readDatabaseTexture("window.button.pressed", "black", style);
|
||||
|
||||
//if neither of these can be found, we will use the previous resource
|
||||
resource.wstyle.b_pressed_focus =
|
||||
readDatabaseTexture("window.button.pressed.focus", "black", style, true);
|
||||
resource.wstyle.b_pressed_unfocus =
|
||||
readDatabaseTexture("window.button.pressed.unfocus", "black", style, true);
|
||||
|
||||
if (resource.wstyle.close_button.mask != None)
|
||||
XFreePixmap(otk::OBDisplay::display, resource.wstyle.close_button.mask);
|
||||
if (resource.wstyle.max_button.mask != None)
|
||||
XFreePixmap(otk::OBDisplay::display, resource.wstyle.max_button.mask);
|
||||
if (resource.wstyle.icon_button.mask != None)
|
||||
XFreePixmap(otk::OBDisplay::display, resource.wstyle.icon_button.mask);
|
||||
if (resource.wstyle.stick_button.mask != None)
|
||||
XFreePixmap(otk::OBDisplay::display, resource.wstyle.stick_button.mask);
|
||||
|
||||
resource.wstyle.close_button.mask = resource.wstyle.max_button.mask =
|
||||
resource.wstyle.icon_button.mask =
|
||||
resource.wstyle.icon_button.mask = None;
|
||||
|
||||
readDatabaseMask("window.button.close.mask", resource.wstyle.close_button,
|
||||
style);
|
||||
readDatabaseMask("window.button.max.mask", resource.wstyle.max_button,
|
||||
style);
|
||||
readDatabaseMask("window.button.icon.mask", resource.wstyle.icon_button,
|
||||
style);
|
||||
readDatabaseMask("window.button.stick.mask", resource.wstyle.stick_button,
|
||||
style);
|
||||
|
||||
// we create the window.frame texture by hand because it exists only to
|
||||
// make the code cleaner and is not actually used for display
|
||||
otk::BColor color = readDatabaseColor("window.frame.focusColor", "white",
|
||||
style);
|
||||
resource.wstyle.f_focus = otk::BTexture("solid flat", getScreenNumber(),
|
||||
image_control);
|
||||
resource.wstyle.f_focus.setColor(color);
|
||||
|
||||
color = readDatabaseColor("window.frame.unfocusColor", "white", style);
|
||||
resource.wstyle.f_unfocus = otk::BTexture("solid flat", getScreenNumber(),
|
||||
image_control);
|
||||
resource.wstyle.f_unfocus.setColor(color);
|
||||
|
||||
resource.wstyle.l_text_focus =
|
||||
readDatabaseColor("window.label.focus.textColor", "black", style);
|
||||
resource.wstyle.l_text_unfocus =
|
||||
readDatabaseColor("window.label.unfocus.textColor", "white", style);
|
||||
resource.wstyle.b_pic_focus =
|
||||
readDatabaseColor("window.button.focus.picColor", "black", style);
|
||||
resource.wstyle.b_pic_unfocus =
|
||||
readDatabaseColor("window.button.unfocus.picColor", "white", style);
|
||||
|
||||
resource.wstyle.justify = LeftJustify;
|
||||
if (style.getValue("window.justify", s)) {
|
||||
if (s == "right" || s == "Right")
|
||||
resource.wstyle.justify = RightJustify;
|
||||
else if (s == "center" || s == "Center")
|
||||
resource.wstyle.justify = CenterJustify;
|
||||
}
|
||||
|
||||
// sanity checks
|
||||
if (resource.wstyle.t_focus.texture() == otk::BTexture::Parent_Relative)
|
||||
resource.wstyle.t_focus = resource.wstyle.f_focus;
|
||||
if (resource.wstyle.t_unfocus.texture() == otk::BTexture::Parent_Relative)
|
||||
resource.wstyle.t_unfocus = resource.wstyle.f_unfocus;
|
||||
if (resource.wstyle.h_focus.texture() == otk::BTexture::Parent_Relative)
|
||||
resource.wstyle.h_focus = resource.wstyle.f_focus;
|
||||
if (resource.wstyle.h_unfocus.texture() == otk::BTexture::Parent_Relative)
|
||||
resource.wstyle.h_unfocus = resource.wstyle.f_unfocus;
|
||||
|
||||
resource.border_color =
|
||||
readDatabaseColor("borderColor", "black", style);
|
||||
|
||||
// load bevel, border and handle widths
|
||||
if (! style.getValue("handleWidth", resource.handle_width) ||
|
||||
resource.handle_width > (getWidth() / 2) || resource.handle_width == 0)
|
||||
resource.handle_width = 6;
|
||||
|
||||
if (! style.getValue("borderWidth", resource.border_width))
|
||||
resource.border_width = 1;
|
||||
|
||||
if (! style.getValue("bevelWidth", resource.bevel_width) ||
|
||||
resource.bevel_width > (getWidth() / 2) || resource.bevel_width == 0)
|
||||
resource.bevel_width = 3;
|
||||
|
||||
if (! style.getValue("frameWidth", resource.frame_width) ||
|
||||
resource.frame_width > (getWidth() / 2))
|
||||
resource.frame_width = resource.bevel_width;
|
||||
|
||||
if (style.getValue("rootCommand", s))
|
||||
bexec(s, displayString());
|
||||
}
|
||||
|
||||
|
||||
void BScreen::addIcon(BlackboxWindow *w) {
|
||||
if (! w) return;
|
||||
|
||||
w->setWorkspace(BSENTINEL);
|
||||
w->setWorkspace(otk::BSENTINEL);
|
||||
w->setWindowNumber(iconList.size());
|
||||
|
||||
iconList.push_back(w);
|
||||
|
@ -1214,8 +1088,8 @@ void BScreen::unmanageWindow(BlackboxWindow *w, bool remap) {
|
|||
// Remove the modality so that its parent won't try to re-focus the window
|
||||
if (w->isModal()) w->setModal(False);
|
||||
|
||||
if (w->getWorkspaceNumber() != BSENTINEL &&
|
||||
w->getWindowNumber() != BSENTINEL) {
|
||||
if (w->getWorkspaceNumber() != otk::BSENTINEL &&
|
||||
w->getWindowNumber() != otk::BSENTINEL) {
|
||||
getWorkspace(w->getWorkspaceNumber())->removeWindow(w);
|
||||
if (w->isStuck()) {
|
||||
for (unsigned int i = 0; i < getNumberOfWorkspaces(); ++i)
|
||||
|
@ -1357,7 +1231,7 @@ void BScreen::reassociateWindow(BlackboxWindow *w, unsigned int wkspc_id,
|
|||
bool ignore_sticky) {
|
||||
if (! w) return;
|
||||
|
||||
if (wkspc_id == BSENTINEL)
|
||||
if (wkspc_id == otk::BSENTINEL)
|
||||
wkspc_id = current_workspace->getID();
|
||||
|
||||
if (w->getWorkspaceNumber() == wkspc_id)
|
||||
|
@ -1482,7 +1356,7 @@ void BScreen::showPosition(int x, int y) {
|
|||
XClearWindow(otk::OBDisplay::display, geom_window);
|
||||
|
||||
resource.wstyle.font->drawString(geom_window,
|
||||
resource.bevel_width, resource.bevel_width,
|
||||
resource.wstyle.bevel_width, resource.wstyle.bevel_width,
|
||||
resource.wstyle.l_text_focus,
|
||||
label);
|
||||
}
|
||||
|
@ -1506,7 +1380,7 @@ void BScreen::showGeometry(unsigned int gx, unsigned int gy) {
|
|||
XClearWindow(otk::OBDisplay::display, geom_window);
|
||||
|
||||
resource.wstyle.font->drawString(geom_window,
|
||||
resource.bevel_width, resource.bevel_width,
|
||||
resource.wstyle.bevel_width, resource.wstyle.bevel_width,
|
||||
resource.wstyle.l_text_focus,
|
||||
label);
|
||||
}
|
||||
|
@ -1678,122 +1552,4 @@ void BScreen::toggleFocusModel(FocusModel model) {
|
|||
std::mem_fun(&BlackboxWindow::grabButtons));
|
||||
}
|
||||
|
||||
void BScreen::readDatabaseMask(const string &rname, PixmapMask &pixmapMask,
|
||||
const Configuration &style) {
|
||||
string s;
|
||||
int hx, hy; //ignored
|
||||
int ret = BitmapOpenFailed; //default to failure.
|
||||
|
||||
if (style.getValue(rname, s))
|
||||
{
|
||||
if (s[0] != '/' && s[0] != '~')
|
||||
{
|
||||
std::string xbmFile = std::string("~/.openbox/buttons/") + s;
|
||||
ret = XReadBitmapFile(otk::OBDisplay::display, getRootWindow(),
|
||||
expandTilde(xbmFile).c_str(), &pixmapMask.w,
|
||||
&pixmapMask.h, &pixmapMask.mask, &hx, &hy);
|
||||
} else
|
||||
ret = XReadBitmapFile(otk::OBDisplay::display, getRootWindow(),
|
||||
expandTilde(s).c_str(), &pixmapMask.w,
|
||||
&pixmapMask.h, &pixmapMask.mask, &hx, &hy);
|
||||
|
||||
if (ret == BitmapSuccess)
|
||||
return;
|
||||
}
|
||||
|
||||
pixmapMask.mask = None;
|
||||
pixmapMask.w = pixmapMask.h = 0;
|
||||
}
|
||||
|
||||
otk::BTexture BScreen::readDatabaseTexture(const string &rname,
|
||||
const string &default_color,
|
||||
const Configuration &style,
|
||||
bool allowNoTexture) {
|
||||
otk::BTexture texture;
|
||||
string s;
|
||||
|
||||
if (style.getValue(rname, s))
|
||||
texture = otk::BTexture(s);
|
||||
else if (allowNoTexture) //no default
|
||||
texture.setTexture(otk::BTexture::NoTexture);
|
||||
else
|
||||
texture.setTexture(otk::BTexture::Solid | otk::BTexture::Flat);
|
||||
|
||||
// associate this texture with this screen
|
||||
texture.setScreen(getScreenNumber());
|
||||
texture.setImageControl(image_control);
|
||||
|
||||
if (texture.texture() != otk::BTexture::NoTexture) {
|
||||
texture.setColor(readDatabaseColor(rname + ".color", default_color,
|
||||
style));
|
||||
texture.setColorTo(readDatabaseColor(rname + ".colorTo", default_color,
|
||||
style));
|
||||
texture.setBorderColor(readDatabaseColor(rname + ".borderColor",
|
||||
default_color, style));
|
||||
}
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
|
||||
otk::BColor BScreen::readDatabaseColor(const string &rname,
|
||||
const string &default_color,
|
||||
const Configuration &style) {
|
||||
otk::BColor color;
|
||||
string s;
|
||||
if (style.getValue(rname, s))
|
||||
color = otk::BColor(s, getScreenNumber());
|
||||
else
|
||||
color = otk::BColor(default_color, getScreenNumber());
|
||||
return color;
|
||||
}
|
||||
|
||||
|
||||
otk::BFont *BScreen::readDatabaseFont(const string &rbasename,
|
||||
const Configuration &style) {
|
||||
string fontname;
|
||||
|
||||
string s;
|
||||
|
||||
int i;
|
||||
if (style.getValue(rbasename + "xft.font", s) &&
|
||||
style.getValue(rbasename + "xft.size", i)) {
|
||||
string family = s;
|
||||
bool bold = False;
|
||||
bool italic = False;
|
||||
bool dropShadow = False;
|
||||
|
||||
if (style.getValue(rbasename + "xft.flags", s)) {
|
||||
if (s.find("bold") != string::npos)
|
||||
bold = True;
|
||||
if (s.find("italic") != string::npos)
|
||||
italic = True;
|
||||
if (s.find("shadow") != string::npos)
|
||||
dropShadow = True;
|
||||
}
|
||||
|
||||
unsigned char offset = 1;
|
||||
if (style.getValue(rbasename + "xft.shadow.offset", s)) {
|
||||
offset = atoi(s.c_str()); //doesn't detect errors
|
||||
if (offset > CHAR_MAX)
|
||||
offset = 1;
|
||||
}
|
||||
|
||||
unsigned char tint = 0x40;
|
||||
if (style.getValue(rbasename + "xft.shadow.tint", s)) {
|
||||
tint = atoi(s.c_str());
|
||||
}
|
||||
|
||||
|
||||
otk::BFont *b = new otk::BFont(getScreenNumber(), family, i, bold, italic,
|
||||
dropShadow && resource.shadow_fonts,
|
||||
offset, tint, resource.aa_fonts);
|
||||
if (b->valid())
|
||||
return b;
|
||||
delete b;
|
||||
}
|
||||
|
||||
exit(2); // can't continue without a font
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,35 +26,14 @@ extern "C" {
|
|||
#include "otk/image.hh"
|
||||
#include "otk/strut.hh"
|
||||
#include "otk/property.hh"
|
||||
#include "otk/configuration.hh"
|
||||
#include "otk/style.hh"
|
||||
#include "timer.hh"
|
||||
#include "workspace.hh"
|
||||
#include "blackbox.hh"
|
||||
|
||||
namespace ob {
|
||||
|
||||
enum TextJustify { LeftJustify = 1, RightJustify, CenterJustify };
|
||||
|
||||
struct PixmapMask {
|
||||
Pixmap mask;
|
||||
unsigned int w, h;
|
||||
};
|
||||
|
||||
struct WindowStyle {
|
||||
otk::BColor l_text_focus, l_text_unfocus, b_pic_focus,
|
||||
b_pic_unfocus;
|
||||
otk::BTexture f_focus, f_unfocus, t_focus, t_unfocus, l_focus, l_unfocus,
|
||||
h_focus, h_unfocus, b_focus, b_unfocus, b_pressed, b_pressed_focus,
|
||||
b_pressed_unfocus, g_focus, g_unfocus;
|
||||
|
||||
PixmapMask close_button, max_button, icon_button, stick_button;
|
||||
otk::BFont *font;
|
||||
|
||||
TextJustify justify;
|
||||
|
||||
void doJustify(const std::string &text, int &start_pos,
|
||||
unsigned int max_length, unsigned int modifier) const;
|
||||
};
|
||||
|
||||
class BScreen : public otk::ScreenInfo {
|
||||
private:
|
||||
bool root_colormap_installed, managed, geom_visible;
|
||||
|
@ -64,7 +43,7 @@ private:
|
|||
|
||||
Blackbox *blackbox;
|
||||
otk::BImageControl *image_control;
|
||||
Configuration *config;
|
||||
otk::Configuration *config;
|
||||
otk::OBProperty *xatom;
|
||||
|
||||
BlackboxWindowList iconList, windowList;
|
||||
|
@ -88,7 +67,7 @@ private:
|
|||
WorkspaceList workspacesList;
|
||||
|
||||
struct screen_resource {
|
||||
WindowStyle wstyle;
|
||||
otk::Style wstyle;
|
||||
|
||||
bool sloppy_focus, auto_raise, auto_edge_balance, ordered_dither,
|
||||
opaque_move, full_max, focus_new, focus_last, click_raise,
|
||||
|
@ -98,15 +77,12 @@ private:
|
|||
int snap_to_windows, snap_to_edges;
|
||||
unsigned int snap_offset;
|
||||
|
||||
otk::BColor border_color;
|
||||
|
||||
unsigned int workspaces;
|
||||
int placement_policy,
|
||||
snap_threshold, row_direction, col_direction, root_scroll,
|
||||
resistance_size;
|
||||
|
||||
unsigned int handle_width, bevel_width, frame_width, border_width,
|
||||
resize_zones;
|
||||
unsigned int resize_zones;
|
||||
|
||||
std::string strftime_format;
|
||||
|
||||
|
@ -116,22 +92,6 @@ private:
|
|||
BScreen(const BScreen&);
|
||||
BScreen& operator=(const BScreen&);
|
||||
|
||||
void readDatabaseMask(const std::string &rname,
|
||||
PixmapMask &pixmapMask,
|
||||
const Configuration &style);
|
||||
|
||||
otk::BTexture readDatabaseTexture(const std::string &rname,
|
||||
const std::string &default_color,
|
||||
const Configuration &style,
|
||||
bool allowNoTexture = false);
|
||||
otk::BColor readDatabaseColor(const std::string &rname,
|
||||
const std::string &default_color,
|
||||
const Configuration &style);
|
||||
otk::BFont *readDatabaseFont(const std::string &rbasename,
|
||||
const Configuration &style);
|
||||
|
||||
void LoadStyle(void);
|
||||
|
||||
void updateWorkArea(void);
|
||||
|
||||
public:
|
||||
|
@ -144,7 +104,6 @@ public:
|
|||
enum { RowSmartPlacement = 1, ColSmartPlacement, CascadePlacement,
|
||||
UnderMousePlacement, ClickMousePlacement, LeftRight, RightLeft,
|
||||
TopBottom, BottomTop, IgnoreShaded, IgnoreMaximized };
|
||||
enum { RoundBullet = 1, TriangleBullet, SquareBullet, NoBullet };
|
||||
enum { Restart = 1, RestartOther, Exit, Shutdown, Execute, Reconfigure,
|
||||
WindowShade, WindowIconify, WindowMaximize, WindowClose, WindowRaise,
|
||||
WindowLower, WindowStick, WindowKill, SetStyle };
|
||||
|
@ -154,6 +113,8 @@ public:
|
|||
BScreen(Blackbox *bb, unsigned int scrn);
|
||||
~BScreen(void);
|
||||
|
||||
void LoadStyle(void);
|
||||
|
||||
inline bool isSloppyFocus(void) const { return resource.sloppy_focus; }
|
||||
inline bool isRootColormapInstalled(void) const
|
||||
{ return root_colormap_installed; }
|
||||
|
@ -182,21 +143,15 @@ public:
|
|||
inline const GC &getOpGC(void) const { return opGC; }
|
||||
|
||||
inline Blackbox *getBlackbox(void) { return blackbox; }
|
||||
inline otk::BColor *getBorderColor(void) { return &resource.border_color; }
|
||||
inline otk::BColor *getBorderColor(void) {
|
||||
return &resource.wstyle.border_color;
|
||||
}
|
||||
inline otk::BImageControl *getImageControl(void) { return image_control; }
|
||||
|
||||
Workspace *getWorkspace(unsigned int index) const;
|
||||
|
||||
inline Workspace *getCurrentWorkspace(void) { return current_workspace; }
|
||||
|
||||
inline unsigned int getHandleWidth(void) const
|
||||
{ return resource.handle_width; }
|
||||
inline unsigned int getBevelWidth(void) const
|
||||
{ return resource.bevel_width; }
|
||||
inline unsigned int getFrameWidth(void) const
|
||||
{ return resource.frame_width; }
|
||||
inline unsigned int getBorderWidth(void) const
|
||||
{ return resource.border_width; }
|
||||
inline unsigned int getResizeZones(void) const
|
||||
{ return resource.resize_zones; }
|
||||
inline bool getPlaceIgnoreShaded(void) const
|
||||
|
@ -258,7 +213,7 @@ public:
|
|||
{ return resource.strftime_format.c_str(); }
|
||||
void saveStrftimeFormat(const std::string& format);
|
||||
|
||||
inline WindowStyle *getWindowStyle(void) { return &resource.wstyle; }
|
||||
inline otk::Style *getWindowStyle(void) { return &resource.wstyle; }
|
||||
|
||||
BlackboxWindow *getIcon(unsigned int index);
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ using std::string;
|
|||
#include "otk/font.hh"
|
||||
#include "otk/display.hh"
|
||||
#include "screen.hh"
|
||||
#include "util.hh"
|
||||
#include "otk/util.hh"
|
||||
#include "bbwindow.hh"
|
||||
#include "workspace.hh"
|
||||
|
||||
|
@ -605,8 +605,8 @@ bool Workspace::smartPlacement(otk::Rect& win) {
|
|||
}
|
||||
|
||||
tmp.setRect(curr->frameRect().x(), curr->frameRect().y(),
|
||||
curr->frameRect().width() + screen->getBorderWidth(),
|
||||
curr->frameRect().height() + screen->getBorderWidth());
|
||||
curr->frameRect().width() + screen->getWindowStyle()->getBorderWidth(),
|
||||
curr->frameRect().height() + screen->getWindowStyle()->getBorderWidth());
|
||||
|
||||
spaces = calcSpace(tmp, spaces);
|
||||
}
|
||||
|
@ -765,7 +765,7 @@ void Workspace::placeWindow(BlackboxWindow *win) {
|
|||
|
||||
if (placed == False)
|
||||
cascadePlacement(new_win, (win->getTitleHeight() +
|
||||
screen->getBorderWidth() * 2));
|
||||
screen->getWindowStyle()->getBorderWidth() * 2));
|
||||
|
||||
if (new_win.right() > screen->availableArea().right())
|
||||
new_win.setX(screen->availableArea().left());
|
||||
|
|
Loading…
Reference in a new issue