diff options
author | Mark Tiefenbruck <mark@fluxbox.org> | 2008-08-18 12:12:30 (GMT) |
---|---|---|
committer | Mark Tiefenbruck <mark@fluxbox.org> | 2008-08-18 12:12:30 (GMT) |
commit | 37b18a9694122e285286757df2a74213b8d27a3e (patch) | |
tree | 035d68db3def39a72ce9d41e7337e93c7e768560 /src/Remember.cc | |
parent | 2ab539073b115e3e05cab6b95c4ea638bd8d1b6f (diff) | |
download | fluxbox-37b18a9694122e285286757df2a74213b8d27a3e.zip fluxbox-37b18a9694122e285286757df2a74213b8d27a3e.tar.bz2 |
combined code for saved window positions and MoveTo key command
added left, right, top, and bottom center reference points
Diffstat (limited to 'src/Remember.cc')
-rw-r--r-- | src/Remember.cc | 91 |
1 files changed, 30 insertions, 61 deletions
diff --git a/src/Remember.cc b/src/Remember.cc index 3e9e16a..d5b2ece 100644 --- a/src/Remember.cc +++ b/src/Remember.cc | |||
@@ -103,7 +103,8 @@ public: | |||
103 | { focushiddenstate= state; focushiddenstate_remember= true; } | 103 | { focushiddenstate= state; focushiddenstate_remember= true; } |
104 | void rememberIconHiddenstate(bool state) | 104 | void rememberIconHiddenstate(bool state) |
105 | { iconhiddenstate= state; iconhiddenstate_remember= true; } | 105 | { iconhiddenstate= state; iconhiddenstate_remember= true; } |
106 | void rememberPosition(int posx, int posy, unsigned char rfc= 0 ) | 106 | void rememberPosition(int posx, int posy, |
107 | FluxboxWindow::ReferenceCorner rfc = FluxboxWindow::LEFTTOP) | ||
107 | { x = posx; y = posy; refc = rfc; position_remember = true; } | 108 | { x = posx; y = posy; refc = rfc; position_remember = true; } |
108 | void rememberShadedstate(bool state) | 109 | void rememberShadedstate(bool state) |
109 | { shadedstate = state; shadedstate_remember = true; } | 110 | { shadedstate = state; shadedstate_remember = true; } |
@@ -139,10 +140,7 @@ public: | |||
139 | 140 | ||
140 | bool position_remember; | 141 | bool position_remember; |
141 | int x,y; | 142 | int x,y; |
142 | unsigned char refc; // referenceCorner-> 0 - upperleft | 143 | FluxboxWindow::ReferenceCorner refc; |
143 | // 1 - upperight | ||
144 | // 2 - lowerleft | ||
145 | // 3 - lowerright | ||
146 | 144 | ||
147 | bool alpha_remember; | 145 | bool alpha_remember; |
148 | int focused_alpha; | 146 | int focused_alpha; |
@@ -477,27 +475,16 @@ int parseApp(ifstream &file, Application &app, string *first_line = 0) { | |||
477 | else | 475 | else |
478 | had_error = true; | 476 | had_error = true; |
479 | } else if (str_key == "position") { | 477 | } else if (str_key == "position") { |
480 | unsigned int r= 0; | 478 | FluxboxWindow::ReferenceCorner r = FluxboxWindow::LEFTTOP; |
481 | unsigned int x= 0; | 479 | int x = 0, y = 0; |
482 | unsigned int y= 0; | ||
483 | // more info about the parameter | 480 | // more info about the parameter |
484 | // in ::rememberPosition | 481 | // in ::rememberPosition |
485 | 482 | ||
486 | str_option == FbTk::StringUtil::toUpper(str_option); | 483 | if (str_option.length()) |
487 | if ( str_option.length() ) | 484 | r = FluxboxWindow::getCorner(str_option); |
488 | { | 485 | had_error = (r == FluxboxWindow::ERROR); |
489 | if (str_option == "UPPERLEFT") r= Remember::POS_UPPERLEFT; | ||
490 | else if (str_option == "UPPERRIGHT") r= Remember::POS_UPPERRIGHT; | ||
491 | else if (str_option == "LOWERLEFT") r= Remember::POS_LOWERLEFT; | ||
492 | else if (str_option == "LOWERRIGHT") r= Remember::POS_LOWERRIGHT; | ||
493 | else if (str_option == "CENTER") r= Remember::POS_CENTER; | ||
494 | else if (str_option == "WINCENTER") r= Remember::POS_WINCENTER; | ||
495 | else if (!getuint(str_option.c_str(), r)) { | ||
496 | had_error = 1; | ||
497 | } | ||
498 | } | ||
499 | 486 | ||
500 | if (!had_error && sscanf(str_label.c_str(), "%u %u", &x, &y) == 2) | 487 | if (!had_error && sscanf(str_label.c_str(), "%d %d", &x, &y) == 2) |
501 | app.rememberPosition(x, y, r); | 488 | app.rememberPosition(x, y, r); |
502 | else | 489 | else |
503 | had_error = true; | 490 | had_error = true; |
@@ -916,21 +903,30 @@ void Remember::save() { | |||
916 | if (a.position_remember) { | 903 | if (a.position_remember) { |
917 | apps_file << " [Position]\t("; | 904 | apps_file << " [Position]\t("; |
918 | switch(a.refc) { | 905 | switch(a.refc) { |
919 | case POS_WINCENTER: | 906 | case FluxboxWindow::CENTER: |
920 | apps_file << "WINCENTER"; | ||
921 | break; | ||
922 | case POS_CENTER: | ||
923 | apps_file << "CENTER"; | 907 | apps_file << "CENTER"; |
924 | break; | 908 | break; |
925 | case POS_LOWERLEFT: | 909 | case FluxboxWindow::LEFTBOTTOM: |
926 | apps_file << "LOWERLEFT"; | 910 | apps_file << "LOWERLEFT"; |
927 | break; | 911 | break; |
928 | case POS_LOWERRIGHT: | 912 | case FluxboxWindow::RIGHTBOTTOM: |
929 | apps_file << "LOWERRIGHT"; | 913 | apps_file << "LOWERRIGHT"; |
930 | break; | 914 | break; |
931 | case POS_UPPERRIGHT: | 915 | case FluxboxWindow::RIGHTTOP: |
932 | apps_file << "UPPERRIGHT"; | 916 | apps_file << "UPPERRIGHT"; |
933 | break; | 917 | break; |
918 | case FluxboxWindow::LEFT: | ||
919 | apps_file << "LEFT"; | ||
920 | break; | ||
921 | case FluxboxWindow::RIGHT: | ||
922 | apps_file << "RIGHT"; | ||
923 | break; | ||
924 | case FluxboxWindow::TOP: | ||
925 | apps_file << "TOP"; | ||
926 | break; | ||
927 | case FluxboxWindow::BOTTOM: | ||
928 | apps_file << "BOTTOM"; | ||
929 | break; | ||
934 | default: | 930 | default: |
935 | apps_file << "UPPERLEFT"; | 931 | apps_file << "UPPERLEFT"; |
936 | } | 932 | } |
@@ -1114,8 +1110,8 @@ void Remember::rememberAttrib(WinClient &winclient, Attribute attrib) { | |||
1114 | break; | 1110 | break; |
1115 | case REM_POSITION: { | 1111 | case REM_POSITION: { |
1116 | int head = win->screen().getHead(win->fbWindow()); | 1112 | int head = win->screen().getHead(win->fbWindow()); |
1117 | int head_x = win->screen().getHeadX(head); | 1113 | int head_x = win->screen().maxLeft(head); |
1118 | int head_y = win->screen().getHeadY(head); | 1114 | int head_y = win->screen().maxTop(head); |
1119 | app->rememberPosition(win->normalX() - head_x, win->normalY() - head_y); | 1115 | app->rememberPosition(win->normalX() - head_x, win->normalY() - head_y); |
1120 | break; | 1116 | break; |
1121 | } | 1117 | } |
@@ -1275,37 +1271,10 @@ void Remember::setupFrame(FluxboxWindow &win) { | |||
1275 | if (app->dimensions_remember) | 1271 | if (app->dimensions_remember) |
1276 | win.resize(app->w, app->h); | 1272 | win.resize(app->w, app->h); |
1277 | 1273 | ||
1278 | int head = screen.getHead(win.fbWindow()); | ||
1279 | |||
1280 | if (app->position_remember) { | 1274 | if (app->position_remember) { |
1281 | 1275 | int newx = app->x, newy = app->y; | |
1282 | switch (app->refc) { | 1276 | win.translateCoords(newx, newy, app->refc); |
1283 | default: | 1277 | win.move(newx, newy); |
1284 | case POS_UPPERLEFT: // upperleft corner | ||
1285 | win.move(screen.getHeadX(head) + app->x, | ||
1286 | screen.getHeadY(head) + app->y); | ||
1287 | break; | ||
1288 | case POS_UPPERRIGHT: // upperright corner | ||
1289 | win.move(screen.getHeadX(head) + screen.getHeadWidth(head) - win.width() - app->x, | ||
1290 | screen.getHeadY(head) + app->y); | ||
1291 | break; | ||
1292 | case POS_LOWERLEFT: // lowerleft corner | ||
1293 | win.move(screen.getHeadX(head) + app->x, | ||
1294 | screen.getHeadHeight(head) - win.height() - app->y); | ||
1295 | break; | ||
1296 | case POS_LOWERRIGHT: // lowerright corner | ||
1297 | win.move(screen.getHeadWidth(head) - win.width() - app->x, | ||
1298 | screen.getHeadHeight(head) - win.height() - app->y); | ||
1299 | break; | ||
1300 | case POS_CENTER: // center of the screen, windows topleft corner is on the center | ||
1301 | win.move((screen.getHeadWidth(head) / 2) + app->x, | ||
1302 | (screen.getHeadHeight(head) / 2) + app->y); | ||
1303 | break; | ||
1304 | case POS_WINCENTER: // the window is centered REALLY upon the center | ||
1305 | win.move((screen.getHeadWidth(head) / 2) - ( win.width() / 2 ) + app->x, | ||
1306 | (screen.getHeadHeight(head) / 2) - ( win.height() / 2 ) + app->y); | ||
1307 | break; | ||
1308 | }; | ||
1309 | } | 1278 | } |
1310 | 1279 | ||
1311 | if (app->shadedstate_remember) | 1280 | if (app->shadedstate_remember) |