FLTK logo

Re: [fltk/fltk] macOS regression with glwindow, glsubwindow and tile. (Issue #968)

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.issues  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: [fltk/fltk] macOS regression with glwindow, glsubwindow and tile. (Issue #968) ManoloFLTK 08:27 May 08  
 

@ggarra13 The problem is in your calculations to position and size your toplevel window in the screen that are plain wrong. Use this modified code for your function cb_Resize() and you'll see that the bug disappears. You'll see also that the window is correctly positioned both when the dock is at bottom or at left (or right) of the display.

Your errors are mainly to forget that
Fl::screen_work_area(minx, miny, maxW, maxH, screen);
compute two positions (minx and miny) and two sizes (maxW, maxH), and to compare positions to sizes.

static void cb_Resize(Fl_Widget* o, void* d)
{
    std::cerr << "resize called" << std::endl;
    RenderSize renderSize;
  renderSize.w =  1950; // big values for big and also for small screens
  renderSize.h = 900;
    Fl_Double_Window* mw = uiMain;
    int screen = mw->screen_num();
    //float scale = Fl::screen_scale(screen);

    int W = renderSize.w;
    int H = renderSize.h;

    int minx, miny, maxW, maxH, posX, posY;
    Fl::screen_work_area(minx, miny, maxW, maxH, screen);

    posX = mw->x();
    posY = mw->y();

    int decW = mw->decorated_w();
    int decH = mw->decorated_h();

    int dW = decW - mw->w();
    int dH = decH - mw->h();

    maxW -= dW;
    //maxH -= dH;
    posX += dW / 2;
#ifdef _WIN32
    miny += dH - dW / 2;
#endif

    // Take into account the different UI bars
    if (uiMenuGroup->visible())
        H += uiMenuGroup->h();

    if (uiTopBar->visible())
        H += uiTopBar->h();

    if (uiPixelBar->visible())
        H += uiPixelBar->h();

    if (uiBottomBar->visible())
    {
        H += uiBottomBar->h();
    }

    if (uiStatusGroup->visible())
        H += uiStatusGroup->h();

    if (uiToolsGroup->visible())
        W += uiToolsGroup->w();

    if (uiDockGroup->visible())
        W += uiDockGroup->w();

    //maxW = (int)(maxW / scale); // bad: maxW accounts for scale already
    if (W < 690)
    {
        W = 690;
    }
    /*else if (W > maxW) // bad: done in final sanity checks
    {
        W = maxW;
    }*/

    //maxH = (int)(maxH / scale); // bad: maxH accounts for scale already
    if (H < 602)
    {
        H = 602;
    }
    /*else if (H > maxH) // bad: done in final sanity checks
    {
        H = maxH;
    }*/

    if (uiBottomBar->visible())
    {
        H += uiBottomBar->h();
    }

    //
    // Final sanity checks.
    //
    /*if (W > maxW)
        W = maxW;
    if (H > maxH)
        H = maxH;*/

    /*if (posX + W > maxW) // bad: left of > is a position, right of > is a size!
        posX = minx;*/
  if (posX + W > minx+maxW) {
    posX = minx;
    W = minx+maxW - posX;
  }
  
    /*if (posY + H > maxH) // bad: left of > is a position, right of > is a size!
        posY = miny;*/
  if (posY + H > miny+maxH) {
    posY = miny + dH;
    H = miny+maxH - posY;
  }

  std::cerr << "mw resize=" << posX << ", " << posY
              << " " << W << "x" << H << std::endl;
    mw->resize(posX, posY, W, H);

    std::cerr << "1 uiView->y()=" << uiView->y() << std::endl;
    uiRegion->layout();
    std::cerr << "2 uiView->y()=" << uiView->y() << std::endl;

    // Set_mode_cb();
}


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <fltk/fltk/issues/968/2100842819@github.com>

Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.