What should I do to get FL_ACTIVATE? My idea was to rely on it and FL_DEACTIVATE to keep a satellite (wingman) window on the screen only while the main window is active. As can be seen from the above, active_r() returns true so I would expect FL_ACTIVATE. What else should I check.
On Wednesday 13 December 2023 at 05:28:00 UTC Pavel wrote:What should I do to get FL_ACTIVATE? My idea was to rely on it and FL_DEACTIVATE to keep a satellite (wingman) window on the screen only while the main window is active. As can be seen from the above, active_r() returns true so I would expect FL_ACTIVATE. What else should I check.If this is the objective, a floating window that is on screen only when it's main window is, then it *sounds* to me like you are talking about making a non-modal window...?In which case, all that messing about with events is just unnecessary confusion; just set the satellite window as non-modal to the main window and it should Just Work.Um, OK... Not sure this is actually what you want, but here's a worked example that seems to work (if I understood the question, at any rate!)
On 12/14/23 02:52 Pavel wrote:
> I want to track events anyway to move the wingman at (more or less)
> fixed offset from the main window as the main window is moved. Hence
> that question #1 about what those FL_NO_EVENT were and whether they
> could be used (ax proxies?) to catch when main window is moved around
> or resized.
[...]
> How to track window size and position changes is still unclear.
> Although, tons of FL_NO_EVENT events are generated so hopefully
> piggy-backing on these will work, even though in a non-documented way..
Please don't rely on undocumented behavior like FL_NO_EVENT events.
These events are platform dependent and may be changed (removed) without
notice. I know of these events and I may try to "fix" them by not
sending them to the application.
AFAICT these events are mostly sent on
X11 platforms but much less (or not at all when moving windows) on other
platforms like Windows. I don't see such events on Wayland, for instance.
There is also another issue with your "wingman" approach, particularly
on the Wayland platform. On this platform applications (in our case the
FLTK library) are not able to read the current window coordinates and we
can't position a new window at arbitrary screen coordinates.
These two
features are prohibited by Wayland for security reasons.
There is a
special Wayland option though so you can position a window relative to
an existing window (used for menus and other popup windows). I'm not
aware of a FLTK method to utilize this to position a window like your
"wingman" window near or relative to the main window, even if you could
track window movement.
Maybe you can use the virtual method resize() to catch resize (and maybe
move?) events of the main window (needs subclassing) but I'm not sure if
this works on Wayland or at all. This is just an idea (untested).
That said, using undocumented methods is not a good idea, and Wayland
may be another issue that prevents you from positioning your "wingman"
window. Maybe you should rethink your GUI. It would be possible to
extend your main window and put your wingman stuff in a separate group
in the main window.
See e.g. test/demo.cxx how this works for the "debug
terminal" (right click on the demo window opens a menu to open/close the
debug terminal).
Thanks Albrecht.
On Thursday, December 14, 2023 at 11:37:21 AM UTC-5 Albrecht Schlosser wrote:On 12/14/23 02:52 Pavel wrote:
There is also another issue with your "wingman" approach, particularly
on the Wayland platform. On this platform applications (in our case the
FLTK library) are not able to read the current window coordinates and we
can't position a new window at arbitrary screen coordinates.Noted. Even on my xfce4 I noticed that x() and y() stay zeros while handling FL_SHOW, FL_DEACTIVATE and FL_ACTIVATE, and only become sensible on the next event (FL_FOCUS):handling 16(FL_SHOW) mainWin(0,0,340,180), wingMan(null)
handling 13(FL_DEACTIVATE) mainWin(0,0,340,180), wingMan(null)
handling 14(FL_ACTIVATE) mainWin(0,0,340,180), wingMan(null)
activated, active_r:1
deactivated, active_r:1
window x,y,w,h: 0 0 340 180
handling 6(FL_FOCUS) mainWin(790,460,340,180), wingMan(390,0,340,180)
handling 6(FL_FOCUS) mainWin(790,460,340,180), wingMan(390,24,340,180)
These two features are prohibited by Wayland for security reasons.I guess I don't understand their concern: it would seem to me that if a user is allowed to move window around and be aware of its location, the process running with this user's permissions should, too. Need to do some reading about their rationale and how common it is.
There is a special Wayland option though so you can position a window relative to
an existing window (used for menus and other popup windows). I'm not
aware of a FLTK method to utilize this to position a window like your
"wingman" window near or relative to the main window, even if you could
track window movement.
Thanks! It seems I could use the relative positioning for my purpose if it was exposed. If those security considerations becomes a mainstream, the APIs to just note movements (without coordinates) and do relative positioning could help achieve my goal.
What I would like my app look like is similar to gimp (when not in a single-window mode). The idea is to use those wingmans to configure a non-rectangular space so the user could read from the window of another app below my app and do something with my app. [...]
Docs of Fl_Widget::deactivate() say: "Currently you cannot deactivate Fl_Window widgets.". I don't know why that is so but as you see active_r() is still 1 after deactivation (if I interpret your text correctly).
You may want to use Fl_Window::wait_for_expose() after Fl_Window::show(). Then you should be able to read x() and y() - provided your platform is not wayland which will always return 0.
Interesting. But I believe this could be left to the user. Being able to move more windows in common has its own problems, e.g. screen limits.