Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Popups Vanishing #91

Open
DanTheMan1244 opened this issue Aug 13, 2022 · 9 comments
Open

Popups Vanishing #91

DanTheMan1244 opened this issue Aug 13, 2022 · 9 comments

Comments

@DanTheMan1244
Copy link

Whenever I make a Popup that has focusable widgets, it will disappear whenever I move my mouse off of the popup. It will also disappear if a new window appears. This never happens if no controls can be focused.

This is the code I have used to define my Popup:

def startPopups(qtile):
    global PopupLayout
    PopupLayout = PopupRelativeLayout(qtile, width=1000, height=200, controls=[
        PopupWidget(
            widget=widget.CPUGraph(),
            width=0.45,
            height=0.45,
            pos_x=0.05,
            pos_y=0.05,
            highlight_method='border'
        ),
        PopupWidget(
            widget=widget.MemoryGraph(),
            width=0.9,
            height=0.45,
            pos_x=0.05,
            pos_y=0.5,
        ),

    ], background="00000060", inital_focus=None, close_on_click=False)


@lazy.function
def show_graphs(qtile):
    startPopups(qtile)
    PopupLayout.show(centered=True)

@lazy.function
def hide_graphs(qtile):
    PopupLayout.hide()

This Popup will stay.

However, If I add a mouse callback, like so:

def startPopups(qtile):
    global PopupLayout
    PopupLayout = PopupRelativeLayout(qtile, width=1000, height=200, controls=[
        PopupWidget(
            widget=widget.CPUGraph(),
            width=0.45,
            height=0.45,
            pos_x=0.05,
            pos_y=0.05,
            highlight_method='border'
        ),
        PopupWidget(
            widget=widget.MemoryGraph(),
            width=0.9,
            height=0.45,
            pos_x=0.05,
            pos_y=0.5,
            mouse_callbacks={"Button1": hide_graphs()}

        ),

    ], background="00000060", inital_focus=None, close_on_click=False)


@lazy.function
def show_graphs(qtile):
    startPopups(qtile)
    PopupLayout.show(centered=True)

@lazy.function
def hide_graphs(qtile):
    PopupLayout.hide()

This will disappear if I move the mouse off of the Popup, or if a new window appears.
I have noticed while writing this, that the Popup also disappears if the focus of the windows is changed, which if I have the follow_mouse_focus property set as true, in the qtile config, would explain why the popup disappears when my mouse moves off of the Popup. It would also explain why if a new window appears why the popup will also disappear.
Again none of this happens if the popup has no focusable controls.

@elParaguayo
Copy link
Owner

That is the intended behaviour at the moment. When using keyboard navigation the popup subscribes to some hooks which will kill the window if it loses focus. This is the relevant code:

if self.keyboard_navigation:
self.set_hooks()
self.popup.win.focus(False)
def set_hooks(self):
hook.subscribe.client_focus(self.focus_change)
hook.subscribe.focus_change(self.focus_change)
self._hooked = True
def unset_hooks(self):
if self._hooked:
hook.unsubscribe.client_focus(self.focus_change)
hook.unsubscribe.focus_change(self.focus_change)
self._hooked = False
def focus_change(self, window=None):
if window is None or not window == self.popup.win:
self.kill()

So, we would just need an optional parameter to disable the hooks.

If you comment out line 203, does it work as expected/desired?

@DanTheMan1244
Copy link
Author

I tried commenting out line 203 as you suggested. It did not have any effect on the behavior of the Popup.

@elParaguayo
Copy link
Owner

Commenting out line 203 fixes the issue for me. Can you try again?

@DanTheMan1244
Copy link
Author

I have tried again. Simply commenting out line 203 and then writing the file and reloading qtile does not do anything for me. I have also tried commenting out the entire set_hooks() function, but that also did nothing.

@elParaguayo
Copy link
Owner

What do you mean by "reloading"? Are you completely exiting qtile?

@DanTheMan1244
Copy link
Author

No, just using a keybinding to call lazy.reload_config()

@elParaguayo
Copy link
Owner

That won't work. You'll need to exit qtile to load the new code. You're not changing your config.

@DanTheMan1244
Copy link
Author

Yes, that worked. I had figured that reloading the config would work due to the popup being defined in the config, but I understand now.

@elParaguayo
Copy link
Owner

Ok, let me play around with this. May see if we can have an option to disable those hooks rather than you having to hard code it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants