DSD-DBS / capella-dockerimages

Collection of Docker images for MBSE. Most images are based on Eclipse Capella.
https://dsd-dbs.github.io/capella-dockerimages/
Apache License 2.0
16 stars 5 forks source link

Modal dialogs disappear in the background #317

Open MoritzWeber0 opened 1 month ago

MoritzWeber0 commented 1 month ago

When a modal dialog / popup opens in Capella and the user clicks next to the window, the popups goes to the background and is hidden by the main Capella window. The main Capella window is unresponsive then. This is confusing to users and model dialogs should always stay in the foreground.

jamilraichouni commented 1 week ago

I prepared a script named place_properties_window_on_top.py and successfuly tested, if the following works in the /tmp/supervisord/supervisord.xpra.conf:

[program:place-properties-window-on-top]
command=python /path/to/place_properties_window_on_top.py
user=techuser

Question, where do we want to put the script?

The script itself is a service and will look like this:

# SPDX-FileCopyrightText: Copyright DB InfraGO AG and contributors
# SPDX-License-Identifier: Apache-2.0
"""Script placing "Properties" windows on top of Capella's main window."""

import time

from Xlib import X, display

def _identify_property_window_and_place_it_on_top(window):
    for child in window.query_tree().children:
        name = child.get_wm_name() if child.get_wm_name() else "Unknown"
        if name.lower().strip() == "properties":
            child.configure(stack_mode=X.PlaceOnTop)

def _main() -> None:
    while True:
        windows = display.Display().screen().root.query_tree().children
        if windows is None or not windows:
            time.sleep(2)
            continue
        try:
            _ = [_identify_property_window_and_place_it_on_top(w) for w in windows]
        except Exception:
            pass
        time.sleep(0.3)

if __name__ == "__main__":
    _main()
MoritzWeber0 commented 1 week ago

Question, where do we want to put the script?

My proposal would be to place it in /opt. That's where Capella lives too.

The metrics service was placed in /home/techuser, but I'd say that /opt is a more suitable location.

jamilraichouni commented 1 week ago

What about introducing a new dir /opt/services? This is our first but (IMHO) not last service.

MoritzWeber0 commented 1 week ago

What about introducing a new dir /opt/services? This is our first but (IMHO) not last service.

In theory, everything in /opt is just a service. Capella is also just a service that is started by supervisord. I'd put it to /opt directly. If the folder should get messy at some point (which I don't think will happen), we can still move it (without a breaking change).

jamilraichouni commented 1 week ago

I a peer-to-peer at work discussion between @MoritzWeber0 and me we decided to introduce a new dir named /opt/services.

I was short before proposing /opt/startup as parent dir, Reason is given in https://github.com/DSD-DBS/capella-dockerimages/blob/144f90c02b80d06391bb576b48ed4a762b4bd09e/capella/setup/README.md

But: This is dangerous, since a depending caller waits for all scripts in /opt/startup to be terminated and such a service in setup would end up in a kind of container deadlock.

jamilraichouni commented 1 week ago

Question, where do we want to put the script?

My proposal would be to place it in /opt. That's where Capella lives too.

The metrics service was placed in /home/techuser, but I'd say that /opt is a more suitable location.

We agreed on moving the /home/techuser/.metrics.pyout of the $HOME and I suggest to rename it to /opt/services/metrics.py which is not a hidden file anymore.

jamilraichouni commented 1 week ago

Storing this because it might become relevant when I open the PR:

image

and in contrast

image
jamilraichouni commented 1 week ago

Nice terminal tools to investigate x11 windows:

apt-get install x11-utils wmctrl

Always set the correct DISPLAY env var before running any tool.

List windows with window id:

wmctrl -l

Example output

0x00a00037  0 engine-room-capella-7.0.0 capella_7.0.0 - test - Capella
0x00a02621  0 engine-room-capella-7.0.0 About Capella

Get window props:

obxprop --id 0x00a02621
jamilraichouni commented 1 week ago

Solution, that works:

/etc/xdg/openbox/rc.xml

    <application type="normal">                                                                                                                                                                                                                                                                                                                    
      <fullscreen>yes</fullscreen>                                                                                                                                                                                                                                                                                                                 
    </application>  

Then in supervisord.xpra.conf

(...)
command=xpra start-desktop :10 --start=openbox --start-env=GTK_IM_MODULE=ibus --attach=yes --daemon=no --bind-tcp=0.0.0.0:10001 --min-quality=70   
(...)

Add export GTK_IM_MODULE=ibus to ~/.config/openbox/autostart

jamilraichouni commented 1 week ago

There is a draft PR already https://github.com/DSD-DBS/capella-dockerimages/pull/328