From 481481a952d17940f322b8859460b1f19b8ad23f Mon Sep 17 00:00:00 2001 From: Scott Duensing Date: Wed, 31 Aug 2022 19:09:00 -0500 Subject: [PATCH] Minimize and maximize fixed. --- roo-e/src/gui/wmwindow.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/roo-e/src/gui/wmwindow.c b/roo-e/src/gui/wmwindow.c index 1a255b6..74866b4 100644 --- a/roo-e/src/gui/wmwindow.c +++ b/roo-e/src/gui/wmwindow.c @@ -378,21 +378,28 @@ void windowMaximizeRestore(WindowT *win) { // Are we maximized? if (win->flags & WIN_IS_MAX) { - // Restore to previous size. + // Restore to previous size and offset. win->flags &= ~WIN_IS_MAX; win->base.r = win->restore; + // Update the window so we have new values calculated. + windowCache(win, 1); + // Now move the scroll position. + win->scroll->offset = win->restoreOffset; + scrollableValueHSet(win->scroll, win->restoreOffset.x); + scrollableValueVSet(win->scroll, win->restoreOffset.y); } else { // Maximized? // Maximize window. Reposition if needed. win->flags |= WIN_IS_MAX; - // Remember current size. + // Remember current size and offset. win->restore = win->base.r; + win->restoreOffset = win->scroll->offset; // Expand to full contents. - win->base.r.w = (win->base.r.w - (win->bounds.x2 - win->bounds.x) + win->scroll->original.x); - win->base.r.h = (win->base.r.h - (win->bounds.y2 - win->bounds.y) + win->scroll->original.y); + win->base.r.w = (win->base.r.w - (win->bounds.x2 - win->bounds.x) + surfaceWidthGet(win->scroll->area) + (win->scroll->scrollv ? win->scroll->scrollv->base.r.w - 1: 0)); + win->base.r.h = (win->base.r.h - (win->bounds.y2 - win->bounds.y) + surfaceHeightGet(win->scroll->area) - 1); // Does this go off the screen to the right? if (win->base.r.x + win->base.r.w >= videoDisplayWidthGet()) { @@ -425,7 +432,7 @@ void windowMaximizeRestore(WindowT *win) { } // Maximized? // Update. - windowCache(win, 1); + widgetDirtySet(W(win), 1); } @@ -692,7 +699,8 @@ void wmUpdate(EventT *event) { // Is the left mouse button down? if (event->buttons & BUTTON_LEFT) { - // DEBUG - draw active regions. + // DEBUG - draw active regions. Crashes if you minimize. + /* surfaceSet(__guiBackBuffer); surfaceBox(win->base.r.x, win->base.r.y, x2, y2, GUI_YELLOW); surfaceBox(win->bounds.x, win->bounds.y, win->bounds.x2, win->bounds.y2, GUI_YELLOW); @@ -700,6 +708,7 @@ void wmUpdate(EventT *event) { surfaceBox(win->titlebar.x, win->titlebar.y, win->titlebar.x2, win->titlebar.y2, GUI_LIGHTCYAN); surfaceBox(win->minimize.x, win->minimize.y, win->minimize.x2, win->minimize.y2, GUI_LIGHTGREEN); surfaceBox(win->maximize.x, win->maximize.y, win->maximize.x2, win->maximize.y2, GUI_RED); + */ /* surfaceBox(win->scrollv.x, win->scrollv.y, win->scrollv.x2, win->scrollv.y2, GUI_BLUE); surfaceBox(win->scrollh.x, win->scrollh.y, win->scrollh.x2, win->scrollh.y2, GUI_BROWN);