|
Emit event when window moves |
urskogshumla
Member #16,942
January 2019
|
Hi! I could only find an event for when the window is resized, not when it is moved around the screen so I thought, why not emit an event for it since there is a hook (at least for the XDisplay on linux) already in use for the resize event. I simply duplicated the event creation code for the resize event, changed the condition and added a new event to the enum. Code style wise, I pledge guilty. It aint beautiful. But it's the most logical way I can see to handle this. Would you do different? Poll and check this at user level every frame instead? My diff: https://pastebin.com/UHZvbXXN EDIT: There is also no way to tell which display that the event is relevant for. Since we can create a number of windows (around 20 per allegro application on my machine) there should be some way to identify which display that generated the event. Or, if multiple displays is not a feature we support fully, maybe that should be more clear OR even restricted by the API or something? Just some thoughts, for myself I'll just patch in some integer identifier system or similar. EDIT 2: Found the al_get_x_window_id(dpy) function, that might be sufficient. EDIT 3: And I guess I can just compare the two ALLEGRO_DISPLAY pointers (event.display.source and my stored pointer from display creation)? Because they should point to the same memory right? Hugs, |
Elias
Member #358
May 2000
|
Sounds useful to me! And yes, the "source" field of the event will be the display it came from for all display events. The only small concern I have is wether we should create those events in response to al_set_window_position or not - we do have some code there to prevent resize events when the user calls al_resize_display. I don't know why. But resizing is a bit more complex because of al_acknowledge_resize. Just for consistency we might want to do the same for move events, but not really sure. Myself I can't see a possible use case for detecting when a window moves in a game so hard to know what would make sense with events for al_set_window_position. -- |
Edgar Reynaldo
Major Reynaldo
May 2007
|
What's the use case? Why do you care where the window is? TBH, I'd rather have audio events, when a sample finishes, etc... My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
dthompson
Member #5,749
April 2005
|
Hey, I know at least one other person with a use case for this. {"name":"611909","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/8\/0\/80a90af231375e976c9cbca32646e734.jpg","w":1920,"h":1083,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/8\/0\/80a90af231375e976c9cbca32646e734"} ______________________________________________________ |
Edgar Reynaldo
Major Reynaldo
May 2007
|
playing with anime pr0n does not count To be more helpful, the patch looks good. I could probably do something similar on Windows. EDIT EDIT2 My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
|