Minimize and maximize fixed.

This commit is contained in:
Scott Duensing 2022-08-31 19:09:00 -05:00
parent 28560e8721
commit 481481a952

View file

@ -378,21 +378,28 @@ void windowMaximizeRestore(WindowT *win) {
// Are we maximized? // Are we maximized?
if (win->flags & WIN_IS_MAX) { if (win->flags & WIN_IS_MAX) {
// Restore to previous size. // Restore to previous size and offset.
win->flags &= ~WIN_IS_MAX; win->flags &= ~WIN_IS_MAX;
win->base.r = win->restore; 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? } else { // Maximized?
// Maximize window. Reposition if needed. // Maximize window. Reposition if needed.
win->flags |= WIN_IS_MAX; win->flags |= WIN_IS_MAX;
// Remember current size. // Remember current size and offset.
win->restore = win->base.r; win->restore = win->base.r;
win->restoreOffset = win->scroll->offset;
// Expand to full contents. // 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.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) + win->scroll->original.y); 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? // Does this go off the screen to the right?
if (win->base.r.x + win->base.r.w >= videoDisplayWidthGet()) { if (win->base.r.x + win->base.r.w >= videoDisplayWidthGet()) {
@ -425,7 +432,7 @@ void windowMaximizeRestore(WindowT *win) {
} // Maximized? } // Maximized?
// Update. // Update.
windowCache(win, 1); widgetDirtySet(W(win), 1);
} }
@ -692,7 +699,8 @@ void wmUpdate(EventT *event) {
// Is the left mouse button down? // Is the left mouse button down?
if (event->buttons & BUTTON_LEFT) { if (event->buttons & BUTTON_LEFT) {
// DEBUG - draw active regions. // DEBUG - draw active regions. Crashes if you minimize.
/*
surfaceSet(__guiBackBuffer); surfaceSet(__guiBackBuffer);
surfaceBox(win->base.r.x, win->base.r.y, x2, y2, GUI_YELLOW); 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); 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->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->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->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->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); surfaceBox(win->scrollh.x, win->scrollh.y, win->scrollh.x2, win->scrollh.y2, GUI_BROWN);