vlevit / xatk

a keyboard-driven window switcher for x11
GNU General Public License v2.0
13 stars 0 forks source link

Is it possible to minimize windows by same key if it is visible #6

Open pymen opened 3 years ago

pymen commented 3 years ago

Really nice tool, was looking for it for a long time.

For my workflow I need to have the ability to temporary show and hide window (for example) TelegramDesktop, for example, now i need to

  1. click super+t -> telegram shown
  2. click super+p -> pycharm shown, telegram hidden

It will be really nice instead

  1. click super+t -> telegram shown
  2. click super+t -> telegram hidden

Other

vlevit commented 3 years ago

I'm glad you find it useful. I think your ideas are great! Personally I'd perhaps rely on window focus instead of visibility. BUT I lack time and motivation to add new features to xatk partially because it's unclear how long I will be able to avoid wayland.

pymen commented 3 years ago

Thanks for the answer!

Personally I'd perhaps rely on window focus instead of visibility.

as I can see the issue with focus, that if you have 4 windows on one monitor (without overlapping) - both of them are visible, but only one has focus, the same if you have 2 monitors...

I have added some hack to the source code, but because I have never worked with these areas - it is ugly but working :)

    @staticmethod
    def raise_window(wid, desktop_action=DESKTOP_IGNORE):
        """Activate window.

        Optionally switch a desktop or move a window to the active desktop.
        Raise BadWindow.
        """
        if Xtool.is_visible(wid):
            Xtool.hide_window(wid)
            return
    @staticmethod
    def is_visible(wid):
        from xcovered import XCovered
        return not XCovered().is_covered(wid)

    @staticmethod
    def hide_window(wid):
        from ewmh import EWMH
        cmd = EWMH()
        win = cmd.display.create_resource_object('window', wid)
        cmd.setWmState(win, 1, '_NET_WM_STATE_HIDDEN')
        cmd.display.flush()

XCovered

class XCovered(object):
    def __init__(self):
        import ewmh_xlib as ewmh
        self.ewmh = ewmh.EWMH()

def is_covered(self, window_id):
    wid = self.ewmh.dpy.create_resource_object('window', window_id)
    return self.is_fully_covered(wid)