restoreWindowStateFromString and multiple display


#1

Hi Julian,

 

I have an issue with restoreWindowStateFromString in a special case:

I'm running on Window 7 64 Pro US SP1.

(my GPU JFYI: AMD FirePro V5900 with v13.352 driver.)

 

I'm running my application in multiple display.

When getWindowStateAsString is called it was maximized on a screen that do not own the (0, 0) coordinate of the desktop.

If I use the restoreWindowStateFromString with this state, It is correctly restored in maximized state but on the bad screen.

 

To fix this I modify the ResizableWindow class like this :

 

bool ResizableWindow::restoreWindowStateFromString (const String& s)
{

  [...]


  if (peer != nullptr)
  {
      peer->getFrameSize().subtractFrom (newPos);
      peer->setNonFullScreenBounds (newPos);
  }

  // alexdlabs: do not try overwrite last non full screen user bounds.
  // this help user to retrieve its non maximised bounds when it disable maximised mode.
  //updateLastPosIfNotFullScreen();

  // alexdlabs: delay full screen setting after bound was set.
  //setFullScreen (fs);


  // alexdlabs: always use user bounds
  //if (! fs)
      setBoundsConstrained (newPos);

  // alexdlabs: always restore full screen state after setBoundsConstrained
  setFullScreen (fs);

  return true;
}

 

I'm using last Juce version compiled with Visual Studio 2010 SP1 in 64 bit.

 

Thanks for your concern about this.


#2

Hi again,

I don’t know why our last posts have disappeared from the forum. Just for information, you are right about the updateLastPosIfNotFullScreen call.

here the new code :

bool ResizableWindow::restoreWindowStateFromString (const String& s)
{

  [...]

    if (peer != nullptr)
    {
        peer->getFrameSize().subtractFrom (newPos);
        peer->setNonFullScreenBounds (newPos);
    }

    // alexdlabs: always call setBoundsConstrained before updateLastPosIfNotFullScreen and setFullScreen
    setBoundsConstrained(newPos);

    updateLastPosIfNotFullScreen();
    setFullScreen (fs);

    // alexdlabs: comment this (already done)
    //if (! fs)
    //    setBoundsConstrained (newPos);

    return true;
}

I hope this can help


#3

How about this:


    if (peer != nullptr)
    {
        peer->getFrameSize().subtractFrom (newPos);
        peer->setNonFullScreenBounds (newPos);
    }
    
    updateLastPosIfNotFullScreen();

    if (fs)
        setBoundsConstrained (newPos);

    setFullScreen (fs);

    if (! fs)
        setBoundsConstrained (newPos);

    return true;

..though I do have some misgivings about this - it feels like there could be an edge-case where even this would break something.


#4

It's working except when exiting fullscreen mode, the application restore the bounds set by
updateLastPosIfNotFullScreen (screen owning 0,0 instead of the maximized screen)

perapse we should change the prototype like this: updateLastPosIfNotFullScreen(newPos);

or reoder like this:

    if (fs)
        setBoundsConstrained (newPos);

    updateLastPosIfNotFullScreen();

    setFullScreen (fs);

    if (! fs)
        setBoundsConstrained (newPos);


 


#5

Did you always think that this last version could break something ?

Regards


#6

I've a feeling it'll almost certainly break something, but it's a tricky piece of logic to check - there are a lot of different paths to think about.