Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: How to "unfreeze" a window while dragging it  (Read 9435 times)

0 Members and 1 Guest are viewing this topic.

smguyk

  • Jr. Member
  • **
  • Posts: 79
    • View Profile
How to "unfreeze" a window while dragging it
« on: November 22, 2015, 06:44:46 pm »
When clicking the window's title bar and holding down the mouse button (for example to drag the window around), it "freezes". Is there a fix/workaround for that?

I know that a lot of applications freeze too, but only for a fraction of a second, and then unfreeze even if the mouse button is still held down.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: How to "unfreeze" a window while dragging it
« Reply #1 on: November 22, 2015, 07:25:54 pm »
It's explained somewhere, probably on the forum if not in the documentation.

Because of the way SFML handles events internally, the thread that calls pollEvent will be blocked as long as the window is being moved/resized. The workaround is to do whatever you want to happen while the window is frozen, in another thread.
Laurent Gomila - SFML developer

smguyk

  • Jr. Member
  • **
  • Posts: 79
    • View Profile
Re: How to "unfreeze" a window while dragging it
« Reply #2 on: November 22, 2015, 07:44:04 pm »
Okay, thanks!

mkalex777

  • Full Member
  • ***
  • Posts: 206
    • View Profile
Re: How to "unfreeze" a window while dragging it
« Reply #3 on: December 21, 2015, 07:07:57 pm »
Laurent could you please add callback to allow render window while window in resize loop? Just call it from WM_PAINT message. So, we can set this callback with minimal render function which will works in resize mode. For sfml.net it will be cool to implement it as event.

it will be cool feature, because we can make window without artefacts and garbage...
« Last Edit: December 21, 2015, 07:11:03 pm by mkalex777 »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: How to "unfreeze" a window while dragging it
« Reply #4 on: December 22, 2015, 07:54:39 am »
It wouldn't fit at all in the SFML API...
Laurent Gomila - SFML developer

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: How to "unfreeze" a window while dragging it
« Reply #5 on: December 22, 2015, 09:09:57 am »
Laurent:

Maybe we could at least clear the window to the last window.clear(); color while resizing? Don't think you could restore the classic drag behaviour (outline only) for individual windows, which would be another nice idea.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: How to "unfreeze" a window while dragging it
« Reply #6 on: December 22, 2015, 11:02:53 am »
Quote
Maybe we could at least clear the window to the last window.clear(); color while resizing?
That's just a hack that doesn't solve much of the problem, and that would involve adding some crappy code to the implementation :(

The problem is not to make the window look good while it is being resized, it is to avoid blocking the calling thread. Which is impossible unless you work with callbacks, which SFML is not designed for.
Laurent Gomila - SFML developer

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: How to "unfreeze" a window while dragging it
« Reply #7 on: December 22, 2015, 11:27:14 am »
Yeah, possibly. Although I'd have used the WinAPI directly, no OpenGL clear/display. Not sure that would work though.

mkalex777

  • Full Member
  • ***
  • Posts: 206
    • View Profile
Re: How to "unfreeze" a window while dragging it
« Reply #8 on: January 09, 2016, 10:51:41 pm »
It's too complicated task to render window in usual way while resizing. But if we support rendering of some static scene it will be looks good enough.

Currently I'm working on my own OpenGL wrapper and learning OpenGL internals.
I've found that OpenGL contexts with extensions is real holly shit... :)
DirectX API with it's own COM interfaces looks much easier in comparison to those OpenGL kludges :)

Also I've found that OpenGL cannot render it's content into window which is in resizing state and has double buffer flag.
It seems like the reson why SFML doesn't provide any way to render window in resizing state.
I've found nice solution for this issue.
You can handle WM_SIZING and WM_SIZE messages in order to catch resize begin and resize end events.
When you catch resize begin event, just reset double buffering flag and reenable it back on resize end.
Actually I'm using WinForms events Form.OnResizeBegin and Form.OnResizeEnd.
It works very good. It allows to use double buffered window to avoid tearing effects and to render content while window is in resizing state.
I implemented RenderRequest event which is raised when a system sends WM_PAINT message from internal message loop (I just set internal flag before dispatch window messages and reset it when it's done, so my event is raised in resizing state only). So, I'm using it to render static scene in resizing state.
Yes, it doesn't allow to update game state like in usual game loop, so the game will freeze, but it still render current state into the window.



« Last Edit: January 09, 2016, 10:57:12 pm by mkalex777 »

 

anything