diff options
author | Mark Tiefenbruck <mark@fluxbox.org> | 2008-08-27 20:29:35 (GMT) |
---|---|---|
committer | Mark Tiefenbruck <mark@fluxbox.org> | 2008-08-27 20:29:35 (GMT) |
commit | a2ec0c9bdd9ebcc713426a79209b9ca90b4db301 (patch) | |
tree | 3d7b659c38f3b01e4e09a4887dc7b7cf1f73689b | |
parent | 84c87a86f9365014b7425c56a2a1051c102df804 (diff) | |
download | fluxbox_pavel-a2ec0c9bdd9ebcc713426a79209b9ca90b4db301.zip fluxbox_pavel-a2ec0c9bdd9ebcc713426a79209b9ca90b4db301.tar.bz2 |
make FbWinFrame and FluxboxWindow share a WindowState object
-rw-r--r-- | src/FbWinFrame.cc | 43 | ||||
-rw-r--r-- | src/FbWinFrame.hh | 19 | ||||
-rw-r--r-- | src/Remember.cc | 8 | ||||
-rw-r--r-- | src/ScreenPlacement.cc | 4 | ||||
-rw-r--r-- | src/Window.cc | 102 | ||||
-rw-r--r-- | src/Window.hh | 26 | ||||
-rw-r--r-- | src/WindowState.cc | 30 | ||||
-rw-r--r-- | src/WindowState.hh | 10 |
8 files changed, 107 insertions, 135 deletions
diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc index 1a98ff5..0fa71d5 100644 --- a/src/FbWinFrame.cc +++ b/src/FbWinFrame.cc | |||
@@ -43,14 +43,12 @@ using std::string; | |||
43 | 43 | ||
44 | FbWinFrame::FbWinFrame(BScreen &screen, | 44 | FbWinFrame::FbWinFrame(BScreen &screen, |
45 | FocusableTheme<FbWinFrameTheme> &theme, | 45 | FocusableTheme<FbWinFrameTheme> &theme, |
46 | FbTk::ImageControl &imgctrl, | 46 | FbTk::XLayer &layer, WindowState &state): |
47 | FbTk::XLayer &layer, | ||
48 | int x, int y, | ||
49 | unsigned int width, unsigned int height): | ||
50 | m_screen(screen), | 47 | m_screen(screen), |
51 | m_theme(theme), | 48 | m_theme(theme), |
52 | m_imagectrl(imgctrl), | 49 | m_imagectrl(screen.imageControl()), |
53 | m_window(theme->screenNum(), x, y, width, height, | 50 | m_state(state), |
51 | m_window(theme->screenNum(), state.x, state.y, state.width, state.height, | ||
54 | ButtonPressMask | ButtonReleaseMask | | 52 | ButtonPressMask | ButtonReleaseMask | |
55 | ButtonMotionMask | EnterWindowMask | | 53 | ButtonMotionMask | EnterWindowMask | |
56 | LeaveWindowMask, true), | 54 | LeaveWindowMask, true), |
@@ -189,19 +187,6 @@ void FbWinFrame::show() { | |||
189 | m_window.show(); | 187 | m_window.show(); |
190 | } | 188 | } |
191 | 189 | ||
192 | /** | ||
193 | Toggle shade state, and resize window | ||
194 | */ | ||
195 | void FbWinFrame::shade() { | ||
196 | if (!(m_state.deco_mask & WindowState::DECORM_TITLEBAR)) | ||
197 | return; | ||
198 | |||
199 | // toggle shade | ||
200 | m_state.shaded = !m_state.shaded; | ||
201 | applyState(); | ||
202 | } | ||
203 | |||
204 | |||
205 | void FbWinFrame::move(int x, int y) { | 190 | void FbWinFrame::move(int x, int y) { |
206 | moveResize(x, y, 0, 0, true, false); | 191 | moveResize(x, y, 0, 0, true, false); |
207 | } | 192 | } |
@@ -519,22 +504,6 @@ void FbWinFrame::setFocus(bool newvalue) { | |||
519 | clearAll(); | 504 | clearAll(); |
520 | } | 505 | } |
521 | 506 | ||
522 | void FbWinFrame::setFullscreen(bool newvalue) { | ||
523 | if (newvalue == m_state.fullscreen) | ||
524 | return; | ||
525 | |||
526 | m_state.fullscreen = newvalue; | ||
527 | applyState(); | ||
528 | } | ||
529 | |||
530 | void FbWinFrame::setMaximized(int value) { | ||
531 | if (value == m_state.maximized) | ||
532 | return; | ||
533 | |||
534 | m_state.maximized = value; | ||
535 | applyState(); | ||
536 | } | ||
537 | |||
538 | void FbWinFrame::applyState() { | 507 | void FbWinFrame::applyState() { |
539 | applyDecorations(); | 508 | applyDecorations(); |
540 | 509 | ||
@@ -542,7 +511,7 @@ void FbWinFrame::applyState() { | |||
542 | int new_x = m_state.x, new_y = m_state.y; | 511 | int new_x = m_state.x, new_y = m_state.y; |
543 | unsigned int new_w = m_state.width, new_h = m_state.height; | 512 | unsigned int new_w = m_state.width, new_h = m_state.height; |
544 | 513 | ||
545 | if (m_state.maximized & WindowState::MAX_VERT) { | 514 | if (m_state.isMaximizedVert()) { |
546 | new_y = m_screen.maxTop(head); | 515 | new_y = m_screen.maxTop(head); |
547 | new_h = m_screen.maxBottom(head) - new_y - 2*window().borderWidth(); | 516 | new_h = m_screen.maxBottom(head) - new_y - 2*window().borderWidth(); |
548 | if (!m_screen.getMaxOverTabs()) { | 517 | if (!m_screen.getMaxOverTabs()) { |
@@ -550,7 +519,7 @@ void FbWinFrame::applyState() { | |||
550 | new_h -= heightOffset(); | 519 | new_h -= heightOffset(); |
551 | } | 520 | } |
552 | } | 521 | } |
553 | if (m_state.maximized & WindowState::MAX_HORZ) { | 522 | if (m_state.isMaximizedHorz()) { |
554 | new_x = m_screen.maxLeft(head); | 523 | new_x = m_screen.maxLeft(head); |
555 | new_w = m_screen.maxRight(head) - new_x - 2*window().borderWidth(); | 524 | new_w = m_screen.maxRight(head) - new_x - 2*window().borderWidth(); |
556 | if (!m_screen.getMaxOverTabs()) { | 525 | if (!m_screen.getMaxOverTabs()) { |
diff --git a/src/FbWinFrame.hh b/src/FbWinFrame.hh index 4a33fec..7891c36 100644 --- a/src/FbWinFrame.hh +++ b/src/FbWinFrame.hh | |||
@@ -72,10 +72,7 @@ public: | |||
72 | 72 | ||
73 | /// create a top level window | 73 | /// create a top level window |
74 | FbWinFrame(BScreen &screen, FocusableTheme<FbWinFrameTheme> &theme, | 74 | FbWinFrame(BScreen &screen, FocusableTheme<FbWinFrameTheme> &theme, |
75 | FbTk::ImageControl &imgctrl, | 75 | FbTk::XLayer &layer, WindowState &state); |
76 | FbTk::XLayer &layer, | ||
77 | int x, int y, | ||
78 | unsigned int width, unsigned int height); | ||
79 | 76 | ||
80 | /* /// create a frame window inside another FbWindow, NOT IMPLEMENTED! | 77 | /* /// create a frame window inside another FbWindow, NOT IMPLEMENTED! |
81 | FbWinFrame(BScreen &screen, FbWinFrameTheme &theme, FbTk::ImageControl &imgctrl, | 78 | FbWinFrame(BScreen &screen, FbWinFrameTheme &theme, FbTk::ImageControl &imgctrl, |
@@ -89,8 +86,7 @@ public: | |||
89 | void hide(); | 86 | void hide(); |
90 | void show(); | 87 | void show(); |
91 | bool isVisible() const { return m_visible; } | 88 | bool isVisible() const { return m_visible; } |
92 | /// shade frame (ie resize to titlebar size) | 89 | |
93 | void shade(); | ||
94 | void move(int x, int y); | 90 | void move(int x, int y); |
95 | void resize(unsigned int width, unsigned int height); | 91 | void resize(unsigned int width, unsigned int height); |
96 | /// resize client to specified size and resize frame to it | 92 | /// resize client to specified size and resize frame to it |
@@ -117,8 +113,6 @@ public: | |||
117 | 113 | ||
118 | /// set focus/unfocus style | 114 | /// set focus/unfocus style |
119 | void setFocus(bool newvalue); | 115 | void setFocus(bool newvalue); |
120 | void setFullscreen(bool value); | ||
121 | void setMaximized(int value); | ||
122 | 116 | ||
123 | void setFocusTitle(const std::string &str) { m_label.setText(str); } | 117 | void setFocusTitle(const std::string &str) { m_label.setText(str); } |
124 | bool setTabMode(TabMode tabmode); | 118 | bool setTabMode(TabMode tabmode); |
@@ -201,11 +195,6 @@ public: | |||
201 | unsigned int width() const { return m_window.width(); } | 195 | unsigned int width() const { return m_window.width(); } |
202 | unsigned int height() const { return m_window.height(); } | 196 | unsigned int height() const { return m_window.height(); } |
203 | 197 | ||
204 | int normalX() const { return m_state.x; } | ||
205 | int normalY() const { return m_state.y; } | ||
206 | unsigned int normalWidth() const { return m_state.width; } | ||
207 | unsigned int normalHeight() const { return m_state.height; } | ||
208 | |||
209 | // extra bits for tabs | 198 | // extra bits for tabs |
210 | int xOffset() const; | 199 | int xOffset() const; |
211 | int yOffset() const; | 200 | int yOffset() const; |
@@ -234,7 +223,6 @@ public: | |||
234 | const FbTk::FbWindow &gripRight() const { return m_grip_right; } | 223 | const FbTk::FbWindow &gripRight() const { return m_grip_right; } |
235 | FbTk::FbWindow &gripRight() { return m_grip_right; } | 224 | FbTk::FbWindow &gripRight() { return m_grip_right; } |
236 | bool focused() const { return m_state.focused; } | 225 | bool focused() const { return m_state.focused; } |
237 | bool isShaded() const { return m_state.shaded; } | ||
238 | FocusableTheme<FbWinFrameTheme> &theme() const { return m_theme; } | 226 | FocusableTheme<FbWinFrameTheme> &theme() const { return m_theme; } |
239 | /// @return titlebar height | 227 | /// @return titlebar height |
240 | unsigned int titlebarHeight() const { return (m_use_titlebar?m_titlebar.height()+m_titlebar.borderWidth():0); } | 228 | unsigned int titlebarHeight() const { return (m_use_titlebar?m_titlebar.height()+m_titlebar.borderWidth():0); } |
@@ -311,6 +299,8 @@ private: | |||
311 | 299 | ||
312 | FocusableTheme<FbWinFrameTheme> &m_theme; ///< theme to be used | 300 | FocusableTheme<FbWinFrameTheme> &m_theme; ///< theme to be used |
313 | FbTk::ImageControl &m_imagectrl; ///< Image control for rendering | 301 | FbTk::ImageControl &m_imagectrl; ///< Image control for rendering |
302 | WindowState &m_state; | ||
303 | |||
314 | /** | 304 | /** |
315 | @name windows | 305 | @name windows |
316 | */ | 306 | */ |
@@ -380,7 +370,6 @@ private: | |||
380 | TabMode m_tabmode; | 370 | TabMode m_tabmode; |
381 | 371 | ||
382 | unsigned int m_active_orig_client_bw; | 372 | unsigned int m_active_orig_client_bw; |
383 | WindowState m_state; | ||
384 | 373 | ||
385 | bool m_need_render; | 374 | bool m_need_render; |
386 | int m_button_size; ///< size for all titlebar buttons | 375 | int m_button_size; ///< size for all titlebar buttons |
diff --git a/src/Remember.cc b/src/Remember.cc index 0ea8a6c..0fa778f 100644 --- a/src/Remember.cc +++ b/src/Remember.cc | |||
@@ -1115,15 +1115,15 @@ void Remember::rememberAttrib(WinClient &winclient, Attribute attrib) { | |||
1115 | app->rememberHead(win->screen().getHead(win->fbWindow())); | 1115 | app->rememberHead(win->screen().getHead(win->fbWindow())); |
1116 | break; | 1116 | break; |
1117 | case REM_DIMENSIONS: | 1117 | case REM_DIMENSIONS: |
1118 | app->rememberDimensions(win->frame().normalWidth(), | 1118 | app->rememberDimensions(win->normalWidth(), |
1119 | win->frame().normalHeight()); | 1119 | win->normalHeight()); |
1120 | break; | 1120 | break; |
1121 | case REM_POSITION: { | 1121 | case REM_POSITION: { |
1122 | int head = win->screen().getHead(win->fbWindow()); | 1122 | int head = win->screen().getHead(win->fbWindow()); |
1123 | int head_x = win->screen().maxLeft(head); | 1123 | int head_x = win->screen().maxLeft(head); |
1124 | int head_y = win->screen().maxTop(head); | 1124 | int head_y = win->screen().maxTop(head); |
1125 | app->rememberPosition(win->frame().normalX() - head_x, | 1125 | app->rememberPosition(win->normalX() - head_x, |
1126 | win->frame().normalY() - head_y); | 1126 | win->normalY() - head_y); |
1127 | break; | 1127 | break; |
1128 | } | 1128 | } |
1129 | case REM_FOCUSHIDDENSTATE: | 1129 | case REM_FOCUSHIDDENSTATE: |
diff --git a/src/ScreenPlacement.cc b/src/ScreenPlacement.cc index 4397092..fa6aefc 100644 --- a/src/ScreenPlacement.cc +++ b/src/ScreenPlacement.cc | |||
@@ -115,8 +115,8 @@ bool ScreenPlacement::placeWindow(const FluxboxWindow &win, int head, | |||
115 | 115 | ||
116 | 116 | ||
117 | 117 | ||
118 | int win_w = win.width() + win.fbWindow().borderWidth()*2 + win.widthOffset(), | 118 | int win_w = win.normalWidth() + win.fbWindow().borderWidth()*2 + win.widthOffset(), |
119 | win_h = win.height() + win.fbWindow().borderWidth()*2 + win.heightOffset(); | 119 | win_h = win.normalHeight() + win.fbWindow().borderWidth()*2 + win.heightOffset(); |
120 | 120 | ||
121 | // make sure the window is inside our screen(head) area | 121 | // make sure the window is inside our screen(head) area |
122 | if (place_x + win_w - win.xOffset() > head_right) | 122 | if (place_x + win_w - win.xOffset() > head_right) |
diff --git a/src/Window.cc b/src/Window.cc index 8f97954..57fa1f5 100644 --- a/src/Window.cc +++ b/src/Window.cc | |||
@@ -269,9 +269,8 @@ FluxboxWindow::FluxboxWindow(WinClient &client, FbTk::XLayer &layer): | |||
269 | m_layersig(*this), | 269 | m_layersig(*this), |
270 | m_workspacesig(*this), | 270 | m_workspacesig(*this), |
271 | m_creation_time(0), | 271 | m_creation_time(0), |
272 | moving(false), resizing(false), shaded(false), iconic(false), | 272 | moving(false), resizing(false), iconic(false), stuck(false), |
273 | stuck(false), m_initialized(false), fullscreen(false), | 273 | m_initialized(false), |
274 | maximized(WindowState::MAX_NONE), | ||
275 | m_attaching_tab(0), | 274 | m_attaching_tab(0), |
276 | display(FbTk::App::instance()->display()), | 275 | display(FbTk::App::instance()->display()), |
277 | m_button_grab_x(0), m_button_grab_y(0), | 276 | m_button_grab_x(0), m_button_grab_y(0), |
@@ -292,8 +291,7 @@ FluxboxWindow::FluxboxWindow(WinClient &client, FbTk::XLayer &layer): | |||
292 | screen().unfocusedWinButtonTheme()), | 291 | screen().unfocusedWinButtonTheme()), |
293 | m_theme(*this, screen().focusedWinFrameTheme(), | 292 | m_theme(*this, screen().focusedWinFrameTheme(), |
294 | screen().unfocusedWinFrameTheme()), | 293 | screen().unfocusedWinFrameTheme()), |
295 | m_frame(client.screen(), m_theme, client.screen().imageControl(), layer, | 294 | m_frame(client.screen(), m_theme, layer, m_state), |
296 | 0, 0, 100, 100), | ||
297 | m_placed(false), | 295 | m_placed(false), |
298 | m_layernum(layer.getLayerNum()), | 296 | m_layernum(layer.getLayerNum()), |
299 | m_old_layernum(0), | 297 | m_old_layernum(0), |
@@ -509,11 +507,11 @@ void FluxboxWindow::init() { | |||
509 | unsigned int real_width = frame().width(), real_height = frame().height(); | 507 | unsigned int real_width = frame().width(), real_height = frame().height(); |
510 | frame().applySizeHints(real_width, real_height); | 508 | frame().applySizeHints(real_width, real_height); |
511 | 509 | ||
510 | screen().getWorkspace(m_workspace_number)->addWindow(*this); | ||
512 | if (m_placed) | 511 | if (m_placed) |
513 | moveResize(frame().x(), frame().y(), real_width, real_height); | 512 | moveResize(frame().x(), frame().y(), real_width, real_height); |
514 | 513 | else | |
515 | if (!m_placed) placeWindow(getOnHead()); | 514 | placeWindow(getOnHead()); |
516 | screen().getWorkspace(m_workspace_number)->addWindow(*this); | ||
517 | 515 | ||
518 | setFocusFlag(false); // update graphics before mapping | 516 | setFocusFlag(false); // update graphics before mapping |
519 | 517 | ||
@@ -522,8 +520,8 @@ void FluxboxWindow::init() { | |||
522 | stick(); | 520 | stick(); |
523 | } | 521 | } |
524 | 522 | ||
525 | if (shaded) { // start shaded | 523 | if (m_state.shaded) { // start shaded |
526 | shaded = false; | 524 | m_state.shaded = false; |
527 | shade(); | 525 | shade(); |
528 | } | 526 | } |
529 | 527 | ||
@@ -542,14 +540,14 @@ void FluxboxWindow::init() { | |||
542 | } | 540 | } |
543 | } | 541 | } |
544 | 542 | ||
545 | if (fullscreen) { | 543 | if (m_state.fullscreen) { |
546 | fullscreen = false; | 544 | m_state.fullscreen = false; |
547 | setFullscreen(true); | 545 | setFullscreen(true); |
548 | } | 546 | } |
549 | 547 | ||
550 | if (maximized) { | 548 | if (m_state.maximized) { |
551 | int tmp = maximized; | 549 | int tmp = m_state.maximized; |
552 | maximized = WindowState::MAX_NONE; | 550 | m_state.maximized = WindowState::MAX_NONE; |
553 | setMaximizedState(tmp); | 551 | setMaximizedState(tmp); |
554 | } | 552 | } |
555 | 553 | ||
@@ -1226,7 +1224,7 @@ void FluxboxWindow::moveResizeForClient(int new_x, int new_y, | |||
1226 | m_placed = true; | 1224 | m_placed = true; |
1227 | frame().moveResizeForClient(new_x, new_y, new_width, new_height, gravity, client_bw); | 1225 | frame().moveResizeForClient(new_x, new_y, new_width, new_height, gravity, client_bw); |
1228 | setFocusFlag(m_focused); | 1226 | setFocusFlag(m_focused); |
1229 | shaded = false; | 1227 | m_state.shaded = false; |
1230 | sendConfigureNotify(); | 1228 | sendConfigureNotify(); |
1231 | 1229 | ||
1232 | if (!moving) { | 1230 | if (!moving) { |
@@ -1449,15 +1447,15 @@ void FluxboxWindow::setFullscreen(bool flag) { | |||
1449 | 1447 | ||
1450 | if (!m_initialized) { | 1448 | if (!m_initialized) { |
1451 | // this will interfere with window placement, so we delay it | 1449 | // this will interfere with window placement, so we delay it |
1452 | fullscreen = flag; | 1450 | m_state.fullscreen = flag; |
1453 | return; | 1451 | return; |
1454 | } | 1452 | } |
1455 | 1453 | ||
1456 | if (flag && !isFullscreen()) { | 1454 | if (flag && !isFullscreen()) { |
1457 | 1455 | ||
1458 | m_old_layernum = layerNum(); | 1456 | m_old_layernum = layerNum(); |
1459 | fullscreen = true; | 1457 | m_state.fullscreen = true; |
1460 | frame().setFullscreen(true); | 1458 | frame().applyState(); |
1461 | 1459 | ||
1462 | setFullscreenLayer(); // calls stateSig().notify() | 1460 | setFullscreenLayer(); // calls stateSig().notify() |
1463 | if (!isFocused()) | 1461 | if (!isFocused()) |
@@ -1465,8 +1463,8 @@ void FluxboxWindow::setFullscreen(bool flag) { | |||
1465 | 1463 | ||
1466 | } else if (!flag && isFullscreen()) { | 1464 | } else if (!flag && isFullscreen()) { |
1467 | 1465 | ||
1468 | fullscreen = false; | 1466 | m_state.fullscreen = false; |
1469 | frame().setFullscreen(false); | 1467 | frame().applyState(); |
1470 | 1468 | ||
1471 | moveToLayer(m_old_layernum); | 1469 | moveToLayer(m_old_layernum); |
1472 | stateSig().notify(); | 1470 | stateSig().notify(); |
@@ -1491,45 +1489,26 @@ void FluxboxWindow::setFullscreenLayer() { | |||
1491 | Maximize window both horizontal and vertical | 1489 | Maximize window both horizontal and vertical |
1492 | */ | 1490 | */ |
1493 | void FluxboxWindow::maximize(int type) { | 1491 | void FluxboxWindow::maximize(int type) { |
1494 | 1492 | int new_max = m_state.queryToggleMaximized(type); | |
1495 | // nothing to do | ||
1496 | if (type == WindowState::MAX_NONE) | ||
1497 | return; | ||
1498 | |||
1499 | int new_max = maximized; | ||
1500 | |||
1501 | // toggle maximize vertically? | ||
1502 | // when _don't_ we want to toggle? | ||
1503 | // - type is horizontal maximise, or | ||
1504 | // - type is full and we are not maximised horz but already vertically | ||
1505 | if (type != WindowState::MAX_HORZ && | ||
1506 | (type != WindowState::MAX_FULL || maximized != WindowState::MAX_VERT)) | ||
1507 | new_max ^= WindowState::MAX_VERT; | ||
1508 | |||
1509 | // maximize horizontally? | ||
1510 | if (type != WindowState::MAX_VERT && | ||
1511 | (type != WindowState::MAX_FULL || maximized != WindowState::MAX_HORZ)) | ||
1512 | new_max ^= WindowState::MAX_HORZ; | ||
1513 | |||
1514 | setMaximizedState(new_max); | 1493 | setMaximizedState(new_max); |
1515 | } | 1494 | } |
1516 | 1495 | ||
1517 | void FluxboxWindow::setMaximizedState(int type) { | 1496 | void FluxboxWindow::setMaximizedState(int type) { |
1518 | 1497 | ||
1519 | if (!m_initialized || type == maximized) { | 1498 | if (!m_initialized || type == m_state.maximized) { |
1520 | // this will interfere with window placement, so we delay it | 1499 | // this will interfere with window placement, so we delay it |
1521 | maximized = type; | 1500 | m_state.maximized = type; |
1522 | return; | 1501 | return; |
1523 | } | 1502 | } |
1524 | 1503 | ||
1525 | if (isResizing()) | 1504 | if (isResizing()) |
1526 | stopResizing(); | 1505 | stopResizing(); |
1527 | 1506 | ||
1528 | maximized = type; | 1507 | m_state.maximized = type; |
1529 | frame().setMaximized(type); | 1508 | frame().applyState(); |
1530 | 1509 | ||
1531 | // notify when struts change, so we can resize accordingly | 1510 | // notify when struts change, so we can resize accordingly |
1532 | if (maximized) | 1511 | if (m_state.maximized) |
1533 | screen().workspaceAreaSig().attach(this); | 1512 | screen().workspaceAreaSig().attach(this); |
1534 | else | 1513 | else |
1535 | screen().workspaceAreaSig().detach(this); | 1514 | screen().workspaceAreaSig().detach(this); |
@@ -1590,27 +1569,27 @@ void FluxboxWindow::shade() { | |||
1590 | if (!decorations.titlebar) | 1569 | if (!decorations.titlebar) |
1591 | return; | 1570 | return; |
1592 | 1571 | ||
1593 | // we're toggling, so if they're equal now, we need to change it | 1572 | m_state.shaded = !m_state.shaded; |
1594 | if (m_initialized && m_frame.isShaded() == shaded) | 1573 | if (!m_initialized) |
1595 | frame().shade(); | 1574 | return; |
1596 | 1575 | ||
1597 | shaded = !shaded; | 1576 | frame().applyState(); |
1598 | stateSig().notify(); | 1577 | stateSig().notify(); |
1599 | // TODO: this should set IconicState, but then we can't focus the window | 1578 | // TODO: this should set IconicState, but then we can't focus the window |
1600 | } | 1579 | } |
1601 | 1580 | ||
1602 | void FluxboxWindow::shadeOn() { | 1581 | void FluxboxWindow::shadeOn() { |
1603 | if (!shaded) | 1582 | if (!m_state.shaded) |
1604 | shade(); | 1583 | shade(); |
1605 | } | 1584 | } |
1606 | 1585 | ||
1607 | void FluxboxWindow::shadeOff() { | 1586 | void FluxboxWindow::shadeOff() { |
1608 | if (shaded) | 1587 | if (m_state.shaded) |
1609 | shade(); | 1588 | shade(); |
1610 | } | 1589 | } |
1611 | 1590 | ||
1612 | void FluxboxWindow::setShaded(bool val) { | 1591 | void FluxboxWindow::setShaded(bool val) { |
1613 | if (val != shaded) | 1592 | if (val != m_state.shaded) |
1614 | shade(); | 1593 | shade(); |
1615 | } | 1594 | } |
1616 | 1595 | ||
@@ -1789,10 +1768,10 @@ void FluxboxWindow::setFocusFlag(bool focus) { | |||
1789 | 1768 | ||
1790 | // if we're fullscreen and another window gains focus on the same head, | 1769 | // if we're fullscreen and another window gains focus on the same head, |
1791 | // then we need to let the user see it | 1770 | // then we need to let the user see it |
1792 | if (fullscreen && !focus) | 1771 | if (m_state.fullscreen && !focus) |
1793 | screen().focusedWindowSig().attach(this); | 1772 | screen().focusedWindowSig().attach(this); |
1794 | 1773 | ||
1795 | if (fullscreen && focus) { | 1774 | if (m_state.fullscreen && focus) { |
1796 | moveToLayer(::Layer::ABOVE_DOCK); | 1775 | moveToLayer(::Layer::ABOVE_DOCK); |
1797 | screen().focusedWindowSig().detach(this); | 1776 | screen().focusedWindowSig().detach(this); |
1798 | } | 1777 | } |
@@ -3149,8 +3128,10 @@ void FluxboxWindow::startResizing(int x, int y, ReferenceCorner dir) { | |||
3149 | m_resize_corner = dir; | 3128 | m_resize_corner = dir; |
3150 | 3129 | ||
3151 | resizing = true; | 3130 | resizing = true; |
3152 | maximized = WindowState::MAX_NONE; | 3131 | m_state.maximized = WindowState::MAX_NONE; |
3153 | frame().setMaximized(maximized); | 3132 | m_state.saveGeometry(frame().x(), frame().y(), |
3133 | frame().width(), frame().height()); | ||
3134 | frame().applyState(); | ||
3154 | 3135 | ||
3155 | const Cursor& cursor = (m_resize_corner == LEFTTOP) ? frame().theme()->upperLeftAngleCursor() : | 3136 | const Cursor& cursor = (m_resize_corner == LEFTTOP) ? frame().theme()->upperLeftAngleCursor() : |
3156 | (m_resize_corner == RIGHTTOP) ? frame().theme()->upperRightAngleCursor() : | 3137 | (m_resize_corner == RIGHTTOP) ? frame().theme()->upperRightAngleCursor() : |
@@ -3814,11 +3795,12 @@ void FluxboxWindow::setOnHead(int head) { | |||
3814 | } | 3795 | } |
3815 | 3796 | ||
3816 | void FluxboxWindow::placeWindow(int head) { | 3797 | void FluxboxWindow::placeWindow(int head) { |
3817 | int place_x, place_y; | 3798 | int new_x, new_y; |
3818 | // we ignore the return value, | 3799 | // we ignore the return value, |
3819 | // the screen placement strategy is guaranteed to succeed. | 3800 | // the screen placement strategy is guaranteed to succeed. |
3820 | screen().placementStrategy().placeWindow(*this, head, place_x, place_y); | 3801 | screen().placementStrategy().placeWindow(*this, head, new_x, new_y); |
3821 | move(place_x, place_y); | 3802 | m_state.saveGeometry(new_x, new_y, frame().width(), frame().height(), true); |
3803 | move(new_x, new_y); | ||
3822 | } | 3804 | } |
3823 | 3805 | ||
3824 | void FluxboxWindow::setWindowType(Focusable::WindowType type) { | 3806 | void FluxboxWindow::setWindowType(Focusable::WindowType type) { |
diff --git a/src/Window.hh b/src/Window.hh index 2dbb816..b0b8248 100644 --- a/src/Window.hh +++ b/src/Window.hh | |||
@@ -371,12 +371,12 @@ public: | |||
371 | bool isManaged() const { return m_initialized; } | 371 | bool isManaged() const { return m_initialized; } |
372 | bool isVisible() const; | 372 | bool isVisible() const; |
373 | bool isIconic() const { return iconic; } | 373 | bool isIconic() const { return iconic; } |
374 | bool isShaded() const { return shaded; } | 374 | bool isShaded() const { return m_state.shaded; } |
375 | bool isFullscreen() const { return fullscreen; } | 375 | bool isFullscreen() const { return m_state.fullscreen; } |
376 | bool isMaximized() const { return maximized == WindowState::MAX_FULL; } | 376 | bool isMaximized() const { return m_state.isMaximized(); } |
377 | bool isMaximizedVert() const { return (bool)(maximized & WindowState::MAX_VERT); } | 377 | bool isMaximizedVert() const { return m_state.isMaximizedVert(); } |
378 | bool isMaximizedHorz() const { return (bool)(maximized & WindowState::MAX_HORZ); } | 378 | bool isMaximizedHorz() const { return m_state.isMaximizedHorz(); } |
379 | int maximizedState() const { return maximized; } | 379 | int maximizedState() const { return m_state.maximized; } |
380 | bool isIconifiable() const { return functions.iconify; } | 380 | bool isIconifiable() const { return functions.iconify; } |
381 | bool isMaximizable() const { return functions.maximize; } | 381 | bool isMaximizable() const { return functions.maximize; } |
382 | bool isResizable() const { return functions.resize; } | 382 | bool isResizable() const { return functions.resize; } |
@@ -425,6 +425,11 @@ public: | |||
425 | unsigned int width() const { return frame().width(); } | 425 | unsigned int width() const { return frame().width(); } |
426 | unsigned int height() const { return frame().height(); } | 426 | unsigned int height() const { return frame().height(); } |
427 | 427 | ||
428 | int normalX() const { return m_state.x; } | ||
429 | int normalY() const { return m_state.y; } | ||
430 | unsigned int normalWidth() const { return m_state.width; } | ||
431 | unsigned int normalHeight() const { return m_state.height; } | ||
432 | |||
428 | int xOffset() const { return frame().xOffset(); } | 433 | int xOffset() const { return frame().xOffset(); } |
429 | int yOffset() const { return frame().yOffset(); } | 434 | int yOffset() const { return frame().yOffset(); } |
430 | int widthOffset() const { return frame().widthOffset(); } | 435 | int widthOffset() const { return frame().widthOffset(); } |
@@ -526,10 +531,7 @@ private: | |||
526 | time_t m_creation_time; | 531 | time_t m_creation_time; |
527 | 532 | ||
528 | // Window states | 533 | // Window states |
529 | bool moving, resizing, shaded, iconic, | 534 | bool moving, resizing, iconic, stuck, m_initialized; |
530 | stuck, m_initialized, fullscreen; | ||
531 | |||
532 | int maximized; | ||
533 | 535 | ||
534 | WinClient *m_attaching_tab; | 536 | WinClient *m_attaching_tab; |
535 | 537 | ||
@@ -579,7 +581,9 @@ private: | |||
579 | 581 | ||
580 | FocusableTheme<WinButtonTheme> m_button_theme; | 582 | FocusableTheme<WinButtonTheme> m_button_theme; |
581 | FocusableTheme<FbWinFrameTheme> m_theme; | 583 | FocusableTheme<FbWinFrameTheme> m_theme; |
582 | FbWinFrame m_frame; ///< the actuall window frame | 584 | |
585 | WindowState m_state; | ||
586 | FbWinFrame m_frame; ///< the actual window frame | ||
583 | 587 | ||
584 | bool m_placed; ///< determine whether or not we should place the window | 588 | bool m_placed; ///< determine whether or not we should place the window |
585 | 589 | ||
diff --git a/src/WindowState.cc b/src/WindowState.cc index f4df136..50a88fc 100644 --- a/src/WindowState.cc +++ b/src/WindowState.cc | |||
@@ -43,21 +43,41 @@ bool WindowState::useTitlebar() const { | |||
43 | } | 43 | } |
44 | 44 | ||
45 | void WindowState::saveGeometry(int new_x, int new_y, | 45 | void WindowState::saveGeometry(int new_x, int new_y, |
46 | unsigned int new_w, unsigned int new_h) { | 46 | unsigned int new_w, unsigned int new_h, |
47 | if (fullscreen || maximized == MAX_FULL) | 47 | bool force) { |
48 | if ((fullscreen || maximized == MAX_FULL) && !force) | ||
48 | return; | 49 | return; |
49 | 50 | ||
50 | if (!(maximized & MAX_HORZ)) { | 51 | if (!(maximized & MAX_HORZ) || force) { |
51 | x = new_x; | 52 | x = new_x; |
52 | width = new_w; | 53 | width = new_w; |
53 | } | 54 | } |
54 | if (!(maximized & MAX_VERT)) { | 55 | if (!(maximized & MAX_VERT) || force) { |
55 | y = new_y; | 56 | y = new_y; |
56 | if (!shaded) | 57 | if (!shaded || force) |
57 | height = new_h; | 58 | height = new_h; |
58 | } | 59 | } |
59 | } | 60 | } |
60 | 61 | ||
62 | int WindowState::queryToggleMaximized(int type) const { | ||
63 | if (type == MAX_NONE) | ||
64 | return maximized; | ||
65 | |||
66 | int new_max = maximized; | ||
67 | // toggle maximize vertically? | ||
68 | // when _don't_ we want to toggle? | ||
69 | // - type is horizontal maximize, or | ||
70 | // - type is full and we are not maximized horz but already vertically | ||
71 | if (type != MAX_HORZ && (type != MAX_FULL || maximized != MAX_VERT)) | ||
72 | new_max ^= MAX_VERT; | ||
73 | |||
74 | // maximize horizontally? | ||
75 | if (type != MAX_VERT && (type != MAX_FULL || maximized != MAX_HORZ)) | ||
76 | new_max ^= MAX_HORZ; | ||
77 | |||
78 | return new_max; | ||
79 | } | ||
80 | |||
61 | int WindowState::getDecoMaskFromString(const std::string &str_label) { | 81 | int WindowState::getDecoMaskFromString(const std::string &str_label) { |
62 | std::string label = FbTk::StringUtil::toLower(str_label); | 82 | std::string label = FbTk::StringUtil::toLower(str_label); |
63 | if (label == "none") | 83 | if (label == "none") |
diff --git a/src/WindowState.hh b/src/WindowState.hh index 3bc5d24..ea9b635 100644 --- a/src/WindowState.hh +++ b/src/WindowState.hh | |||
@@ -100,13 +100,21 @@ public: | |||
100 | shaded(false), fullscreen(false), maximized(0), | 100 | shaded(false), fullscreen(false), maximized(0), |
101 | x(0), y(0), width(1), height(1) { } | 101 | x(0), y(0), width(1), height(1) { } |
102 | 102 | ||
103 | void saveGeometry(int x, int y, unsigned int width, unsigned int height); | 103 | void saveGeometry(int x, int y, unsigned int width, unsigned int height, |
104 | bool force = false); | ||
105 | |||
106 | // returns what the state should be set to, without actually setting it | ||
107 | int queryToggleMaximized(int type) const; | ||
104 | 108 | ||
105 | bool useBorder() const; | 109 | bool useBorder() const; |
106 | bool useHandle() const; | 110 | bool useHandle() const; |
107 | bool useTabs() const; | 111 | bool useTabs() const; |
108 | bool useTitlebar() const; | 112 | bool useTitlebar() const; |
109 | 113 | ||
114 | bool isMaximized() const { return maximized == MAX_FULL; } | ||
115 | bool isMaximizedHorz() const { return (bool)(maximized & MAX_HORZ); } | ||
116 | bool isMaximizedVert() const { return (bool)(maximized & MAX_VERT); } | ||
117 | |||
110 | static int getDecoMaskFromString(const std::string &str); | 118 | static int getDecoMaskFromString(const std::string &str); |
111 | 119 | ||
112 | SizeHints size_hints; | 120 | SizeHints size_hints; |