rearranged includes, minor cleaning

This commit is contained in:
fluxgen 2002-10-25 20:58:14 +00:00
parent cc60dc63d6
commit a42295bccb

View file

@ -22,7 +22,22 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// $Id: Screen.cc,v 1.75 2002/10/23 17:30:12 fluxgen Exp $ // $Id: Screen.cc,v 1.76 2002/10/25 20:58:14 fluxgen Exp $
#include "Screen.hh"
#include "i18n.hh"
#include "fluxbox.hh"
#include "Image.hh"
#include "Toolbar.hh"
#include "Window.hh"
#include "Workspace.hh"
#include "Rootmenu.hh"
#include "Workspacemenu.hh"
#include "Configmenu.hh"
#include "Iconmenu.hh"
#include "StringUtil.hh"
//use GNU extensions //use GNU extensions
#ifndef _GNU_SOURCE #ifndef _GNU_SOURCE
@ -33,51 +48,37 @@
#include "config.h" #include "config.h"
#endif // HAVE_CONFIG_H #endif // HAVE_CONFIG_H
#include "Screen.hh"
#include "i18n.hh"
#include "fluxbox.hh"
#include "Icon.hh"
#include "Image.hh"
#include "StringUtil.hh"
#ifdef SLIT #ifdef SLIT
#include "Slit.hh" #include "Slit.hh"
#endif // SLIT #endif // SLIT
#include "Rootmenu.hh"
#include "Toolbar.hh"
#include "Window.hh"
#include "Workspace.hh"
#include "Workspacemenu.hh"
#ifdef STDC_HEADERS #ifdef STDC_HEADERS
# include <sys/types.h> #include <sys/types.h>
#endif // STDC_HEADERS #endif // STDC_HEADERS
#ifdef HAVE_CTYPE_H #ifdef HAVE_CTYPE_H
# include <ctype.h> #include <ctype.h>
#endif // HAVE_CTYPE_H #endif // HAVE_CTYPE_H
#ifdef HAVE_DIRENT_H #ifdef HAVE_DIRENT_H
# include <dirent.h> #include <dirent.h>
#endif // HAVE_DIRENT_H #endif // HAVE_DIRENT_H
#ifdef HAVE_LOCALE_H #ifdef HAVE_LOCALE_H
# include <locale.h> #include <locale.h>
#endif // HAVE_LOCALE_H #endif // HAVE_LOCALE_H
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
# include <sys/types.h> #include <sys/types.h>
# include <unistd.h> #include <unistd.h>
#endif // HAVE_UNISTD_H #endif // HAVE_UNISTD_H
#ifdef HAVE_SYS_STAT_H #ifdef HAVE_SYS_STAT_H
# include <sys/stat.h> #include <sys/stat.h>
#endif // HAVE_SYS_STAT_H #endif // HAVE_SYS_STAT_H
#ifdef HAVE_STDARG_H #ifdef HAVE_STDARG_H
# include <stdarg.h> #include <stdarg.h>
#endif // HAVE_STDARG_H #endif // HAVE_STDARG_H
#ifndef MAXPATHLEN #ifndef MAXPATHLEN
@ -94,8 +95,9 @@
using namespace std; using namespace std;
static bool running = true; static bool running = true;
namespace {
static int anotherWMRunning(Display *display, XErrorEvent *) { int anotherWMRunning(Display *display, XErrorEvent *) {
fprintf(stderr, fprintf(stderr,
I18n::instance()-> I18n::instance()->
getMessage( getMessage(
@ -109,10 +111,12 @@ static int anotherWMRunning(Display *display, XErrorEvent *) {
return(-1); return(-1);
} }
static int dcmp(const void *one, const void *two) { int dcmp(const void *one, const void *two) {
return (strcmp((*(char **) one), (*(char **) two))); return (strcmp((*(char **) one), (*(char **) two)));
} }
};
//---------- resource manipulators --------- //---------- resource manipulators ---------
template<> template<>
void Resource<Tab::Alignment>:: void Resource<Tab::Alignment>::
@ -218,26 +222,24 @@ toolbar_placement(rm, Toolbar::BOTTOMCENTER, scrname+".toolbar.placement", altsc
}; };
BScreen::BScreen(ResourceManager &rm, Fluxbox *b, BScreen::BScreen(ResourceManager &rm,
const string &screenname, const string &altscreenname, const string &screenname, const string &altscreenname,
int scrn) : ScreenInfo(b, scrn), int scrn) : ScreenInfo(scrn),
m_clientlist_sig(*this), // client signal m_clientlist_sig(*this), // client signal
m_workspacecount_sig(*this), // workspace count signal m_workspacecount_sig(*this), // workspace count signal
m_workspacenames_sig(*this), // workspace names signal m_workspacenames_sig(*this), // workspace names signal
m_currentworkspace_sig(*this), // current workspace signal m_currentworkspace_sig(*this), // current workspace signal
theme(0), theme(0),
resource(rm, screenname, altscreenname) resource(rm, screenname, altscreenname)
{ {
fluxbox = b;
event_mask = ColormapChangeMask | EnterWindowMask | PropertyChangeMask | event_mask = ColormapChangeMask | EnterWindowMask | PropertyChangeMask |
SubstructureRedirectMask | KeyPressMask | KeyReleaseMask | SubstructureRedirectMask | KeyPressMask | KeyReleaseMask |
ButtonPressMask | ButtonReleaseMask| SubstructureNotifyMask; ButtonPressMask | ButtonReleaseMask| SubstructureNotifyMask;
XErrorHandler old = XSetErrorHandler((XErrorHandler) anotherWMRunning); XErrorHandler old = XSetErrorHandler((XErrorHandler) anotherWMRunning);
XSelectInput(getBaseDisplay()->getXDisplay(), getRootWindow(), event_mask); XSelectInput(BaseDisplay::getXDisplay(), getRootWindow(), event_mask);
XSync(getBaseDisplay()->getXDisplay(), False); XSync(BaseDisplay::getXDisplay(), False);
XSetErrorHandler((XErrorHandler) old); XSetErrorHandler((XErrorHandler) old);
managed = running; managed = running;
@ -256,18 +258,18 @@ resource(rm, screenname, altscreenname)
getDepth()); getDepth());
rootmenu = 0; rootmenu = 0;
Fluxbox * const fluxbox = Fluxbox::instance();
#ifdef HAVE_GETPID #ifdef HAVE_GETPID
pid_t bpid = getpid(); pid_t bpid = getpid();
XChangeProperty(getBaseDisplay()->getXDisplay(), getRootWindow(), XChangeProperty(BaseDisplay::getXDisplay(), getRootWindow(),
fluxbox->getFluxboxPidAtom(), XA_CARDINAL, Fluxbox::instance()->getFluxboxPidAtom(), XA_CARDINAL,
sizeof(pid_t) * 8, PropModeReplace, sizeof(pid_t) * 8, PropModeReplace,
(unsigned char *) &bpid, 1); (unsigned char *) &bpid, 1);
#endif // HAVE_GETPID #endif // HAVE_GETPID
XDefineCursor(getBaseDisplay()->getXDisplay(), getRootWindow(), XDefineCursor(BaseDisplay::getXDisplay(), getRootWindow(),
fluxbox->getSessionCursor()); fluxbox->getSessionCursor());
image_control = image_control =
@ -288,20 +290,7 @@ resource(rm, screenname, altscreenname)
"0: 0000 x 0: 0000"); "0: 0000 x 0: 0000");
int l = strlen(s); int l = strlen(s);
/*
if (i18n->multibyte()) {
XRectangle ink, logical;
XmbTextExtents(theme->getWindowStyle().font.set, s, l, &ink, &logical);
geom_w = logical.width;
geom_h = theme->getWindowStyle().font.set_extents->max_ink_extent.height;
} else {
geom_h = theme->getWindowStyle().font.fontstruct->ascent +
theme->getWindowStyle().font.fontstruct->descent;
geom_w = XTextWidth(theme->getWindowStyle().font.fontstruct, s, l);
}
*/
geom_h = theme->getWindowStyle().font.height(); geom_h = theme->getWindowStyle().font.height();
geom_w = theme->getWindowStyle().font.textWidth(s, l); geom_w = theme->getWindowStyle().font.textWidth(s, l);
@ -347,7 +336,7 @@ resource(rm, screenname, altscreenname)
} }
workspacemenu = new Workspacemenu(this); workspacemenu = new Workspacemenu(this);
iconmenu = new Iconmenu(this); m_iconmenu = new Iconmenu(this);
configmenu = new Configmenu(this); configmenu = new Configmenu(this);
Workspace *wkspc = (Workspace *) 0; Workspace *wkspc = (Workspace *) 0;
@ -367,13 +356,13 @@ resource(rm, screenname, altscreenname)
getMessage( getMessage(
FBNLS::IconSet, FBNLS::IconIcons, FBNLS::IconSet, FBNLS::IconIcons,
"Icons"), "Icons"),
iconmenu); m_iconmenu);
workspacemenu->update(); workspacemenu->update();
current_workspace = workspacesList.front(); current_workspace = workspacesList.front();
workspacemenu->setItemSelected(2, true); workspacemenu->setItemSelected(2, true);
toolbar = new Toolbar(this); m_toolbar.reset(new Toolbar(this));
#ifdef SLIT #ifdef SLIT
slit = new Slit(this); slit = new Slit(this);
@ -389,7 +378,7 @@ resource(rm, screenname, altscreenname)
slit->reconfigure(); slit->reconfigure();
#endif // SLIT #endif // SLIT
// start with workspace 0
changeWorkspaceID(0); changeWorkspaceID(0);
updateNetizenWorkspaceCount(); updateNetizenWorkspaceCount();
@ -452,7 +441,7 @@ resource(rm, screenname, altscreenname)
} }
if (! resource.sloppy_focus) if (! resource.sloppy_focus)
XSetInputFocus(getBaseDisplay()->getXDisplay(), toolbar->getWindowID(), XSetInputFocus(getBaseDisplay()->getXDisplay(), m_toolbar->getWindowID(),
RevertToParent, CurrentTime); RevertToParent, CurrentTime);
XFree(children); XFree(children);
@ -501,27 +490,30 @@ BScreen::~BScreen() {
delete rootmenu; delete rootmenu;
delete workspacemenu; delete workspacemenu;
delete iconmenu; delete m_iconmenu;
delete configmenu; delete configmenu;
#ifdef SLIT #ifdef SLIT
delete slit; delete slit;
#endif // SLIT #endif // SLIT
delete toolbar;
delete image_control; delete image_control;
delete theme; delete theme;
} }
void BScreen::iconUpdate() {
m_iconmenu->update();
}
void BScreen::reconfigure() { void BScreen::reconfigure() {
#ifdef DEBUG #ifdef DEBUG
cerr<<__FILE__<<"("<<__LINE__<<"): BScreen::reconfigure"<<endl; cerr<<__FILE__<<"("<<__LINE__<<"): BScreen::reconfigure"<<endl;
#endif // DEBUG #endif // DEBUG
Fluxbox::instance()->loadRootCommand(this); Fluxbox::instance()->loadRootCommand(this);
theme->setRootCommand(getRootCommand()); theme->setRootCommand(getRootCommand());
theme->load(fluxbox->getStyleFilename()); theme->load(Fluxbox::instance()->getStyleFilename());
theme->reconfigure(*resource.antialias); theme->reconfigure(*resource.antialias);
I18n *i18n = I18n::instance(); I18n *i18n = I18n::instance();
@ -530,20 +522,7 @@ void BScreen::reconfigure() {
FBNLS::ScreenSet, FBNLS::ScreenPositionLength, FBNLS::ScreenSet, FBNLS::ScreenPositionLength,
"0: 0000 x 0: 0000"); "0: 0000 x 0: 0000");
int l = strlen(s); int l = strlen(s);
/*
if (i18n->multibyte()) {
XRectangle ink, logical;
XmbTextExtents(theme->getWindowStyle().font.set, s, l, &ink, &logical);
geom_w = logical.width;
geom_h = theme->getWindowStyle().font.set_extents->max_ink_extent.height;
} else {
geom_w = XTextWidth(theme->getWindowStyle().font.fontstruct, s, l);
geom_h = theme->getWindowStyle().font.fontstruct->ascent +
theme->getWindowStyle().font.fontstruct->descent;
}
*/
//TODO: repeat from somewhere else? //TODO: repeat from somewhere else?
geom_h = theme->getWindowStyle().font.height(); geom_h = theme->getWindowStyle().font.height();
geom_w = theme->getWindowStyle().font.textWidth(s, l); geom_w = theme->getWindowStyle().font.textWidth(s, l);
@ -585,7 +564,7 @@ void BScreen::reconfigure() {
//reconfigure menus //reconfigure menus
workspacemenu->reconfigure(); workspacemenu->reconfigure();
iconmenu->reconfigure(); m_iconmenu->reconfigure();
configmenu->reconfigure(); configmenu->reconfigure();
@ -598,7 +577,7 @@ void BScreen::reconfigure() {
} }
toolbar->reconfigure(); m_toolbar->reconfigure();
#ifdef SLIT #ifdef SLIT
slit->reconfigure(); slit->reconfigure();
@ -648,9 +627,9 @@ void BScreen::addIcon(FluxboxWindow *w) {
iconList.push_back(w); iconList.push_back(w);
iconmenu->insert(w->getIconTitle().c_str()); m_iconmenu->insert(w->getIconTitle().c_str());
iconmenu->update(); m_iconmenu->update();
toolbar->addIcon(w); m_toolbar->addIcon(w);
} }
@ -669,9 +648,9 @@ void BScreen::removeIcon(FluxboxWindow *w) {
} }
} }
iconmenu->remove(w->getWindowNumber()); m_iconmenu->remove(w->getWindowNumber());
iconmenu->update(); m_iconmenu->update();
toolbar->delIcon(w); m_toolbar->delIcon(w);
Icons::iterator it = iconList.begin(); Icons::iterator it = iconList.begin();
Icons::iterator it_end = iconList.end(); Icons::iterator it_end = iconList.end();
@ -712,7 +691,7 @@ int BScreen::addWorkspace() {
workspacemenu->update(); workspacemenu->update();
saveWorkspaces(workspacesList.size()); saveWorkspaces(workspacesList.size());
toolbar->reconfigure(); m_toolbar->reconfigure();
updateNetizenWorkspaceCount(); updateNetizenWorkspaceCount();
@ -724,29 +703,28 @@ int BScreen::addWorkspace() {
/// removes last workspace /// removes last workspace
/// @return number of desktops left /// @return number of desktops left
int BScreen::removeLastWorkspace() { int BScreen::removeLastWorkspace() {
if (workspacesList.size() > 1) { if (workspacesList.size() <= 1)
Workspace *wkspc = workspacesList.back(); return 0;
Workspace *wkspc = workspacesList.back();
if (current_workspace->workspaceID() == wkspc->workspaceID()) if (current_workspace->workspaceID() == wkspc->workspaceID())
changeWorkspaceID(current_workspace->workspaceID() - 1); changeWorkspaceID(current_workspace->workspaceID() - 1);
wkspc->removeAll(); wkspc->removeAll();
workspacemenu->remove(wkspc->workspaceID()+2); // + 2 is where workspaces starts workspacemenu->remove(wkspc->workspaceID()+2); // + 2 is where workspaces starts
workspacemenu->update(); workspacemenu->update();
//remove last workspace //remove last workspace
workspacesList.pop_back(); workspacesList.pop_back();
delete wkspc; delete wkspc;
toolbar->reconfigure(); m_toolbar->reconfigure();
updateNetizenWorkspaceCount(); updateNetizenWorkspaceCount();
saveWorkspaces(workspacesList.size()); saveWorkspaces(workspacesList.size());
return workspacesList.size();
}
return 0; return workspacesList.size();
} }
@ -755,8 +733,8 @@ void BScreen::changeWorkspaceID(unsigned int id) {
return; return;
if (id != current_workspace->workspaceID()) { if (id != current_workspace->workspaceID()) {
XSync(fluxbox->getXDisplay(), true); XSync(BaseDisplay::getXDisplay(), true);
FluxboxWindow *focused = fluxbox->getFocusedWindow(); FluxboxWindow *focused = Fluxbox::instance()->getFocusedWindow();
#ifdef DEBUG #ifdef DEBUG
cerr<<__FILE__<<"("<<__FUNCTION__<<"): focused = "<<focused<<endl; cerr<<__FILE__<<"("<<__FUNCTION__<<"): focused = "<<focused<<endl;
#endif // DEBUG #endif // DEBUG
@ -782,14 +760,14 @@ void BScreen::changeWorkspaceID(unsigned int id) {
if (focused && focused->getScreen() == this && if (focused && focused->getScreen() == this &&
(! focused->isStuck()) && (!focused->isMoving())) { (! focused->isStuck()) && (!focused->isMoving())) {
current_workspace->setLastFocusedWindow(focused); current_workspace->setLastFocusedWindow(focused);
fluxbox->setFocusedWindow(0); // set focused window to none Fluxbox::instance()->setFocusedWindow(0); // set focused window to none
} }
// set new workspace // set new workspace
current_workspace = getWorkspace(id); current_workspace = getWorkspace(id);
workspacemenu->setItemSelected(current_workspace->workspaceID() + 2, true); workspacemenu->setItemSelected(current_workspace->workspaceID() + 2, true);
toolbar->redrawWorkspaceLabel(true); m_toolbar->redrawWorkspaceLabel(true);
current_workspace->showAll(); current_workspace->showAll();
@ -815,7 +793,7 @@ void BScreen::sendToWorkspace(unsigned int id, FluxboxWindow *win, bool changeWS
return; return;
if (!win) if (!win)
win = fluxbox->getFocusedWindow(); win = Fluxbox::instance()->getFocusedWindow();
if (id != current_workspace->workspaceID()) { if (id != current_workspace->workspaceID()) {
XSync(BaseDisplay::getXDisplay(), True); XSync(BaseDisplay::getXDisplay(), True);
@ -867,8 +845,8 @@ void BScreen::addNetizen(Netizen *n) {
} }
} }
Window f = ((fluxbox->getFocusedWindow()) ? Window f = ((Fluxbox::instance()->getFocusedWindow()) ?
fluxbox->getFocusedWindow()->getClientWindow() : None); Fluxbox::instance()->getFocusedWindow()->getClientWindow() : None);
n->sendWindowFocus(f); n->sendWindowFocus(f);
} }
@ -905,13 +883,6 @@ void BScreen::updateNetizenWorkspaceCount() {
for (; it != it_end; ++it) { for (; it != it_end; ++it) {
(*it)->sendWorkspaceCount(); (*it)->sendWorkspaceCount();
} }
#ifdef NEWWMSPEC
//update _NET_WM_NUMBER_OF_DESKTOPS
int numworkspaces = getCount()-1;
XChangeProperty(getBaseDisplay()->getXDisplay(), getRootWindow(),
getBaseDisplay()->getNETNumberOfDesktopsAtom(), XA_CARDINAL, 32, PropModeReplace,
(unsigned char *)&numworkspaces, 1);
#endif // NEWWMSPEC
m_workspacecount_sig.notify(); m_workspacecount_sig.notify();
@ -922,8 +893,8 @@ void BScreen::updateNetizenWindowFocus() {
Netizens::iterator it = netizenList.begin(); Netizens::iterator it = netizenList.begin();
Netizens::iterator it_end = netizenList.end(); Netizens::iterator it_end = netizenList.end();
Window f = ((fluxbox->getFocusedWindow()) ? Window f = ((Fluxbox::instance()->getFocusedWindow()) ?
fluxbox->getFocusedWindow()->getClientWindow() : None); Fluxbox::instance()->getFocusedWindow()->getClientWindow() : None);
for (; it != it_end; ++it) { for (; it != it_end; ++it) {
(*it)->sendWindowFocus(f); (*it)->sendWindowFocus(f);
} }
@ -984,8 +955,8 @@ void BScreen::raiseWindows(const Workspace::Stack &workspace_stack) {
Window session_stack[(workspace_stack.size() + workspacesList.size() + rootmenuList.size() + 30)]; Window session_stack[(workspace_stack.size() + workspacesList.size() + rootmenuList.size() + 30)];
int i = 0; int i = 0;
XRaiseWindow(getBaseDisplay()->getXDisplay(), iconmenu->windowID()); XRaiseWindow(getBaseDisplay()->getXDisplay(), m_iconmenu->windowID());
session_stack[i++] = iconmenu->windowID(); session_stack[i++] = m_iconmenu->windowID();
Workspaces::iterator wit = workspacesList.begin(); Workspaces::iterator wit = workspacesList.begin();
Workspaces::iterator wit_end = workspacesList.end(); Workspaces::iterator wit_end = workspacesList.end();
@ -1012,13 +983,13 @@ void BScreen::raiseWindows(const Workspace::Stack &workspace_stack) {
#endif // SLIT #endif // SLIT
session_stack[i++] = session_stack[i++] =
toolbar->getMenu()->getPlacementmenu()->windowID(); m_toolbar->getMenu()->getPlacementmenu()->windowID();
#ifdef XINERAMA #ifdef XINERAMA
if (hasXinerama()) { if (hasXinerama()) {
session_stack[i++] = toolbar->getMenu()->getHeadmenu()->windowID(); session_stack[i++] = m_toolbar->getMenu()->getHeadmenu()->windowID();
} }
#endif // XINERAMA #endif // XINERAMA
session_stack[i++] = toolbar->getMenu()->windowID(); session_stack[i++] = m_toolbar->getMenu()->windowID();
Rootmenus::iterator rit = rootmenuList.begin(); Rootmenus::iterator rit = rootmenuList.begin();
Rootmenus::iterator rit_end = rootmenuList.end(); Rootmenus::iterator rit_end = rootmenuList.end();
@ -1027,8 +998,8 @@ void BScreen::raiseWindows(const Workspace::Stack &workspace_stack) {
} }
session_stack[i++] = rootmenu->windowID(); session_stack[i++] = rootmenu->windowID();
if (toolbar->isOnTop()) if (m_toolbar->isOnTop())
session_stack[i++] = toolbar->getWindowID(); session_stack[i++] = m_toolbar->getWindowID();
#ifdef SLIT #ifdef SLIT
if (slit->isOnTop()) if (slit->isOnTop())
@ -1106,7 +1077,7 @@ void BScreen::reassociateWindow(FluxboxWindow *w, unsigned int wkspc_id, bool ig
void BScreen::nextFocus(int opts) { void BScreen::nextFocus(int opts) {
bool have_focused = false; bool have_focused = false;
int focused_window_number = -1; int focused_window_number = -1;
FluxboxWindow *focused = fluxbox->getFocusedWindow(); FluxboxWindow *focused = Fluxbox::instance()->getFocusedWindow();
const int num_windows = getCurrentWorkspace()->getCount(); const int num_windows = getCurrentWorkspace()->getCount();
if (focused != 0) { if (focused != 0) {
@ -1151,7 +1122,7 @@ void BScreen::prevFocus(int opts) {
FluxboxWindow *focused; FluxboxWindow *focused;
int num_windows = getCurrentWorkspace()->getCount(); int num_windows = getCurrentWorkspace()->getCount();
if ((focused = fluxbox->getFocusedWindow())) { if ((focused = Fluxbox::instance()->getFocusedWindow())) {
if (focused->getScreen()->getScreenNumber() == if (focused->getScreen()->getScreenNumber() ==
getScreenNumber()) { getScreenNumber()) {
have_focused = true; have_focused = true;
@ -1192,17 +1163,18 @@ void BScreen::prevFocus(int opts) {
void BScreen::raiseFocus() { void BScreen::raiseFocus() {
bool have_focused = false; bool have_focused = false;
int focused_window_number = -1; int focused_window_number = -1;
Fluxbox * const fb = Fluxbox::instance();
if (fluxbox->getFocusedWindow()) if (fb->getFocusedWindow())
if (fluxbox->getFocusedWindow()->getScreen()->getScreenNumber() == if (fb->getFocusedWindow()->getScreen()->getScreenNumber() ==
getScreenNumber()) { getScreenNumber()) {
have_focused = true; have_focused = true;
focused_window_number = fluxbox->getFocusedWindow()->getWindowNumber(); focused_window_number = fb->getFocusedWindow()->getWindowNumber();
} }
if ((getCurrentWorkspace()->getCount() > 1) && have_focused) if ((getCurrentWorkspace()->getCount() > 1) && have_focused)
getWorkspace(fluxbox->getFocusedWindow()->getWorkspaceNumber())-> getWorkspace(fb->getFocusedWindow()->getWorkspaceNumber())->
raiseWindow(fluxbox->getFocusedWindow()); raiseWindow(fb->getFocusedWindow());
} }
void BScreen::initMenu() { void BScreen::initMenu() {
@ -1217,9 +1189,9 @@ void BScreen::initMenu() {
rootmenu = new Rootmenu(this); rootmenu = new Rootmenu(this);
bool defaultMenu = true; bool defaultMenu = true;
Fluxbox * const fb = Fluxbox::instance();
if (fluxbox->getMenuFilename()) { if (fb->getMenuFilename()) {
ifstream menu_file(fluxbox->getMenuFilename()); ifstream menu_file(fb->getMenuFilename());
if (!menu_file.fail()) { if (!menu_file.fail()) {
if (! menu_file.eof()) { if (! menu_file.eof()) {
@ -1250,11 +1222,11 @@ void BScreen::initMenu() {
i18n->getMessage( i18n->getMessage(
FBNLS::ScreenSet, FBNLS::ScreenEmptyMenuFile, FBNLS::ScreenSet, FBNLS::ScreenEmptyMenuFile,
"%s: Empty menu file"), "%s: Empty menu file"),
fluxbox->getMenuFilename()); fb->getMenuFilename());
} }
menu_file.close(); menu_file.close();
} else } else
perror(fluxbox->getMenuFilename()); perror(fb->getMenuFilename());
} }
if (defaultMenu) { if (defaultMenu) {
@ -1275,7 +1247,7 @@ void BScreen::initMenu() {
"Exit"), "Exit"),
BScreen::EXIT); BScreen::EXIT);
} else } else
fluxbox->saveMenuFilename(fluxbox->getMenuFilename()); fb->saveMenuFilename(fb->getMenuFilename());
} }
// looks through a menufile and adds correct items to the root-menu. // looks through a menufile and adds correct items to the root-menu.
@ -1397,7 +1369,7 @@ bool BScreen::parseMenuFile(ifstream &file, Rootmenu *menu, int &row) {
fclose(submenufile); fclose(submenufile);
ifstream subfile(newfile.c_str()); ifstream subfile(newfile.c_str());
if (! parseMenuFile(subfile, menu, row)) if (! parseMenuFile(subfile, menu, row))
fluxbox->saveMenuFilename(newfile.c_str()); Fluxbox::instance()->saveMenuFilename(newfile.c_str());
} }
} else } else
perror(newfile.c_str()); perror(newfile.c_str());
@ -1541,7 +1513,7 @@ void BScreen::createStyleMenu(Rootmenu *menu, bool newmenu, const char *label, c
rootmenuList.push_back(stylesmenu); rootmenuList.push_back(stylesmenu);
} }
fluxbox->saveMenuFilename(stylesdir.c_str()); Fluxbox::instance()->saveMenuFilename(stylesdir.c_str());
} else { // dir } else { // dir
fprintf(stderr, fprintf(stderr,
i18n-> i18n->
@ -1563,8 +1535,6 @@ void BScreen::createStyleMenu(Rootmenu *menu, bool newmenu, const char *label, c
} }
void BScreen::shutdown() { void BScreen::shutdown() {
fluxbox->grab();
XSelectInput(getBaseDisplay()->getXDisplay(), getRootWindow(), NoEventMask); XSelectInput(getBaseDisplay()->getXDisplay(), getRootWindow(), NoEventMask);
XSync(getBaseDisplay()->getXDisplay(), False); XSync(getBaseDisplay()->getXDisplay(), False);
@ -1587,7 +1557,6 @@ void BScreen::shutdown() {
slit->shutdown(); slit->shutdown();
#endif // SLIT #endif // SLIT
fluxbox->ungrab();
} }
@ -1619,27 +1588,14 @@ void BScreen::showPosition(int x, int y) {
"X: %4d x Y: %4d"), x, y); "X: %4d x Y: %4d"), x, y);
XClearWindow(getBaseDisplay()->getXDisplay(), geom_window); XClearWindow(getBaseDisplay()->getXDisplay(), geom_window);
/*
if (I18n::instance()->multibyte())
XmbDrawString(getBaseDisplay()->getXDisplay(), geom_window,
theme->getWindowStyle().font.set, theme->getWindowStyle().l_text_focus_gc,
theme->getBevelWidth(), theme->getBevelWidth() -
theme->getWindowStyle().font.set_extents->max_ink_extent.y,
label, strlen(label));
else
XDrawString(getBaseDisplay()->getXDisplay(), geom_window,
theme->getWindowStyle().l_text_focus_gc,
theme->getBevelWidth(),
theme->getWindowStyle().font.fontstruct->ascent +
theme->getBevelWidth(), label, strlen(label));
*/
theme->getWindowStyle().font.drawText( theme->getWindowStyle().font.drawText(
geom_window, geom_window,
getScreenNumber(), getScreenNumber(),
theme->getWindowStyle().l_text_focus_gc, theme->getWindowStyle().l_text_focus_gc,
label, strlen(label), label, strlen(label),
theme->getBevelWidth(), theme->getBevelWidth() + theme->getBevelWidth(), theme->getBevelWidth() +
theme->getWindowStyle().font.height()); theme->getWindowStyle().font.ascent());
} }