aboutsummaryrefslogtreecommitdiff
path: root/src/Remember.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/Remember.cc')
-rw-r--r--src/Remember.cc104
1 files changed, 76 insertions, 28 deletions
diff --git a/src/Remember.cc b/src/Remember.cc
index c4eeb25..626522c 100644
--- a/src/Remember.cc
+++ b/src/Remember.cc
@@ -54,7 +54,6 @@
54#define _GNU_SOURCE 54#define _GNU_SOURCE
55#endif // _GNU_SOURCE 55#endif // _GNU_SOURCE
56 56
57#include <iostream>
58#include <set> 57#include <set>
59 58
60 59
@@ -99,15 +98,24 @@ public:
99 { workspace = ws; workspace_remember = true; } 98 { workspace = ws; workspace_remember = true; }
100 void rememberHead(int h) 99 void rememberHead(int h)
101 { head = h; head_remember = true; } 100 { head = h; head_remember = true; }
102 void rememberDimensions(int width, int height) 101 void rememberDimensions(int width, int height, bool is_relative)
103 { w = width; h = height; dimensions_remember = true; } 102 {
103 dimension_is_relative = is_relative;
104 w = width; h = height;
105 dimensions_remember = true;
106 }
104 void rememberFocusHiddenstate(bool state) 107 void rememberFocusHiddenstate(bool state)
105 { focushiddenstate= state; focushiddenstate_remember= true; } 108 { focushiddenstate= state; focushiddenstate_remember= true; }
106 void rememberIconHiddenstate(bool state) 109 void rememberIconHiddenstate(bool state)
107 { iconhiddenstate= state; iconhiddenstate_remember= true; } 110 { iconhiddenstate= state; iconhiddenstate_remember= true; }
108 void rememberPosition(int posx, int posy, 111 void rememberPosition(int posx, int posy, bool is_relative,
109 FluxboxWindow::ReferenceCorner rfc = FluxboxWindow::LEFTTOP) 112 FluxboxWindow::ReferenceCorner rfc = FluxboxWindow::LEFTTOP)
110 { x = posx; y = posy; refc = rfc; position_remember = true; } 113 {
114 position_is_relative = is_relative;
115 x = posx; y = posy;
116 refc = rfc;
117 position_remember = true;
118 }
111 void rememberShadedstate(bool state) 119 void rememberShadedstate(bool state)
112 { shadedstate = state; shadedstate_remember = true; } 120 { shadedstate = state; shadedstate_remember = true; }
113 void rememberTabstate(bool state) 121 void rememberTabstate(bool state)
@@ -120,7 +128,7 @@ public:
120 { focusnewwindow = state; focusnewwindow_remember = true; } 128 { focusnewwindow = state; focusnewwindow_remember = true; }
121 void rememberJumpworkspace(bool state) 129 void rememberJumpworkspace(bool state)
122 { jumpworkspace = state; jumpworkspace_remember = true; } 130 { jumpworkspace = state; jumpworkspace_remember = true; }
123 void rememberLayer(int layernum) 131 void rememberLayer(int layernum)
124 { layer = layernum; layer_remember = true; } 132 { layer = layernum; layer_remember = true; }
125 void rememberSaveOnClose(bool state) 133 void rememberSaveOnClose(bool state)
126 { save_on_close = state; save_on_close_remember = true; } 134 { save_on_close = state; save_on_close_remember = true; }
@@ -141,9 +149,11 @@ public:
141 149
142 bool dimensions_remember; 150 bool dimensions_remember;
143 int w,h; // width, height 151 int w,h; // width, height
152 bool dimension_is_relative;
144 153
145 bool position_remember; 154 bool position_remember;
146 int x,y; 155 int x,y;
156 bool position_is_relative;
147 FluxboxWindow::ReferenceCorner refc; 157 FluxboxWindow::ReferenceCorner refc;
148 158
149 bool alpha_remember; 159 bool alpha_remember;
@@ -483,10 +493,13 @@ int parseApp(ifstream &file, Application &app, string *first_line = 0) {
483 app.rememberLayer(l); 493 app.rememberLayer(l);
484 } else if (str_key == "dimensions") { 494 } else if (str_key == "dimensions") {
485 unsigned int h,w; 495 unsigned int h,w;
486 if (sscanf(str_label.c_str(), "%u %u", &w, &h) == 2) 496 if (sscanf(str_label.c_str(), "%u %u", &w, &h) == 2) {
487 app.rememberDimensions(w, h); 497 app.rememberDimensions(w, h, false);
488 else 498 } else if(sscanf(str_label.c_str(), "%u%% %u%%", &w, &h) == 2) {
499 app.rememberDimensions(w, h, true);
500 } else {
489 had_error = true; 501 had_error = true;
502 }
490 } else if (str_key == "position") { 503 } else if (str_key == "position") {
491 FluxboxWindow::ReferenceCorner r = FluxboxWindow::LEFTTOP; 504 FluxboxWindow::ReferenceCorner r = FluxboxWindow::LEFTTOP;
492 int x = 0, y = 0; 505 int x = 0, y = 0;
@@ -497,10 +510,15 @@ int parseApp(ifstream &file, Application &app, string *first_line = 0) {
497 r = FluxboxWindow::getCorner(str_option); 510 r = FluxboxWindow::getCorner(str_option);
498 had_error = (r == FluxboxWindow::ERROR); 511 had_error = (r == FluxboxWindow::ERROR);
499 512
500 if (!had_error && sscanf(str_label.c_str(), "%d %d", &x, &y) == 2) 513 if (!had_error){
501 app.rememberPosition(x, y, r); 514 if(sscanf(str_label.c_str(), "%d %d", &x, &y) == 2) {
502 else 515 app.rememberPosition(x, y, false, r);
516 } else if (sscanf(str_label.c_str(), "%d%% %d%%", &x, &y) == 2){
517 app.rememberPosition(x, y, true, r);
518 }
519 } else {
503 had_error = true; 520 had_error = true;
521 }
504 } else if (str_key == "shaded") { 522 } else if (str_key == "shaded") {
505 app.rememberShadedstate((strcasecmp(str_label.c_str(), "yes") == 0)); 523 app.rememberShadedstate((strcasecmp(str_label.c_str(), "yes") == 0));
506 } else if (str_key == "tab") { 524 } else if (str_key == "tab") {
@@ -910,7 +928,11 @@ void Remember::save() {
910 apps_file << " [Head]\t{" << a.head << "}" << endl; 928 apps_file << " [Head]\t{" << a.head << "}" << endl;
911 } 929 }
912 if (a.dimensions_remember) { 930 if (a.dimensions_remember) {
913 apps_file << " [Dimensions]\t{" << a.w << " " << a.h << "}" << endl; 931 if(a.dimension_is_relative) {
932 apps_file << " [Dimensions]\t{" << a.w << "% " << a.h << "%}" << endl;
933 } else {
934 apps_file << " [Dimensions]\t{" << a.w << " " << a.h << "}" << endl;
935 }
914 } 936 }
915 if (a.position_remember) { 937 if (a.position_remember) {
916 apps_file << " [Position]\t("; 938 apps_file << " [Position]\t(";
@@ -942,7 +964,11 @@ void Remember::save() {
942 default: 964 default:
943 apps_file << "UPPERLEFT"; 965 apps_file << "UPPERLEFT";
944 } 966 }
945 apps_file << ")\t{" << a.x << " " << a.y << "}" << endl; 967 if(a.position_is_relative) {
968 apps_file << ")\t{" << a.x << "% " << a.y << "%}" << endl;
969 } else {
970 apps_file << ")\t{" << a.x << " " << a.y << "}" << endl;
971 }
946 } 972 }
947 if (a.shadedstate_remember) { 973 if (a.shadedstate_remember) {
948 apps_file << " [Shaded]\t{" << ((a.shadedstate)?"yes":"no") << "}" << endl; 974 apps_file << " [Shaded]\t{" << ((a.shadedstate)?"yes":"no") << "}" << endl;
@@ -1029,7 +1055,7 @@ void Remember::save() {
1029 if (a.alpha_remember) { 1055 if (a.alpha_remember) {
1030 if (a.focused_alpha == a.unfocused_alpha) 1056 if (a.focused_alpha == a.unfocused_alpha)
1031 apps_file << " [Alpha]\t{" << a.focused_alpha << "}" << endl; 1057 apps_file << " [Alpha]\t{" << a.focused_alpha << "}" << endl;
1032 else 1058 else
1033 apps_file << " [Alpha]\t{" << a.focused_alpha << " " << a.unfocused_alpha << "}" << endl; 1059 apps_file << " [Alpha]\t{" << a.focused_alpha << " " << a.unfocused_alpha << "}" << endl;
1034 } 1060 }
1035 apps_file << "[end]" << endl; 1061 apps_file << "[end]" << endl;
@@ -1110,6 +1136,7 @@ void Remember::rememberAttrib(WinClient &winclient, Attribute attrib) {
1110 app = add(winclient); 1136 app = add(winclient);
1111 if (!app) return; 1137 if (!app) return;
1112 } 1138 }
1139 int head, head_x, head_y, win_w, win_h, percx, percy;
1113 switch (attrib) { 1140 switch (attrib) {
1114 case REM_WORKSPACE: 1141 case REM_WORKSPACE:
1115 app->rememberWorkspace(win->workspaceNumber()); 1142 app->rememberWorkspace(win->workspaceNumber());
@@ -1117,16 +1144,18 @@ void Remember::rememberAttrib(WinClient &winclient, Attribute attrib) {
1117 case REM_HEAD: 1144 case REM_HEAD:
1118 app->rememberHead(win->screen().getHead(win->fbWindow())); 1145 app->rememberHead(win->screen().getHead(win->fbWindow()));
1119 break; 1146 break;
1120 case REM_DIMENSIONS: 1147 case REM_DIMENSIONS: {
1121 app->rememberDimensions(win->normalWidth(), 1148 head = win->screen().getHead(win->fbWindow());
1122 win->normalHeight()); 1149 int percx = win->screen().calRelativeDimensionWidth(head, win->normalWidth());
1150 int percy = win->screen().calRelativeDimensionHeight(head, win->normalHeight());
1151 app->rememberDimensions(percx, percy, true);
1123 break; 1152 break;
1153 }
1124 case REM_POSITION: { 1154 case REM_POSITION: {
1125 int head = win->screen().getHead(win->fbWindow()); 1155 head = win->screen().getHead(win->fbWindow());
1126 int head_x = win->screen().maxLeft(head); 1156 int percx = win->screen().calRelativePositionWidth(head, win->normalX());
1127 int head_y = win->screen().maxTop(head); 1157 int percy = win->screen().calRelativePositionHeight(head, win->normalY());
1128 app->rememberPosition(win->normalX() - head_x, 1158 app->rememberPosition(percx, percy, true);
1129 win->normalY() - head_y);
1130 break; 1159 break;
1131 } 1160 }
1132 case REM_FOCUSHIDDENSTATE: 1161 case REM_FOCUSHIDDENSTATE:
@@ -1288,13 +1317,32 @@ void Remember::setupFrame(FluxboxWindow &win) {
1288 win.setOnHead(app->head); 1317 win.setOnHead(app->head);
1289 } 1318 }
1290 1319
1291 if (app->dimensions_remember) 1320 if (app->dimensions_remember) {
1292 win.resize(app->w, app->h); 1321
1322 int win_w, win_h;
1323 if(app->dimension_is_relative) {
1324 int head = screen.getHead(win.fbWindow());
1325 int screen_y = screen.maxBottom(head) - screen.maxTop(head);
1326 win_w = screen.calRelativeWidth(head, app->w);
1327 win_h = screen.calRelativeHeight(head, app->h);
1328 } else {
1329 win_w = app->w;
1330 win_h = app->h;
1331 }
1332 win.resize(win_w, win_h);
1333 }
1293 1334
1294 if (app->position_remember) { 1335 if (app->position_remember) {
1295 int newx = app->x, newy = app->y; 1336 int newx, newy;
1296 win.translateCoords(newx, newy, app->refc); 1337 if(app->position_is_relative) {
1297 win.move(newx, newy); 1338 int head = screen.getHead(win.fbWindow());
1339 newx = screen.calRelativeWidth(head, app->x);
1340 newy = screen.calRelativeHeight(head, app->y);
1341 } else {
1342 newx = app->x, newy = app->y;
1343 }
1344 win.translateCoords(newx, newy, app->refc);
1345 win.move(newx, newy);
1298 } 1346 }
1299 1347
1300 if (app->shadedstate_remember) 1348 if (app->shadedstate_remember)