Guake / guake

Drop-down terminal for GNOME
https://guake.github.io
GNU General Public License v2.0
4.39k stars 575 forks source link

Two monitors bad terminal width alignment #1350

Open damianw345 opened 6 years ago

damianw345 commented 6 years ago

While having dock on the left side Guake is partially hidden below dock. While having dock on the right side Guake is partially on the left monitor.

System information:

$ guake --version Guake Terminal: 3.3.1 VTE: 0.52.2 VTE runtime: 0.52.2 Gtk: 3.22.30

dockleft dockright

aichingm commented 5 years ago

Have you tried playing the the displacement options?

Preferences -> Main Window

Reduce the width, set the position to left or right and add some pixels of displacement.

gsemet commented 5 years ago

i think the window calculation can be completely redone in a futur version... but not for today

benyitzhaki commented 5 years ago

same here since upgrading to ubuntu 18.04. I guess its because gnome

obrejla commented 5 years ago

Same problem...it's quite ugly :/

ferdinandyb commented 5 years ago

Yup, ran into this as well :( For me it actually works ok on the larger, non-main screen which is on the left side, and messes it up on the smaller main screen on the right.

fed-franz commented 4 years ago

Similar problem here: Left monitor (with dock): guake goes beyond the screen limit and ends up showing on the right monitor Right monitor (no dock): guake shows ok

@aichingm The alignment/displacement options seem to be completely ignored

fed-franz commented 4 years ago

I managed to solve the issue in my case. The problem was that ubuntu now uses its own unity-like dock, which is an extension of gnome-shell. As such, the dock is not correctly detected nor managed by guake, as it only works with the unity dock.

I wrote the code to handle the gnome dock: In guake_app.py: Before set_final_window_rect:

    def is_using_gnome(self):
        if os.environ.get('XDG_CURRENT_DESKTOP', '').lower() == "gnome".lower():
            return True

        if os.environ.get('XDG_CURRENT_DESKTOP', '').lower() == "ubuntu:gnome".lower():
            return True

        return False

In set_final_window_rect, after the if self.is_using_unity() block:

        if self.is_using_gnome():
            #log.debug("CURRENT MONITOR: %s", monitor)
            try:
                dock_enabled = subprocess.check_output([
                        '/usr/bin/dconf', 'list', '/org/gnome/shell/extensions/dash-to-dock/'
                    ])

                if dock_enabled:
                    log.debug("Gnome dock enabled")
            #dconf VALUES:
            #preferred-monitor=0|1 : monitor_num on which dock is shown
                #multi-monitor=true|false : true=>shown on all monitors
            #dock-fixed=true|false : false=>auto-hide on , unset=>true
            #dock-position='LEFT'|'RIGHT'|'BOTTOM' (unset = 'LEFT')
            #dash-max-icon-size=n : size in pixels

            ## Check if dock is active on current monitor ##
                    dock_active = False
            #check if active on all monitors
                    multi_monitor = subprocess.check_output([
                            '/usr/bin/dconf', 'read',
                            '/org/gnome/shell/extensions/dash-to-dock/multi-monitor'
                        ]).decode("utf-8").rstrip() or "true"

                    if multi_monitor == "true":
                        dock_active = True
                    else:
                        preferred_monitor = int(
                            subprocess.check_output([
                                '/usr/bin/dconf', 'read',
                                '/org/gnome/shell/extensions/dash-to-dock/preferred-monitor'
                            ])
                        )
                        #check if we are on preferred monitor
                        if monitor == preferred_monitor:
                            dock_active = True

            ## If active, check if and where the dock is shown ##
                    dock_shown = False

                    # If active, check if auto-hide is on
                    if dock_active:
                        log.debug("Gnome dock active")
                    #check if auto-hide is on
                        dock_fixed = subprocess.check_output([
                            '/usr/bin/dconf', 'read',
                            '/org/gnome/shell/extensions/dash-to-dock/dock-fixed'
                        ]).decode("utf-8").rstrip() or "true"
                        if dock_fixed == "false":
                            auto_hide = True
                        else: auto_hide = False

                #If actually shown
                        if not auto_hide:
                    #Check dock's position
                            dock_pos = subprocess.check_output([
                                '/usr/bin/dconf', 'read',
                                '/org/gnome/shell/extensions/dash-to-dock/dock-position'
                            ]).decode("utf-8").rstrip() or "'LEFT'"

                            log.debug("dock_pos = %s", dock_pos)
                            if dock_pos == "'LEFT'" or dock_pos == "'RIGHT'":
                                log.debug("dock_pos is LEFT or RIGHT")
                                dock_size = int(
                                    subprocess.check_output([
                                        '/usr/bin/dconf', 'read',
                                        '/org/gnome/shell/extensions/dash-to-dock/dash-max-icon-size'
                                    ])
                                )
                    ## Adjust width ##
                                log.debug("Adjusting window size")
                                dock_shown = True
                                dock_size += 19
                                window_rect.width = window_rect.width - dock_size
                                if monitor == 1:
                                    window_rect.x += dock_size
                 #else:
                 # If bottom, reduce window_rect.height?

            except Exception as e:
                    pass

I'm not an expert in Python, so there might be some issue, but the code is working fine on my system for all combinations of options for the Gnome dock (auto-hide/fixed, left/right/bottom, show on all monitors/only monitor1/only monitor2)

aichingm commented 4 years ago

@frz-dev Does the issue with the displacement still occur?

fed-franz commented 4 years ago

@aichingm Yes, the problem is that the displament is relative to the Unity dock, so the option has no effect when using the Gnome dock.

kpalczewski commented 4 years ago

@aichingm the displacement still occurs.

I user dash to dock extension with ubuntu 19.10. https://extensions.gnome.org/extension/307/dash-to-dock/

The behavior is the same as written by @damianw345 :

While having dock on the left side Guake is partially hidden below dock. While having dock on the right side Guake is partially on the left monitor.

fed-franz commented 4 years ago

@kpalczewski could you try the code I posted to check if it works? Maybe some positive feedback would accelerate its integration in the code.

I'll try to create a quick patch asap, but you can easily add the code manually in the guake_app.py file. You can find the file to change in the /usr/lib/python3/dist-packages/guake/ subfolder.

kpalczewski commented 4 years ago

@frz-dev I was able to add this code:

  def is_using_gnome(self):

            if os.environ.get('XDG_CURRENT_DESKTOP', '').lower() == "gnome".lower():
                return True

            if os.environ.get('XDG_CURRENT_DESKTOP', '').lower() == "ubuntu:gnome".lower():
                return True
            return False

    window_rect = RectCalculator.set_final_window_rect(self.settings, self.window)
    self.window.stick()

but I wasn't able to find if self.is_using_unity() , so I wasn't able to alter 2nd part of the code.

Do I have to compile it, or a restart is sufficient? Restart didn't help with only this ^ part of the code altered.

fed-franz commented 4 years ago

What version are you using?

Maybe you can look for these lines: total_width = window_rect.width total_height = window_rect.height

If you find them, you can put the second block right before.

This is the pull request I submitted. You can check it out as a reference: https://github.com/Guake/guake/pull/1729/commits/cfef97d2ffa3abd786bea98ed68d0e860fcc80a4

kpalczewski commented 4 years ago

~$ guake --version Guake Terminal: 3.7.1 VTE: 0.60.1 VTE runtime: 0.60.1 Gtk: 3.24.18

Branch master, I can't find total_width or def set_final_window_rect(self): in guake/guake_app.py

fed-franz commented 4 years ago

For what I can see there's been a big code refactoring in the current version (I'm using version 3.0.5). So my fix cannot be applied to your version. You can either downgrade Guake or hope for developers to fix the issue.

Unfortunately I can't help right now because I only have 1 monitor (I'm working from home due to the COVID). I'll check it out as soon as possible.

leodelgadodev commented 3 years ago

bump? I'm also having this problem using latte dock and Kubuntu. Dual monitor setup, dock to the left/right (it has no problem with dock to the bottom though).

Davidy22 commented 2 years ago

A patch #1765 that may fix this has just been merged. Can you confirm whether or not this is fixed in the current git main? If you can't compile, updates when the next version is released are also welcome.

kpalczewski commented 2 years ago

I have commented in #1765