guake icon indicating copy to clipboard operation
guake copied to clipboard

Two monitors bad terminal width alignment

Open damianw345 opened this issue 7 years ago • 18 comments

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:

  • Ubuntu 18.04
  • Gnome version: 3.28.1

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

dockleft dockright

damianw345 avatar Jun 28 '18 21:06 damianw345

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.

aichingm avatar Aug 15 '18 18:08 aichingm

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

gsemet avatar Aug 24 '18 21:08 gsemet

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

benyitzhaki avatar Sep 03 '18 07:09 benyitzhaki

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

obrejla avatar Sep 05 '18 13:09 obrejla

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.

ferdinandyb avatar Oct 15 '18 12:10 ferdinandyb

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 avatar Feb 24 '20 10:02 fed-franz

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)

fed-franz avatar Feb 24 '20 15:02 fed-franz

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

aichingm avatar Mar 02 '20 12:03 aichingm

@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.

fed-franz avatar Mar 03 '20 10:03 fed-franz

@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.

kpalczewski avatar Apr 16 '20 17:04 kpalczewski

@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.

fed-franz avatar Apr 17 '20 16:04 fed-franz

@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.

kpalczewski avatar Apr 17 '20 23:04 kpalczewski

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

fed-franz avatar Apr 19 '20 17:04 fed-franz

~$ 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

kpalczewski avatar May 06 '20 17:05 kpalczewski

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.

fed-franz avatar May 07 '20 14:05 fed-franz

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).

leodelgadodev avatar Feb 07 '21 23:02 leodelgadodev

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.

Davidy22 avatar Sep 13 '21 13:09 Davidy22

I have commented in #1765

kpalczewski avatar Sep 14 '21 08:09 kpalczewski