all repos — fluxbox @ d44da76ad45ad9c259c7075ea85b98b55ca18e1a

custom fork of the fluxbox windowmanager

indentation and minor fixes
fluxgen fluxgen
commit

d44da76ad45ad9c259c7075ea85b98b55ca18e1a

parent

0c2888202505bfcdf631d870f607aafb9ccc5bec

1 files changed, 72 insertions(+), 65 deletions(-)

jump to
M src/Remember.ccsrc/Remember.cc

@@ -20,22 +20,28 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Remember.cc,v 1.3 2003/04/26 12:01:55 rathnor Exp $ +// $Id: Remember.cc,v 1.4 2003/04/26 12:46:18 fluxgen Exp $ #include "Remember.hh" #include "StringUtil.hh" +#include "Screen.hh" +#include "Window.hh" #include "WinClient.hh" #include "FbMenu.hh" #include "MenuItem.hh" +#include "App.hh" // TODO get rid of these #define RC_PATH "fluxbox" #define RC_INIT_FILE "init" +#include <X11/Xlib.h> + //use GNU extensions #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif // _GNU_SOURCE + #include <iostream> #include <sstream>

@@ -43,11 +49,11 @@ #include <fstream>

#include <string> #include <memory> +using namespace std; + #ifndef MAXPATHLEN #define MAXPATHLEN 255 #endif // MAXPATHLEN - -using namespace std; namespace {

@@ -98,28 +104,52 @@ *screen.layerManager().getLayer(Fluxbox::instance()->getMenuLayer()));

// TODO: nls menu->insert(new RememberMenuItem("Workspace", remember, win, - Remember::REM_WORKSPACE)); + Remember::REM_WORKSPACE)); menu->insert(new RememberMenuItem("Jump to workspace", remember, win, - Remember::REM_JUMPWORKSPACE)); + Remember::REM_JUMPWORKSPACE)); menu->insert(new RememberMenuItem("Dimensions", remember, win, - Remember::REM_DIMENSIONS)); + Remember::REM_DIMENSIONS)); menu->insert(new RememberMenuItem("Position", remember, win, - Remember::REM_POSITION)); + Remember::REM_POSITION)); menu->insert(new RememberMenuItem("Sticky", remember, win, - Remember::REM_STUCKSTATE)); + Remember::REM_STUCKSTATE)); menu->insert(new RememberMenuItem("Decorations", remember, win, - Remember::REM_DECOSTATE)); + Remember::REM_DECOSTATE)); menu->insert(new RememberMenuItem("Shaded", remember, win, - Remember::REM_SHADEDSTATE)); -// menu->insert(new RememberMenuItem("Tab", remember, win, -// Remember::REM_TABSTATE)); + Remember::REM_SHADEDSTATE)); + // menu->insert(new RememberMenuItem("Tab", remember, win, + // Remember::REM_TABSTATE)); menu->insert(new RememberMenuItem("Save on close", remember, win, - Remember::REM_SAVEONCLOSE)); + Remember::REM_SAVEONCLOSE)); menu->update(); return menu; }; +const char * getWMClass(Window w) { + XClassHint ch; + + if (XGetClassHint(FbTk::App::instance()->display(), w, &ch) == 0) { + cerr<<"Failed to read class hint!"<<endl; + return 0; + } else { + string m_class_name; + if (ch.res_name != 0) { + //m_instance_name = const_cast<char *>(ch.res_name); + XFree(ch.res_name); + } else {} + //m_instance_name = ""; + + if (ch.res_class != 0) { + m_class_name = const_cast<char *>(ch.res_class); + XFree(ch.res_class); + } else { + m_class_name = ""; + } + return m_class_name.c_str(); + } +} + }; Application::Application() {

@@ -140,58 +170,29 @@ }

Application* Remember::add(const char* app_name) { if (!app_name) - return NULL; + return 0; Application* a = new Application(); apps[app_name] = a; return a; } -// FIXME, I am evil -#include "X11/Xlib.h" -#include "App.hh" - -const char * getWMClass(Window w) { - XClassHint ch; - - if (XGetClassHint(FbTk::App::instance()->display(), w, &ch) == 0) { - cerr<<"Failed to read class hint!"<<endl; - return 0; - } else { - string m_class_name; - if (ch.res_name != 0) { - //m_instance_name = const_cast<char *>(ch.res_name); - XFree(ch.res_name); - } else {} - //m_instance_name = ""; - - if (ch.res_class != 0) { - m_class_name = const_cast<char *>(ch.res_class); - XFree(ch.res_class); - } else { - m_class_name = ""; - } - return m_class_name.c_str(); - } -} - - Application* Remember::find(WinClient &winclient) { - return find(getWMClass(winclient.fbwindow()->getClientWindow())); //FIXME + return find(getWMClass(winclient.window())); } Application* Remember::add(WinClient &winclient) { - return add(getWMClass(winclient.fbwindow()->getClientWindow())); //FIXME + return add(getWMClass(winclient.window)); } Application* Remember::find(const char* app_name) { if (!app_name) - return NULL; + return 0; Apps::iterator i = apps.find(app_name); if (i!=apps.end()) return i->second; else - return NULL; + return 0; } int Remember::parseApp(ifstream &file, Application *a) {

