Comments (9)
Ok... I have it running if you would want it. Btw... I have related question... so far when you drag window or resize it, it halts the main thread. It would be better if content inside was not halted. Do you want to change it too? Thanks.
from sokol.
Maybe this helps: https://stackoverflow.com/a/18043461/494472
from sokol.
If separate thread is out of question, than there is only option described in:
Windows runs this moving/sizing loop as long as the user is interactively moving/sizing the window. It does this so that it can intercept mouse messages and process them accordingly. When the moving/sizing operation completes (e.g., when the user releases the mouse button or presses the Esc key), control will return to your application code.
It is worth pointing out that you are notified that this mode change has occurred via the WM_ENTERSIZEMOVE message; the corresponding WM_EXITSIZEMOVE message indicates that the modal event-processing loop has exited. That allows you to create a timer that will continue to generate WM_TIMER messages that your application can process. The actual details of how this is implemented are relatively unimportant, but the quick explanation is that DefWindowProc continues to dispatch WM_TIMER messages to your application inside of its own modal event processing loop. Use the SetTimer function to create a timer in response to the WM_ENTERSIZEMOVE message, and the KillTimer function to destroy it in response to the WM_EXITSIZEMOVE message.
As there is small delay before WM_ENTERSIZEMOVE
is received, I guess that same method is used in Adobe AIR, where is also noticeable halt before the content is again updating. It is not perfect, but at least it is not halted when you drag a window.
from sokol.
Yes, I've been planning to add stuff like this "as needed".
Also things like minimized/maximized/restored and 'quit-requested' events.
Please don't bother with a PR though, sokol_app.h is still quite a bit in flux. It'll go in within the next few days I think.
from sokol.
The 'halt-the-main-thread' thing only happens on Windows, I guess because moving/resizing is "modal" there. It would be good to fix this, do you know what the recommend fix for this is (I guess calling the frame callback during a WM_* message?).
from sokol.
I think that the only proper way is to use separate thread. GLFW examples are working the same way.. only the GLFW's threads
test (using tinycthread) is not blocking.
from sokol.
Hmm, no IMHO a separate thread is out of question. I'd rather have no updates during moving/resizing. I'll play around with it a bit, I think a lot can be achieved by calling the frame callback from within the WinProc.
from sokol.
FYI I have started to implement resize, iconified and restored (un-iconified) events. This is basically a subset of what GLFW is doing (and also implemented in the same way). If it makes sense I'll also add a focused/unfocused event later.
I left out the position-changed event, do you know of a scenario where this is required? IMHO size changes is the most important (I also removed the per-frame check for size changes on the platforms where those events are implemented, currently only MacOS and Win32).
from sokol.
Similar sokol-app events have been implemented now, closing this...
from sokol.
Related Issues (20)
- [sokol_app] Alt-tabbing issues on windows in a FPS game on a multi-monitor setup HOT 2
- D3D11 storage buffers do not compile on wine HOT 1
- Seems .c file not generated in bindgen, producing errors HOT 2
- test
- Sokol Fetch Http response 200 is reported as an error HOT 7
- [sokol_gfx d3d11] update_image is wrong for 3d textures HOT 10
- Offscreen with alpha background. Is it possible? HOT 4
- [webgpu] Bindgroups cache breaks down with init/uninit pattern.
- macOS huge memory usage when window minimized HOT 1
- Questions regarding default GL version HOT 5
- App Window Size on Android HOT 3
- Default value _sg_gl_uniform_t::gl_loc when uniform_desc's name isn't given in sokol_gfx HOT 1
- sokol_gfx.h: wrong define in log related to SOKOL_TRACE_HOOKS HOT 1
- WebGPU TextureView validation error HOT 6
- sokol_fetch on Android
- partial updates to buffers/textures (e.g. offset and size args to glBufferSubData, glTexSubImage) HOT 1
- Right shift is recognized as "invalid key" on Windows. HOT 9
- SAPP_EVENT_CHAR for Space is fired when Ctrl+Space is pressed. HOT 2
- Key events on Linux always use the **first** keyboard layout in the system's keyboard layout list. HOT 1
- Continuous Bind Slots Restriction Unnecessary? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sokol.