Toolbar saves its settings as their changed
Main config's Hide Toolbar option is also saved when it is changed Removed 2 debug couts from Slit
This commit is contained in:
parent
73a3c979b3
commit
66c879bd5c
8 changed files with 282 additions and 254 deletions
|
@ -68,7 +68,7 @@ Configmenu::Configmenu(BScreen &scr) : Basemenu(scr), screen(scr)
|
|||
setItemSelected(4, screen.doFullMax());
|
||||
setItemSelected(5, screen.doFocusNew());
|
||||
setItemSelected(6, screen.doFocusLast());
|
||||
setItemSelected(7, screen.doToolbarHide());
|
||||
setItemSelected(7, screen.hideToolbar());
|
||||
}
|
||||
|
||||
Configmenu::~Configmenu(void) {
|
||||
|
@ -123,8 +123,8 @@ void Configmenu::itemSelected(int button, int index) {
|
|||
break;
|
||||
}
|
||||
case 6:{ //toggle toolbar hide
|
||||
screen.saveToolbarHide(!(screen.doToolbarHide()));
|
||||
setItemSelected(index, screen.doToolbarHide());
|
||||
screen.setHideToolbar(!screen.hideToolbar());
|
||||
setItemSelected(index, screen.hideToolbar());
|
||||
break;
|
||||
}
|
||||
} // switch
|
||||
|
|
|
@ -99,6 +99,7 @@
|
|||
#define FONT_ELEMENT_SIZE 50
|
||||
#endif // FONT_ELEMENT_SIZE
|
||||
|
||||
#include <strstream>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
|
||||
|
@ -418,7 +419,7 @@ BScreen::BScreen(Openbox &ob, int scrn, Resource &conf) : ScreenInfo(ob, scrn),
|
|||
current_workspace = workspacesList->first();
|
||||
workspacemenu->setItemSelected(2, True);
|
||||
|
||||
toolbar = new Toolbar(*this);
|
||||
toolbar = new Toolbar(*this, config);
|
||||
|
||||
#ifdef SLIT
|
||||
slit = new Slit(*this, config);
|
||||
|
@ -823,8 +824,22 @@ XFontSet BScreen::createFontSet(const char *fontname) {
|
|||
return fs;
|
||||
}
|
||||
|
||||
void BScreen::load() {
|
||||
std::ostrstream rscreen, rname, rclass;
|
||||
std::string s;
|
||||
bool b;
|
||||
long l;
|
||||
rscreen << "session.screen" << getScreenNumber() << '.' << ends;
|
||||
|
||||
rname << rscreen.str() << "hideToolbar" << ends;
|
||||
rclass << rscreen.str() << "HideToolbar" << ends;
|
||||
if (config.getValue(rname.str(), rclass.str(), b))
|
||||
resource.hide_toolbar = b;
|
||||
|
||||
}
|
||||
|
||||
void BScreen::reconfigure(void) {
|
||||
load();
|
||||
LoadStyle();
|
||||
|
||||
XGCValues gcv;
|
||||
|
@ -1543,7 +1558,7 @@ void BScreen::raiseWindows(Window *workspace_stack, int num) {
|
|||
*(session_stack + i++) = tmp->getWindowID();
|
||||
*(session_stack + i++) = rootmenu->getWindowID();
|
||||
|
||||
if (toolbar->isOnTop())
|
||||
if (toolbar->onTop())
|
||||
*(session_stack + i++) = toolbar->getWindowID();
|
||||
|
||||
#ifdef SLIT
|
||||
|
@ -2266,13 +2281,14 @@ void BScreen::hideGeometry(void) {
|
|||
}
|
||||
}
|
||||
|
||||
void BScreen::saveToolbarHide(Bool b){
|
||||
resource.toolbar_total_hide = b;
|
||||
if (toolbar != NULL){
|
||||
if (b)
|
||||
toolbar->unMapToolbar();
|
||||
void BScreen::setHideToolbar(bool b) {
|
||||
resource.hide_toolbar = b;
|
||||
if (resource.hide_toolbar)
|
||||
getToolbar()->unMapToolbar();
|
||||
else
|
||||
toolbar->mapToolbar();
|
||||
}
|
||||
|
||||
getToolbar()->mapToolbar();
|
||||
ostrstream s;
|
||||
s << "session.screen" << getScreenNumber() << ".hideToolbar" << ends;
|
||||
config.setValue(s.str(), resource.hide_toolbar ? "True" : "False");
|
||||
}
|
||||
|
||||
|
|
138
src/Screen.h
138
src/Screen.h
|
@ -132,20 +132,16 @@ private:
|
|||
ToolbarStyle tstyle;
|
||||
MenuStyle mstyle;
|
||||
|
||||
Bool toolbar_on_top, toolbar_auto_hide, sloppy_focus, auto_raise,
|
||||
Bool sloppy_focus, auto_raise,
|
||||
auto_edge_balance, image_dither, ordered_dither, opaque_move, full_max,
|
||||
focus_new, focus_last, toolbar_total_hide;
|
||||
focus_new, focus_last;
|
||||
bool hide_toolbar;
|
||||
BColor border_color;
|
||||
Resource styleconfig;
|
||||
|
||||
int workspaces, toolbar_placement, toolbar_width_percent, placement_policy,
|
||||
edge_snap_threshold, row_direction, col_direction;
|
||||
|
||||
#ifdef SLIT
|
||||
Bool slit_on_top, slit_auto_hide;
|
||||
int slit_placement, slit_direction;
|
||||
#endif // SLIT
|
||||
|
||||
unsigned int handle_width, bevel_width, frame_width, border_width;
|
||||
unsigned int zones; // number of zones to be used when alt-resizing a window
|
||||
|
||||
|
@ -171,83 +167,73 @@ protected:
|
|||
XFontSet createFontSet(const char *);
|
||||
void readDatabaseFont(const char *, const char *, XFontStruct **);
|
||||
|
||||
void InitMenu(void);
|
||||
void LoadStyle(void);
|
||||
void InitMenu();
|
||||
void LoadStyle();
|
||||
|
||||
|
||||
public:
|
||||
BScreen(Openbox &, int, Resource &);
|
||||
~BScreen(void);
|
||||
~BScreen();
|
||||
|
||||
inline const Bool &isToolbarOnTop(void) const
|
||||
{ return resource.toolbar_on_top; }
|
||||
inline const Bool &doToolbarAutoHide(void) const
|
||||
{ return resource.toolbar_auto_hide; }
|
||||
inline const Bool &doToolbarHide(void) const
|
||||
{return resource.toolbar_total_hide;}
|
||||
inline const Bool &isSloppyFocus(void) const
|
||||
inline const Bool &isSloppyFocus() const
|
||||
{ return resource.sloppy_focus; }
|
||||
inline const Bool &isRootColormapInstalled(void) const
|
||||
inline const Bool &isRootColormapInstalled() const
|
||||
{ return root_colormap_installed; }
|
||||
inline const Bool &doAutoRaise(void) const { return resource.auto_raise; }
|
||||
inline const Bool &isScreenManaged(void) const { return managed; }
|
||||
inline const Bool &doImageDither(void) const
|
||||
inline const Bool &doAutoRaise() const { return resource.auto_raise; }
|
||||
inline const Bool &isScreenManaged() const { return managed; }
|
||||
inline const Bool &doImageDither() const
|
||||
{ return resource.image_dither; }
|
||||
inline const Bool &doOrderedDither(void) const
|
||||
inline const Bool &doOrderedDither() const
|
||||
{ return resource.ordered_dither; }
|
||||
inline const Bool &doOpaqueMove(void) const { return resource.opaque_move; }
|
||||
inline const Bool &doFullMax(void) const { return resource.full_max; }
|
||||
inline const Bool &doFocusNew(void) const { return resource.focus_new; }
|
||||
inline const Bool &doFocusLast(void) const { return resource.focus_last; }
|
||||
inline const Bool &doOpaqueMove() const { return resource.opaque_move; }
|
||||
inline const Bool &doFullMax() const { return resource.full_max; }
|
||||
inline const Bool &doFocusNew() const { return resource.focus_new; }
|
||||
inline const Bool &doFocusLast() const { return resource.focus_last; }
|
||||
|
||||
inline const GC &getOpGC() const { return opGC; }
|
||||
|
||||
inline Openbox &getOpenbox(void) { return openbox; }
|
||||
inline BColor *getBorderColor(void) { return &resource.border_color; }
|
||||
inline BImageControl *getImageControl(void) { return image_control; }
|
||||
inline Rootmenu *getRootmenu(void) { return rootmenu; }
|
||||
inline Openbox &getOpenbox() { return openbox; }
|
||||
inline BColor *getBorderColor() { return &resource.border_color; }
|
||||
inline BImageControl *getImageControl() { return image_control; }
|
||||
inline Rootmenu *getRootmenu() { return rootmenu; }
|
||||
|
||||
#ifdef SLIT
|
||||
inline Slit *getSlit(void) { return slit; }
|
||||
inline Slit *getSlit() { return slit; }
|
||||
#endif // SLIT
|
||||
|
||||
inline int getWindowZones(void) const
|
||||
inline int getWindowZones() const
|
||||
{ return resource.zones; }
|
||||
inline void saveWindowZones(int z) { resource.zones = z; }
|
||||
|
||||
inline Toolbar *getToolbar(void) { return toolbar; }
|
||||
inline Toolbar *getToolbar() { return toolbar; }
|
||||
|
||||
inline Workspace *getWorkspace(int w) { return workspacesList->find(w); }
|
||||
inline Workspace *getCurrentWorkspace(void) { return current_workspace; }
|
||||
inline Workspace *getCurrentWorkspace() { return current_workspace; }
|
||||
|
||||
inline Workspacemenu *getWorkspacemenu(void) { return workspacemenu; }
|
||||
inline Workspacemenu *getWorkspacemenu() { return workspacemenu; }
|
||||
|
||||
inline const unsigned int &getHandleWidth(void) const
|
||||
inline const unsigned int &getHandleWidth() const
|
||||
{ return resource.handle_width; }
|
||||
inline const unsigned int &getBevelWidth(void) const
|
||||
inline const unsigned int &getBevelWidth() const
|
||||
{ return resource.bevel_width; }
|
||||
inline const unsigned int &getFrameWidth(void) const
|
||||
inline const unsigned int &getFrameWidth() const
|
||||
{ return resource.frame_width; }
|
||||
inline const unsigned int &getBorderWidth(void) const
|
||||
inline const unsigned int &getBorderWidth() const
|
||||
{ return resource.border_width; }
|
||||
|
||||
inline const int getCurrentWorkspaceID()
|
||||
{ return current_workspace->getWorkspaceID(); }
|
||||
inline const int getWorkspaceCount(void) { return workspacesList->count(); }
|
||||
inline const int getIconCount(void) { return iconList->count(); }
|
||||
inline const int &getNumberOfWorkspaces(void) const
|
||||
inline const int getWorkspaceCount() { return workspacesList->count(); }
|
||||
inline const int getIconCount() { return iconList->count(); }
|
||||
inline const int &getNumberOfWorkspaces() const
|
||||
{ return resource.workspaces; }
|
||||
inline const int &getToolbarPlacement(void) const
|
||||
{ return resource.toolbar_placement; }
|
||||
inline const int &getToolbarWidthPercent(void) const
|
||||
{ return resource.toolbar_width_percent; }
|
||||
inline const int &getPlacementPolicy(void) const
|
||||
inline const int &getPlacementPolicy() const
|
||||
{ return resource.placement_policy; }
|
||||
inline const int &getEdgeSnapThreshold(void) const
|
||||
inline const int &getEdgeSnapThreshold() const
|
||||
{ return resource.edge_snap_threshold; }
|
||||
inline const int &getRowPlacementDirection(void) const
|
||||
inline const int &getRowPlacementDirection() const
|
||||
{ return resource.row_direction; }
|
||||
inline const int &getColPlacementDirection(void) const
|
||||
inline const int &getColPlacementDirection() const
|
||||
{ return resource.col_direction; }
|
||||
|
||||
inline void saveRootCommand(const char *cmd) {
|
||||
|
@ -258,18 +244,13 @@ public:
|
|||
else
|
||||
resource.root_command = NULL;
|
||||
}
|
||||
inline const char *getRootCommand(void) const
|
||||
inline const char *getRootCommand() const
|
||||
{ return resource.root_command; }
|
||||
|
||||
inline void setRootColormapInstalled(Bool r) { root_colormap_installed = r; }
|
||||
inline void saveSloppyFocus(Bool s) { resource.sloppy_focus = s; }
|
||||
inline void saveAutoRaise(Bool a) { resource.auto_raise = a; }
|
||||
inline void saveWorkspaces(int w) { resource.workspaces = w; }
|
||||
inline void saveToolbarOnTop(Bool r) { resource.toolbar_on_top = r; }
|
||||
inline void saveToolbarAutoHide(Bool r) { resource.toolbar_auto_hide = r; }
|
||||
inline void saveToolbarWidthPercent(int w)
|
||||
{ resource.toolbar_width_percent = w; }
|
||||
inline void saveToolbarPlacement(int p) { resource.toolbar_placement = p; }
|
||||
inline void savePlacementPolicy(int p) { resource.placement_policy = p; }
|
||||
inline void saveRowPlacementDirection(int d) { resource.row_direction = d; }
|
||||
inline void saveColPlacementDirection(int d) { resource.col_direction = d; }
|
||||
|
@ -280,27 +261,30 @@ public:
|
|||
inline void saveFullMax(Bool f) { resource.full_max = f; }
|
||||
inline void saveFocusNew(Bool f) { resource.focus_new = f; }
|
||||
inline void saveFocusLast(Bool f) { resource.focus_last = f; }
|
||||
inline void iconUpdate(void) { iconmenu->update(); }
|
||||
inline void iconUpdate() { iconmenu->update(); }
|
||||
#ifdef HAVE_STRFTIME
|
||||
inline char *getStrftimeFormat(void) { return resource.strftime_format; }
|
||||
inline char *getStrftimeFormat() { return resource.strftime_format; }
|
||||
void saveStrftimeFormat(const char *);
|
||||
#else // !HAVE_STRFTIME
|
||||
inline int getDateFormat(void) { return resource.date_format; }
|
||||
inline int getDateFormat() { return resource.date_format; }
|
||||
inline void saveDateFormat(int f) { resource.date_format = f; }
|
||||
inline Bool isClock24Hour(void) { return resource.clock24hour; }
|
||||
inline Bool isClock24Hour() { return resource.clock24hour; }
|
||||
inline void saveClock24Hour(Bool c) { resource.clock24hour = c; }
|
||||
#endif // HAVE_STRFTIME
|
||||
|
||||
inline WindowStyle *getWindowStyle(void) { return &resource.wstyle; }
|
||||
inline MenuStyle *getMenuStyle(void) { return &resource.mstyle; }
|
||||
inline ToolbarStyle *getToolbarStyle(void) { return &resource.tstyle; }
|
||||
inline bool hideToolbar() const { return resource.hide_toolbar; }
|
||||
void setHideToolbar(bool);
|
||||
|
||||
inline WindowStyle *getWindowStyle() { return &resource.wstyle; }
|
||||
inline MenuStyle *getMenuStyle() { return &resource.mstyle; }
|
||||
inline ToolbarStyle *getToolbarStyle() { return &resource.tstyle; }
|
||||
|
||||
OpenboxWindow *getIcon(int);
|
||||
|
||||
int addWorkspace(void);
|
||||
int removeLastWorkspace(void);
|
||||
int addWorkspace();
|
||||
int removeLastWorkspace();
|
||||
|
||||
void removeWorkspaceNames(void);
|
||||
void removeWorkspaceNames();
|
||||
void addWorkspaceName(const char *);
|
||||
void addNetizen(Netizen *);
|
||||
void removeNetizen(Window);
|
||||
|
@ -310,19 +294,19 @@ public:
|
|||
void changeWorkspaceID(int);
|
||||
void raiseWindows(Window *, int);
|
||||
void reassociateWindow(OpenboxWindow *, int, Bool);
|
||||
void prevFocus(void);
|
||||
void nextFocus(void);
|
||||
void raiseFocus(void);
|
||||
void reconfigure(void);
|
||||
void rereadMenu(void);
|
||||
void shutdown(void);
|
||||
void prevFocus();
|
||||
void nextFocus();
|
||||
void raiseFocus();
|
||||
void reconfigure();
|
||||
void load();
|
||||
void rereadMenu();
|
||||
void shutdown();
|
||||
void showPosition(int, int);
|
||||
void showGeometry(unsigned int, unsigned int);
|
||||
void hideGeometry(void);
|
||||
void saveToolbarHide( Bool b);
|
||||
void updateNetizenCurrentWorkspace(void);
|
||||
void updateNetizenWorkspaceCount(void);
|
||||
void updateNetizenWindowFocus(void);
|
||||
void hideGeometry();
|
||||
void updateNetizenCurrentWorkspace();
|
||||
void updateNetizenWorkspaceCount();
|
||||
void updateNetizenWindowFocus();
|
||||
void updateNetizenWindowAdd(Window, unsigned long);
|
||||
void updateNetizenWindowDel(Window);
|
||||
void updateNetizenConfigNotify(XEvent *);
|
||||
|
|
|
@ -230,7 +230,6 @@ void Slit::setAutoHide(bool b) {
|
|||
|
||||
void Slit::setPlacement(int p) {
|
||||
m_placement = p;
|
||||
cout << "setting " << p << " " << m_placement << endl;
|
||||
ostrstream s;
|
||||
s << "session.screen" << screen.getScreenNumber() << ".slit.placement" <<
|
||||
ends;
|
||||
|
@ -266,7 +265,6 @@ void Slit::load() {
|
|||
rname << rscreen.str() << "slit.placement" << ends;
|
||||
rclass << rscreen.str() << "Slit.Placement" << ends;
|
||||
if (config.getValue(rname.str(), rclass.str(), s)) {
|
||||
cout << "getting " << s.c_str() << endl;
|
||||
if (0 == strncasecmp(s.c_str(), "TopLeft", s.length()))
|
||||
m_placement = TopLeft;
|
||||
else if (0 == strncasecmp(s.c_str(), "CenterLeft", s.length()))
|
||||
|
|
194
src/Toolbar.cc
194
src/Toolbar.cc
|
@ -62,8 +62,18 @@
|
|||
# endif // HAVE_SYS_TIME_H
|
||||
#endif // TIME_WITH_SYS_TIME
|
||||
|
||||
#include <strstream>
|
||||
#include <string>
|
||||
|
||||
Toolbar::Toolbar(BScreen &scrn, Resource &conf) : screen(scrn),
|
||||
openbox(scrn.getOpenbox()), config(conf)
|
||||
{
|
||||
// default values
|
||||
m_width_percent =66;
|
||||
m_placement = BottomCenter;
|
||||
m_ontop = false;
|
||||
m_hidden = m_autohide = false;
|
||||
|
||||
Toolbar::Toolbar(BScreen &scrn) : screen(scrn), openbox(scrn.getOpenbox()) {
|
||||
// get the clock updating every minute
|
||||
clock_timer = new BTimer(openbox, *this);
|
||||
timeval now;
|
||||
|
@ -78,10 +88,7 @@ Toolbar::Toolbar(BScreen &scrn) : screen(scrn), openbox(scrn.getOpenbox()) {
|
|||
|
||||
image_ctrl = screen.getImageControl();
|
||||
|
||||
on_top = screen.isToolbarOnTop();
|
||||
hidden = do_auto_hide = screen.doToolbarAutoHide();
|
||||
|
||||
editing = False;
|
||||
m_editing = False;
|
||||
new_workspace_name = (char *) 0;
|
||||
new_name_pos = 0;
|
||||
frame.grab_x = frame.grab_y = 0;
|
||||
|
@ -151,20 +158,36 @@ Toolbar::Toolbar(BScreen &scrn) : screen(scrn), openbox(scrn.getOpenbox()) {
|
|||
mapToolbar();
|
||||
}
|
||||
|
||||
inline void Toolbar::mapToolbar(){
|
||||
if(!screen.doToolbarHide()){
|
||||
do_hide=false;//not hidden, so windows should not maximize over the toolbar
|
||||
int Toolbar::getX() const {
|
||||
return ((m_hidden) ? frame.x_hidden : frame.x);
|
||||
}
|
||||
|
||||
int Toolbar::getY() const {
|
||||
if (screen.hideToolbar()) return screen.size().h();
|
||||
else if (m_hidden) return frame.y_hidden;
|
||||
else return frame.y;
|
||||
}
|
||||
|
||||
unsigned int Toolbar::getExposedHeight() const {
|
||||
if (screen.hideToolbar()) return 0;
|
||||
else if (m_autohide) return frame.bevel_w;
|
||||
else return frame.height;
|
||||
}
|
||||
|
||||
void Toolbar::mapToolbar(){
|
||||
if (!screen.hideToolbar()) {
|
||||
//not hidden, so windows should not maximize over the toolbar
|
||||
XMapSubwindows(display, frame.window);
|
||||
XMapWindow(display, frame.window);
|
||||
}else
|
||||
do_hide=true;
|
||||
}
|
||||
}
|
||||
inline void Toolbar::unMapToolbar(){
|
||||
do_hide=true; //hidden so we can maximize over the toolbar
|
||||
|
||||
void Toolbar::unMapToolbar(){
|
||||
//hidden so we can maximize over the toolbar
|
||||
XUnmapWindow(display, frame.window);
|
||||
}
|
||||
|
||||
Toolbar::~Toolbar(void) {
|
||||
Toolbar::~Toolbar() {
|
||||
unMapToolbar();
|
||||
if (frame.base) image_ctrl->removeImage(frame.base);
|
||||
if (frame.label) image_ctrl->removeImage(frame.label);
|
||||
|
@ -194,9 +217,92 @@ Toolbar::~Toolbar(void) {
|
|||
}
|
||||
|
||||
|
||||
void Toolbar::reconfigure(void) {
|
||||
void Toolbar::setOnTop(bool b) {
|
||||
m_ontop = b;
|
||||
ostrstream s;
|
||||
s << "session.screen" << screen.getScreenNumber() << ".toolbar.onTop" << ends;
|
||||
config.setValue(s.str(), m_ontop ? "True" : "False");
|
||||
}
|
||||
|
||||
void Toolbar::setAutoHide(bool b) {
|
||||
m_autohide = b;
|
||||
ostrstream s;
|
||||
s << "session.screen" << screen.getScreenNumber() << ".toolbar.autoHide" <<
|
||||
ends;
|
||||
config.setValue(s.str(), m_autohide ? "True" : "False");
|
||||
}
|
||||
|
||||
void Toolbar::setWidthPercent(int w) {
|
||||
m_width_percent = w;
|
||||
ostrstream s;
|
||||
s << "session.screen" << screen.getScreenNumber() << ".toolbar.widthPercent"
|
||||
<< ends;
|
||||
config.setValue(s.str(), m_width_percent);
|
||||
}
|
||||
|
||||
void Toolbar::setPlacement(int p) {
|
||||
m_placement = p;
|
||||
ostrstream s;
|
||||
s << "session.screen" << screen.getScreenNumber() << ".toolbar.placement" <<
|
||||
ends;
|
||||
const char *placement;
|
||||
switch (m_placement) {
|
||||
case TopLeft: placement = "TopLeft"; break;
|
||||
case BottomLeft: placement = "BottomLeft"; break;
|
||||
case TopCenter: placement = "TopCenter"; break;
|
||||
case TopRight: placement = "TopRight"; break;
|
||||
case BottomRight: placement = "BottomRight"; break;
|
||||
case BottomCenter: default: placement = "BottomCenter"; break;
|
||||
}
|
||||
config.setValue(s.str(), placement);
|
||||
}
|
||||
|
||||
void Toolbar::load() {
|
||||
std::ostrstream rscreen, rname, rclass;
|
||||
std::string s;
|
||||
bool b;
|
||||
long l;
|
||||
rscreen << "session.screen" << screen.getScreenNumber() << '.' << ends;
|
||||
|
||||
rname << rscreen.str() << "toolbar.widthPercent" << ends;
|
||||
rclass << rscreen.str() << "Toolbar.WidthPercent" << ends;
|
||||
if (config.getValue(rname.str(), rclass.str(), l) && (l > 0 && l <= 100))
|
||||
m_width_percent = l;
|
||||
|
||||
rname.seekp(0); rclass.seekp(0);
|
||||
rname << rscreen.str() << "toolbar.placement" << ends;
|
||||
rclass << rscreen.str() << "Toolbar.Placement" << ends;
|
||||
if (config.getValue(rname.str(), rclass.str(), s)) {
|
||||
if (0 == strncasecmp(s.c_str(), "TopLeft", s.length()))
|
||||
m_placement = TopLeft;
|
||||
else if (0 == strncasecmp(s.c_str(), "BottomLeft", s.length()))
|
||||
m_placement = BottomLeft;
|
||||
else if (0 == strncasecmp(s.c_str(), "TopCenter", s.length()))
|
||||
m_placement = TopCenter;
|
||||
else if (0 == strncasecmp(s.c_str(), "TopRight", s.length()))
|
||||
m_placement = TopRight;
|
||||
else if ( 0 == strncasecmp(s.c_str(), "BottomRight", s.length()))
|
||||
m_placement = BottomRight;
|
||||
else if ( 0 == strncasecmp(s.c_str(), "BottomCenter", s.length()))
|
||||
m_placement = BottomCenter;
|
||||
}
|
||||
|
||||
rname.seekp(0); rclass.seekp(0);
|
||||
rname << rscreen.str() << "toolbar.onTop" << ends;
|
||||
rclass << rscreen.str() << "Toolbar.OnTop" << ends;
|
||||
if (config.getValue(rname.str(), rclass.str(), b))
|
||||
m_ontop = b;
|
||||
|
||||
rname.seekp(0); rclass.seekp(0);
|
||||
rname << rscreen.str() << "toolbar.autoHide" << ends;
|
||||
rclass << rscreen.str() << "Toolbar.AutoHide" << ends;
|
||||
if (config.getValue(rname.str(), rclass.str(), b))
|
||||
m_hidden = m_autohide = b;
|
||||
}
|
||||
|
||||
void Toolbar::reconfigure() {
|
||||
frame.bevel_w = screen.getBevelWidth();
|
||||
frame.width = screen.size().w() * screen.getToolbarWidthPercent() / 100;
|
||||
frame.width = screen.size().w() * m_width_percent / 100;
|
||||
|
||||
if (i18n->multibyte())
|
||||
frame.height =
|
||||
|
@ -209,7 +315,7 @@ void Toolbar::reconfigure(void) {
|
|||
frame.label_h = frame.height;
|
||||
frame.height += (frame.bevel_w * 2);
|
||||
|
||||
switch (screen.getToolbarPlacement()) {
|
||||
switch (m_placement) {
|
||||
case TopLeft:
|
||||
frame.x = 0;
|
||||
frame.y = 0;
|
||||
|
@ -348,7 +454,7 @@ void Toolbar::reconfigure(void) {
|
|||
(frame.width - (frame.clock_w + (frame.button_w * 4) +
|
||||
frame.workspace_label_w + (frame.bevel_w * 8) + 6));
|
||||
|
||||
if (hidden) {
|
||||
if (m_hidden) {
|
||||
XMoveResizeWindow(display, frame.window, frame.x_hidden, frame.y_hidden,
|
||||
frame.width, frame.height);
|
||||
} else {
|
||||
|
@ -834,11 +940,11 @@ void Toolbar::redrawNextWindowButton(Bool pressed, Bool redraw) {
|
|||
}
|
||||
|
||||
|
||||
void Toolbar::edit(void) {
|
||||
void Toolbar::edit() {
|
||||
Window window;
|
||||
int foo;
|
||||
|
||||
editing = True;
|
||||
m_editing = True;
|
||||
if (XGetInputFocus(display, &window, &foo) &&
|
||||
window == frame.workspace_label)
|
||||
return;
|
||||
|
@ -890,11 +996,11 @@ void Toolbar::buttonPressEvent(XButtonEvent *be) {
|
|||
checkClock(True, True);
|
||||
}
|
||||
#endif // HAVE_STRFTIME
|
||||
else if (! on_top) {
|
||||
else if (! m_ontop) {
|
||||
Window w[1] = { frame.window };
|
||||
screen.raiseWindows(w, 1);
|
||||
}
|
||||
} else if (be->button == 2 && (! on_top)) {
|
||||
} else if (be->button == 2 && (! m_ontop)) {
|
||||
XLowerWindow(display, frame.window);
|
||||
} else if (be->button == 3) {
|
||||
if (! toolbarmenu->isVisible()) {
|
||||
|
@ -970,10 +1076,10 @@ void Toolbar::buttonReleaseEvent(XButtonEvent *re) {
|
|||
|
||||
|
||||
void Toolbar::enterNotifyEvent(XCrossingEvent *) {
|
||||
if (! do_auto_hide)
|
||||
if (! m_autohide)
|
||||
return;
|
||||
|
||||
if (hidden) {
|
||||
if (m_hidden) {
|
||||
if (! hide_timer->isTiming()) hide_timer->start();
|
||||
} else {
|
||||
if (hide_timer->isTiming()) hide_timer->stop();
|
||||
|
@ -981,10 +1087,10 @@ void Toolbar::enterNotifyEvent(XCrossingEvent *) {
|
|||
}
|
||||
|
||||
void Toolbar::leaveNotifyEvent(XCrossingEvent *) {
|
||||
if (! do_auto_hide)
|
||||
if (! m_autohide)
|
||||
return;
|
||||
|
||||
if (hidden) {
|
||||
if (m_hidden) {
|
||||
if (hide_timer->isTiming()) hide_timer->stop();
|
||||
} else if (! toolbarmenu->isVisible()) {
|
||||
if (! hide_timer->isTiming()) hide_timer->start();
|
||||
|
@ -994,7 +1100,7 @@ void Toolbar::leaveNotifyEvent(XCrossingEvent *) {
|
|||
|
||||
void Toolbar::exposeEvent(XExposeEvent *ee) {
|
||||
if (ee->window == frame.clock) checkClock(True);
|
||||
else if (ee->window == frame.workspace_label && (! editing))
|
||||
else if (ee->window == frame.workspace_label && (! m_editing))
|
||||
redrawWorkspaceLabel();
|
||||
else if (ee->window == frame.window_label) redrawWindowLabel();
|
||||
else if (ee->window == frame.psbutton) redrawPrevWorkspaceButton();
|
||||
|
@ -1005,7 +1111,7 @@ void Toolbar::exposeEvent(XExposeEvent *ee) {
|
|||
|
||||
|
||||
void Toolbar::keyPressEvent(XKeyEvent *ke) {
|
||||
if (ke->window == frame.workspace_label && editing) {
|
||||
if (ke->window == frame.workspace_label && m_editing) {
|
||||
openbox.grab();
|
||||
|
||||
if (! new_workspace_name) {
|
||||
|
@ -1023,7 +1129,7 @@ void Toolbar::keyPressEvent(XKeyEvent *ke) {
|
|||
if (ks == XK_Return || new_name_pos == 127) {
|
||||
*(new_workspace_name + new_name_pos) = 0;
|
||||
|
||||
editing = False;
|
||||
m_editing = False;
|
||||
|
||||
openbox.setNoFocus(False);
|
||||
if (openbox.getFocusedWindow()) {
|
||||
|
@ -1124,7 +1230,7 @@ void Toolbar::keyPressEvent(XKeyEvent *ke) {
|
|||
}
|
||||
|
||||
|
||||
void Toolbar::timeout(void) {
|
||||
void Toolbar::timeout() {
|
||||
checkClock(True);
|
||||
|
||||
timeval now;
|
||||
|
@ -1133,9 +1239,9 @@ void Toolbar::timeout(void) {
|
|||
}
|
||||
|
||||
|
||||
void Toolbar::HideHandler::timeout(void) {
|
||||
toolbar->hidden = ! toolbar->hidden;
|
||||
if (toolbar->hidden)
|
||||
void Toolbar::HideHandler::timeout() {
|
||||
toolbar->m_hidden = !toolbar->m_hidden;
|
||||
if (toolbar->m_hidden)
|
||||
XMoveWindow(toolbar->display, toolbar->frame.window,
|
||||
toolbar->frame.x_hidden, toolbar->frame.y_hidden);
|
||||
else
|
||||
|
@ -1159,12 +1265,12 @@ Toolbarmenu::Toolbarmenu(Toolbar &tb) : Basemenu(tb.screen), toolbar(tb) {
|
|||
|
||||
update();
|
||||
|
||||
if (toolbar.isOnTop()) setItemSelected(1, True);
|
||||
if (toolbar.doAutoHide()) setItemSelected(2, True);
|
||||
if (toolbar.onTop()) setItemSelected(1, True);
|
||||
if (toolbar.autoHide()) setItemSelected(2, True);
|
||||
}
|
||||
|
||||
|
||||
Toolbarmenu::~Toolbarmenu(void) {
|
||||
Toolbarmenu::~Toolbarmenu() {
|
||||
delete placementmenu;
|
||||
}
|
||||
|
||||
|
@ -1178,17 +1284,17 @@ void Toolbarmenu::itemSelected(int button, int index) {
|
|||
|
||||
switch (item->function()) {
|
||||
case 1: { // always on top
|
||||
Bool change = ((toolbar.isOnTop()) ? False : True);
|
||||
toolbar.on_top = change;
|
||||
Bool change = ((toolbar.onTop()) ? False : True);
|
||||
toolbar.setOnTop(change);
|
||||
setItemSelected(1, change);
|
||||
|
||||
if (toolbar.isOnTop()) toolbar.screen.raiseWindows((Window *) 0, 0);
|
||||
if (toolbar.onTop()) toolbar.screen.raiseWindows((Window *) 0, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
case 2: { // auto hide
|
||||
Bool change = ((toolbar.doAutoHide()) ? False : True);
|
||||
toolbar.do_auto_hide = change;
|
||||
Bool change = ((toolbar.autoHide()) ? False : True);
|
||||
toolbar.setAutoHide(change);
|
||||
setItemSelected(2, change);
|
||||
|
||||
#ifdef SLIT
|
||||
|
@ -1207,14 +1313,14 @@ void Toolbarmenu::itemSelected(int button, int index) {
|
|||
}
|
||||
|
||||
|
||||
void Toolbarmenu::internal_hide(void) {
|
||||
void Toolbarmenu::internal_hide() {
|
||||
Basemenu::internal_hide();
|
||||
if (toolbar.doAutoHide() && ! toolbar.isEditing())
|
||||
if (toolbar.autoHide() && ! toolbar.isEditing())
|
||||
toolbar.hide_handler.timeout();
|
||||
}
|
||||
|
||||
|
||||
void Toolbarmenu::reconfigure(void) {
|
||||
void Toolbarmenu::reconfigure() {
|
||||
placementmenu->reconfigure();
|
||||
|
||||
Basemenu::reconfigure();
|
||||
|
@ -1251,7 +1357,7 @@ void Toolbarmenu::Placementmenu::itemSelected(int button, int index) {
|
|||
BasemenuItem *item = find(index);
|
||||
if (! item) return;
|
||||
|
||||
toolbarmenu.toolbar.screen.saveToolbarPlacement(item->function());
|
||||
toolbarmenu.toolbar.setPlacement(item->function());
|
||||
hide();
|
||||
toolbarmenu.toolbar.reconfigure();
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include "Basemenu.h"
|
||||
#include "Timer.h"
|
||||
#include "Resource.h"
|
||||
#include "Screen.h"
|
||||
|
||||
// forward declaration
|
||||
|
@ -54,21 +55,22 @@ private:
|
|||
|
||||
protected:
|
||||
virtual void itemSelected(int, int);
|
||||
virtual void internal_hide(void);
|
||||
virtual void internal_hide();
|
||||
|
||||
public:
|
||||
Toolbarmenu(Toolbar &);
|
||||
~Toolbarmenu(void);
|
||||
~Toolbarmenu();
|
||||
|
||||
inline Basemenu *getPlacementmenu(void) { return placementmenu; }
|
||||
inline Basemenu *getPlacementmenu() { return placementmenu; }
|
||||
|
||||
void reconfigure(void);
|
||||
void reconfigure();
|
||||
};
|
||||
|
||||
|
||||
class Toolbar : public TimeoutHandler {
|
||||
private:
|
||||
Bool on_top, editing, hidden, do_auto_hide, do_hide;
|
||||
bool m_ontop, m_editing, m_hidden, m_autohide;
|
||||
int m_width_percent, m_placement;
|
||||
Display *display;
|
||||
|
||||
struct frame {
|
||||
|
@ -85,11 +87,11 @@ private:
|
|||
class HideHandler : public TimeoutHandler {
|
||||
public:
|
||||
Toolbar *toolbar;
|
||||
|
||||
virtual void timeout(void);
|
||||
virtual void timeout();
|
||||
} hide_handler;
|
||||
|
||||
Openbox &openbox;
|
||||
Resource &config;
|
||||
BImageControl *image_ctrl;
|
||||
BScreen &screen;
|
||||
BTimer *clock_timer, *hide_timer;
|
||||
|
@ -104,35 +106,19 @@ private:
|
|||
|
||||
|
||||
public:
|
||||
Toolbar(BScreen &);
|
||||
virtual ~Toolbar(void);
|
||||
Toolbar(BScreen &, Resource &);
|
||||
virtual ~Toolbar();
|
||||
|
||||
inline Toolbarmenu *getMenu(void) { return toolbarmenu; }
|
||||
inline Toolbarmenu *getMenu() { return toolbarmenu; }
|
||||
|
||||
inline const Bool &isEditing(void) const { return editing; }
|
||||
inline const Bool &isOnTop(void) const { return on_top; }
|
||||
inline const Bool &isHidden(void) const { return hidden; }
|
||||
inline const Bool &doAutoHide(void) const { return do_auto_hide; }
|
||||
inline const Window &getWindowID() const { return frame.window; }
|
||||
|
||||
inline const Window &getWindowID(void) const { return frame.window; }
|
||||
|
||||
inline const unsigned int &getWidth(void) const { return frame.width; }
|
||||
inline const unsigned int &getHeight(void) const { return frame.height; }
|
||||
inline const unsigned int getExposedHeight(void) const {
|
||||
if (do_hide) return 0;
|
||||
else if (do_auto_hide) return frame.bevel_w;
|
||||
else return frame.height;
|
||||
}
|
||||
|
||||
inline const int &getX(void) const
|
||||
{ return ((hidden) ? frame.x_hidden : frame.x); }
|
||||
// const int getY(void) const;
|
||||
inline const int getY(void) const {
|
||||
if (do_hide) return screen.size().h();
|
||||
else if (hidden) return frame.y_hidden;
|
||||
else return frame.y;
|
||||
}
|
||||
inline unsigned int getWidth() const { return frame.width; }
|
||||
inline unsigned int getHeight() const { return frame.height; }
|
||||
unsigned int getExposedHeight() const;
|
||||
|
||||
int getX() const;
|
||||
int getY() const;
|
||||
|
||||
void buttonPressEvent(XButtonEvent *);
|
||||
void buttonReleaseEvent(XButtonEvent *);
|
||||
|
@ -147,17 +133,33 @@ public:
|
|||
void redrawNextWorkspaceButton(Bool = False, Bool = False);
|
||||
void redrawPrevWindowButton(Bool = False, Bool = False);
|
||||
void redrawNextWindowButton(Bool = False, Bool = False);
|
||||
void edit(void);
|
||||
void reconfigure(void);
|
||||
void mapToolbar(void);
|
||||
void unMapToolbar(void);
|
||||
void edit();
|
||||
void reconfigure();
|
||||
void load();
|
||||
void mapToolbar();
|
||||
void unMapToolbar();
|
||||
#ifdef HAVE_STRFTIME
|
||||
void checkClock(Bool = False);
|
||||
#else // HAVE_STRFTIME
|
||||
void checkClock(Bool = False, Bool = False);
|
||||
#endif // HAVE_STRFTIME
|
||||
|
||||
virtual void timeout(void);
|
||||
virtual void timeout();
|
||||
|
||||
inline bool onTop() const { return m_ontop; }
|
||||
void setOnTop(bool);
|
||||
|
||||
inline bool autoHide() const { return m_autohide; }
|
||||
void setAutoHide(bool);
|
||||
|
||||
inline int widthPercent() const { return m_width_percent; }
|
||||
void setWidthPercent(int);
|
||||
|
||||
inline int placement() const { return m_placement; }
|
||||
void setPlacement(int);
|
||||
|
||||
inline bool isEditing() const { return m_editing; }
|
||||
inline bool isHidden() const { return m_hidden; }
|
||||
|
||||
enum { TopLeft = 1, BottomLeft, TopCenter,
|
||||
BottomCenter, TopRight, BottomRight };
|
||||
|
|
|
@ -1579,7 +1579,7 @@ void OpenboxWindow::maximize(unsigned int button) {
|
|||
dy += (((screen->size().h() - screen->getToolbar()->getExposedHeight())
|
||||
- dh) / 2) - frame.border_w;
|
||||
|
||||
switch (screen->getToolbarPlacement()) {
|
||||
switch (screen->getToolbar()->placement()) {
|
||||
case Toolbar::TopLeft:
|
||||
case Toolbar::TopCenter:
|
||||
case Toolbar::TopRight:
|
||||
|
@ -2817,7 +2817,7 @@ void OpenboxWindow::motionNotifyEvent(XMotionEvent *me) {
|
|||
dx = screen->size().w() - snap_w;
|
||||
|
||||
int dtty, dbby, dty, dby;
|
||||
switch (screen->getToolbarPlacement()) {
|
||||
switch (screen->getToolbar()->placement()) {
|
||||
case Toolbar::TopLeft:
|
||||
case Toolbar::TopCenter:
|
||||
case Toolbar::TopRight:
|
||||
|
|
|
@ -179,7 +179,6 @@ Openbox::Openbox(int m_argc, char **m_argv, char *dpy_name, char *rc)
|
|||
rc_file = bstrdup(rc);
|
||||
}
|
||||
config.setFile(rc_file);
|
||||
config.load();
|
||||
|
||||
no_focus = False;
|
||||
|
||||
|
@ -1039,32 +1038,6 @@ void Openbox::save_rc(void) {
|
|||
sprintf(rc_string, "session.screen%d.workspaces", screen_number);
|
||||
config.setValue(rc_string, screen->getWorkspaceCount());
|
||||
|
||||
sprintf(rc_string, "session.screen%d.toolbar.onTop", screen_number);
|
||||
config.setValue(rc_string, screen->getToolbar()->isOnTop() ?
|
||||
"True" : "False");
|
||||
|
||||
sprintf(rc_string, "session.screen%d.toolbar.autoHide", screen_number);
|
||||
config.setValue(rc_string, screen->getToolbar()->doAutoHide() ?
|
||||
"True" : "False");
|
||||
|
||||
sprintf(rc_string, "session.screen%d.toolbar.hide", screen_number);
|
||||
config.setValue(rc_string, screen->doToolbarHide() ?
|
||||
"True" : "False");
|
||||
|
||||
|
||||
switch (screen->getToolbarPlacement()) {
|
||||
case Toolbar::TopLeft: placement = "TopLeft"; break;
|
||||
case Toolbar::BottomLeft: placement = "BottomLeft"; break;
|
||||
case Toolbar::TopCenter: placement = "TopCenter"; break;
|
||||
case Toolbar::TopRight: placement = "TopRight"; break;
|
||||
case Toolbar::BottomRight: placement = "BottomRight"; break;
|
||||
default:
|
||||
case Toolbar::BottomCenter: placement = "BottomCenter"; break;
|
||||
}
|
||||
|
||||
sprintf(rc_string, "session.screen%d.toolbar.placement", screen_number);
|
||||
config.setValue(rc_string, placement);
|
||||
|
||||
#ifdef HAVE_STRFTIME
|
||||
sprintf(rc_string, "session.screen%d.strftimeFormat", screen_number);
|
||||
config.setValue(rc_string, screen->getStrftimeFormat());
|
||||
|
@ -1080,9 +1053,6 @@ void Openbox::save_rc(void) {
|
|||
sprintf(rc_string, "session.screen%d.edgeSnapThreshold", screen_number);
|
||||
config.setValue(rc_string, screen->getEdgeSnapThreshold());
|
||||
|
||||
sprintf(rc_string, "session.screen%d.toolbar.widthPercent", screen_number);
|
||||
config.setValue(rc_string, screen->getToolbarWidthPercent());
|
||||
|
||||
// write out the user's workspace names
|
||||
int i, len = 0;
|
||||
for (i = 0; i < screen->getWorkspaceCount(); i++)
|
||||
|
@ -1257,33 +1227,6 @@ void Openbox::load_rc(BScreen *screen) {
|
|||
else
|
||||
screen->saveWorkspaces(1);
|
||||
|
||||
sprintf(name_lookup, "session.screen%d.toolbar.widthPercent",
|
||||
screen_number);
|
||||
sprintf(class_lookup, "Session.Screen%d.Toolbar.WidthPercent",
|
||||
screen_number);
|
||||
if (config.getValue(name_lookup, class_lookup, l) && (l > 0 && l <= 100))
|
||||
screen->saveToolbarWidthPercent(l);
|
||||
else
|
||||
screen->saveToolbarWidthPercent(66);
|
||||
|
||||
sprintf(name_lookup, "session.screen%d.toolbar.placement", screen_number);
|
||||
sprintf(class_lookup, "Session.Screen%d.Toolbar.Placement", screen_number);
|
||||
if (config.getValue(name_lookup, class_lookup, s)) {
|
||||
if (0 == strncasecmp(s.c_str(), "TopLeft", s.length()))
|
||||
screen->saveToolbarPlacement(Toolbar::TopLeft);
|
||||
else if (0 == strncasecmp(s.c_str(), "BottomLeft", s.length()))
|
||||
screen->saveToolbarPlacement(Toolbar::BottomLeft);
|
||||
else if (0 == strncasecmp(s.c_str(), "TopCenter", s.length()))
|
||||
screen->saveToolbarPlacement(Toolbar::TopCenter);
|
||||
else if (0 == strncasecmp(s.c_str(), "TopRight", s.length()))
|
||||
screen->saveToolbarPlacement(Toolbar::TopRight);
|
||||
else if ( 0 == strncasecmp(s.c_str(), "BottomRight", s.length()))
|
||||
screen->saveToolbarPlacement(Toolbar::BottomRight);
|
||||
else
|
||||
screen->saveToolbarPlacement(Toolbar::BottomCenter);
|
||||
} else
|
||||
screen->saveToolbarPlacement(Toolbar::BottomCenter);
|
||||
|
||||
screen->removeWorkspaceNames();
|
||||
sprintf(name_lookup, "session.screen%d.workspaceNames", screen_number);
|
||||
sprintf(class_lookup, "Session.Screen%d.WorkspaceNames", screen_number);
|
||||
|
@ -1301,27 +1244,6 @@ void Openbox::load_rc(BScreen *screen) {
|
|||
}
|
||||
}
|
||||
|
||||
sprintf(name_lookup, "session.screen%d.toolbar.onTop", screen_number);
|
||||
sprintf(class_lookup, "Session.Screen%d.Toolbar.OnTop", screen_number);
|
||||
if (config.getValue(name_lookup, class_lookup, b))
|
||||
screen->saveToolbarOnTop((Bool)b);
|
||||
else
|
||||
screen->saveToolbarOnTop(False);
|
||||
|
||||
sprintf(name_lookup, "session.screen%d.toolbar.hide", screen_number);
|
||||
sprintf(class_lookup, "Session.Screen%d.Toolbar.Hide", screen_number);
|
||||
if (config.getValue(name_lookup, class_lookup, b))
|
||||
screen->saveToolbarHide((Bool)b);
|
||||
else
|
||||
screen->saveToolbarHide(False);
|
||||
|
||||
sprintf(name_lookup, "session.screen%d.toolbar.autoHide", screen_number);
|
||||
sprintf(class_lookup, "Session.Screen%d.Toolbar.autoHide", screen_number);
|
||||
if (config.getValue(name_lookup, class_lookup, b))
|
||||
screen->saveToolbarAutoHide((Bool)b);
|
||||
else
|
||||
screen->saveToolbarAutoHide(False);
|
||||
|
||||
sprintf(name_lookup, "session.screen%d.focusModel", screen_number);
|
||||
sprintf(class_lookup, "Session.Screen%d.FocusModel", screen_number);
|
||||
if (config.getValue(name_lookup, class_lookup, s)) {
|
||||
|
|
Loading…
Reference in a new issue