@@ -206,7 +207,9 @@ string str_key, str_label;

err = StringUtil::getStringBetween(str_key, line.c_str(), '[', ']'); if (err > 0 ) { parse_pos += err; - err = StringUtil::getStringBetween(str_label, line.c_str() + parse_pos, '{', '}'); + err = StringUtil::getStringBetween(str_label, + line.c_str() + parse_pos, + '{', '}'); if (err>0) { parse_pos += err; }

@@ -240,15 +243,15 @@ } else if (str_label == "NORMAL") {

a->rememberDecostate((unsigned int) 0xfffffff); } else if (str_label == "TINY") { a->rememberDecostate((unsigned int) - FluxboxWindow::DECORM_TITLEBAR - | FluxboxWindow::DECORM_ICONIFY - | FluxboxWindow::DECORM_MENU - ); + FluxboxWindow::DECORM_TITLEBAR + | FluxboxWindow::DECORM_ICONIFY + | FluxboxWindow::DECORM_MENU + ); } else if (str_label == "TOOL") { a->rememberDecostate((unsigned int) - FluxboxWindow::DECORM_TITLEBAR - | FluxboxWindow::DECORM_MENU - ); + FluxboxWindow::DECORM_TITLEBAR + | FluxboxWindow::DECORM_MENU + ); } else { unsigned int mask; const char * str = str_label.c_str();

@@ -280,11 +283,13 @@ return row;

} void Remember::load() { + + string apps_string = getenv("HOME")+string("/.")+RC_PATH+string("/")+"apps"; #ifdef DEBUG - cerr << "Loading apps file..." << endl; + cerr<<__FILE__<<"("<<__FUNCTION__<<"): Loading apps file ["<<apps_string<<"]"<<endl; #endif // DEBUG - string apps_string = getenv("HOME")+string("/.")+RC_PATH+string("/")+"apps"; ifstream apps_file(apps_string.c_str()); + if (!apps_file.fail()) { if (!apps_file.eof()) { string line;

@@ -318,7 +323,7 @@

} } else { #ifdef DEBUG - cerr<<__FILE__<<"("<<__LINE__<< ") Empty apps file" << endl; + cerr<<__FILE__<<"("<<__FUNCTION__<< ") Empty apps file" << endl; #endif } } else {

@@ -328,7 +333,7 @@ }

void Remember::save() { #ifdef DEBUG - cerr << "Saving apps file..." << endl; + cerr<<__FILE__<<"("<<__FUNCTION__<<"): Saving apps file..."<<endl; #endif // DEBUG string apps_string = getenv("HOME")+string("/.")+RC_PATH+string("/")+"apps"; ofstream apps_file(apps_string.c_str());

@@ -410,9 +415,9 @@ break;

case REM_SHADEDSTATE: return app->shadedstate_remember; break; -// case REM_TABSTATE: -// return app->tabstate_remember; -// break; + // case REM_TABSTATE: + // return app->tabstate_remember; + // break; case REM_JUMPWORKSPACE: return app->jumpworkspace_remember; break;

@@ -452,8 +457,8 @@ break;

case REM_SHADEDSTATE: app->rememberStuckstate(win->isStuck()); break; -// case REM_TABSTATE: -// break; + // case REM_TABSTATE: + // break; case REM_JUMPWORKSPACE: app->rememberJumpworkspace(true); break;

@@ -555,7 +560,9 @@ win.stick(); // toggles

// add the menu, this -2 is somewhat dodgy... :-/ // TODO: nls - win.getWindowmenu().insert("Remember...", createRememberMenu(*this, win), win.getWindowmenu().numberOfItems()-2); + win.getWindowmenu().insert("Remember...", + createRememberMenu(*this, win), + win.getWindowmenu().numberOfItems()-2); win.getWindowmenu().update(); }