diff options
author | fluxgen <fluxgen> | 2003-12-11 15:23:14 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2003-12-11 15:23:14 (GMT) |
commit | 96c144540887655c3aa0c391a813fabc38855664 (patch) | |
tree | 7c569eb4ad7b7b9e50fae82e82c32692c26693ac /src | |
parent | 19fe500ba2f98b5e7e12628c7c03c8aeff7d0181 (diff) | |
download | fluxbox-96c144540887655c3aa0c391a813fabc38855664.zip fluxbox-96c144540887655c3aa0c391a813fabc38855664.tar.bz2 |
remember position patch from Mathias Gumz
Diffstat (limited to 'src')
-rw-r--r-- | src/Remember.cc | 64 | ||||
-rw-r--r-- | src/Remember.hh | 21 |
2 files changed, 76 insertions, 9 deletions
diff --git a/src/Remember.cc b/src/Remember.cc index 812b109..43647a0 100644 --- a/src/Remember.cc +++ b/src/Remember.cc | |||
@@ -21,7 +21,7 @@ | |||
21 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 21 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
22 | // DEALINGS IN THE SOFTWARE. | 22 | // DEALINGS IN THE SOFTWARE. |
23 | 23 | ||
24 | // $Id: Remember.cc,v 1.31 2003/12/10 23:08:03 fluxgen Exp $ | 24 | // $Id: Remember.cc,v 1.32 2003/12/11 15:23:14 fluxgen Exp $ |
25 | 25 | ||
26 | #include "Remember.hh" | 26 | #include "Remember.hh" |
27 | #include "ClientPattern.hh" | 27 | #include "ClientPattern.hh" |
@@ -291,10 +291,18 @@ int Remember::parseApp(ifstream &file, Application &app, string *first_line) { | |||
291 | if (line[0] == '#') | 291 | if (line[0] == '#') |
292 | continue; //the line is commented | 292 | continue; //the line is commented |
293 | int parse_pos = 0, err = 0; | 293 | int parse_pos = 0, err = 0; |
294 | string str_key, str_label; | 294 | string str_key, str_option, str_label; |
295 | err = FbTk::StringUtil::getStringBetween(str_key, | 295 | err = FbTk::StringUtil::getStringBetween(str_key, |
296 | line.c_str(), | 296 | line.c_str(), |
297 | '[', ']'); | 297 | '[', ']'); |
298 | if (err > 0) { | ||
299 | int tmp; | ||
300 | tmp= FbTk::StringUtil::getStringBetween(str_option, | ||
301 | line.c_str() + err, | ||
302 | '(', ')'); | ||
303 | if (tmp>0) | ||
304 | err += tmp; | ||
305 | } | ||
298 | if (err > 0 ) { | 306 | if (err > 0 ) { |
299 | parse_pos += err; | 307 | parse_pos += err; |
300 | err = FbTk::StringUtil::getStringBetween(str_label, | 308 | err = FbTk::StringUtil::getStringBetween(str_label, |
@@ -324,10 +332,30 @@ int Remember::parseApp(ifstream &file, Application &app, string *first_line) { | |||
324 | iss >> w >> h; | 332 | iss >> w >> h; |
325 | app.rememberDimensions(w,h); | 333 | app.rememberDimensions(w,h); |
326 | } else if (str_key == "Position") { | 334 | } else if (str_key == "Position") { |
327 | unsigned int x,y; | 335 | FB_istringstream iss; |
328 | FB_istringstream iss(str_label.c_str()); | 336 | unsigned int r= 0; |
337 | unsigned int x= 0; | ||
338 | unsigned int y= 0; | ||
339 | // more info about the parameter | ||
340 | // in ::rememberPosition | ||
341 | |||
342 | if ( str_option.length() ) | ||
343 | { | ||
344 | if ( str_option == "UPPERLEFT" ) r= POS_UPPERLEFT; | ||
345 | else if ( str_option == "UPPERRIGHT" ) r= POS_UPPERRIGHT; | ||
346 | else if ( str_option == "LOWERLEFT" ) r= POS_LOWERLEFT; | ||
347 | else if ( str_option == "LOWERRIGHT" ) r= POS_LOWERRIGHT; | ||
348 | else if ( str_option == "CENTER" ) r= POS_CENTER; | ||
349 | else if ( str_option == "WINCENTER" ) r= POS_WINCENTER; | ||
350 | else { | ||
351 | iss.str(str_option); | ||
352 | iss >> r; | ||
353 | } | ||
354 | } | ||
355 | |||
356 | iss.str(str_label.c_str()); | ||
329 | iss >> x >> y; | 357 | iss >> x >> y; |
330 | app.rememberPosition(x,y); | 358 | app.rememberPosition(x, y, r); |
331 | } else if (str_key == "Shaded") { | 359 | } else if (str_key == "Shaded") { |
332 | app.rememberShadedstate((str_label=="yes")); | 360 | app.rememberShadedstate((str_label=="yes")); |
333 | } else if (str_key == "Tab") { | 361 | } else if (str_key == "Tab") { |
@@ -719,8 +747,32 @@ void Remember::setupFrame(FluxboxWindow &win) { | |||
719 | if (app->dimensions_remember) | 747 | if (app->dimensions_remember) |
720 | win.resize(app->w, app->h); | 748 | win.resize(app->w, app->h); |
721 | 749 | ||
722 | if (app->position_remember) | 750 | if (app->position_remember) { |
751 | switch (app->refc) { | ||
752 | default: | ||
753 | case POS_UPPERLEFT: // upperleft corner | ||
723 | win.move(app->x, app->y); | 754 | win.move(app->x, app->y); |
755 | break; | ||
756 | case POS_UPPERRIGHT: // upperright corner | ||
757 | win.move(screen.width() - win.width() - app->x, app->y); | ||
758 | break; | ||
759 | case POS_LOWERLEFT: // lowerleft corner | ||
760 | win.move(app->x, screen.height() - win.height() - app->y); | ||
761 | break; | ||
762 | case POS_LOWERRIGHT: // lowerright corner | ||
763 | win.move(screen.width() - win.width() - app->x, | ||
764 | screen.height() - win.height() - app->y); | ||
765 | break; | ||
766 | case POS_CENTER: // center of the screen, windows topleft corner is on the center | ||
767 | win.move((screen.width() / 2) + app->x, | ||
768 | (screen.height() / 2) + app->y); | ||
769 | break; | ||
770 | case POS_WINCENTER: // the window is centered REALLY upon the center | ||
771 | win.move((screen.width() / 2) - ( win.width() / 2 ) + app->x, | ||
772 | (screen.height() / 2) - ( win.height() / 2 ) + app->y); | ||
773 | break; | ||
774 | }; | ||
775 | } | ||
724 | 776 | ||
725 | if (app->shadedstate_remember) | 777 | if (app->shadedstate_remember) |
726 | // if inconsistent... | 778 | // if inconsistent... |
diff --git a/src/Remember.hh b/src/Remember.hh index 1671a41..a93e3f5 100644 --- a/src/Remember.hh +++ b/src/Remember.hh | |||
@@ -21,7 +21,7 @@ | |||
21 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 21 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
22 | // DEALINGS IN THE SOFTWARE. | 22 | // DEALINGS IN THE SOFTWARE. |
23 | 23 | ||
24 | // $Id: Remember.hh,v 1.12 2003/07/28 15:06:33 rathnor Exp $ | 24 | // $Id: Remember.hh,v 1.13 2003/12/11 15:23:14 fluxgen Exp $ |
25 | 25 | ||
26 | /* Based on the original "Remember patch" by Xavier Brouckaert */ | 26 | /* Based on the original "Remember patch" by Xavier Brouckaert */ |
27 | 27 | ||
@@ -59,8 +59,8 @@ public: | |||
59 | { workspace = ws; workspace_remember = true; } | 59 | { workspace = ws; workspace_remember = true; } |
60 | inline void rememberDimensions(int width, int height) | 60 | inline void rememberDimensions(int width, int height) |
61 | { w = width; h = height; dimensions_remember = true; } | 61 | { w = width; h = height; dimensions_remember = true; } |
62 | inline void rememberPosition(int posx, int posy) | 62 | inline void rememberPosition(int posx, int posy, unsigned char rfc= 0 ) |
63 | { x = posx; y = posy; position_remember = true; } | 63 | { x = posx; y = posy; refc = rfc; position_remember = true; } |
64 | inline void rememberShadedstate(bool state) | 64 | inline void rememberShadedstate(bool state) |
65 | { shadedstate = state; shadedstate_remember = true; } | 65 | { shadedstate = state; shadedstate_remember = true; } |
66 | inline void rememberTabstate(bool state) | 66 | inline void rememberTabstate(bool state) |
@@ -85,6 +85,10 @@ public: | |||
85 | 85 | ||
86 | bool position_remember; | 86 | bool position_remember; |
87 | int x,y; | 87 | int x,y; |
88 | unsigned char refc; // referenceCorner-> 0 - upperleft | ||
89 | // 1 - upperight | ||
90 | // 2 - lowerleft | ||
91 | // 3 - lowerright | ||
88 | 92 | ||
89 | bool shadedstate_remember; | 93 | bool shadedstate_remember; |
90 | bool shadedstate; | 94 | bool shadedstate; |
@@ -138,6 +142,17 @@ public: | |||
138 | REM_LASTATTRIB // not actually used | 142 | REM_LASTATTRIB // not actually used |
139 | }; | 143 | }; |
140 | 144 | ||
145 | enum { | ||
146 | POS_UPPERLEFT= 0, | ||
147 | POS_UPPERRIGHT, | ||
148 | POS_LOWERLEFT, | ||
149 | POS_LOWERRIGHT, | ||
150 | POS_CENTER, | ||
151 | POS_WINCENTER | ||
152 | }; | ||
153 | |||
154 | |||
155 | |||
141 | // a "pattern" to the relevant app | 156 | // a "pattern" to the relevant app |
142 | // each app exists ONLY for that pattern. | 157 | // each app exists ONLY for that pattern. |
143 | // And we need to keep a list of pairs as we want to keep the | 158 | // And we need to keep a list of pairs as we want to keep the |