Ticket #3833: 0001-Palette-update-position-when-the-screen-size-changes.2.patch

File 0001-Palette-update-position-when-the-screen-size-changes.2.patch, 2.1 KB (added by manuq, 8 years ago)

New version that fixes the issue of the previous one.

  • src/sugar3/graphics/palettewindow.py

    From fa04cf5f06dc76ef9c7329a5a6438f7cc6e0f60d Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Manuel=20Qui=C3=B1ones?= <manuq@laptop.org>
    Date: Sat, 24 Nov 2012 11:28:06 -0300
    Subject: [PATCH toolkit] Palette: update position when the screen size
     changes - SL #3833
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    Mail-Followup-To: <sugar-devel@lists.sugarlabs.org>
    
    Do the same as in shell commit b6a30769 .  Add a callback to the
    size-changed signal of the screen.
    
    Hide the palette after the resize, because it will not be in the
    desired position.
    
    Signed-off-by: Manuel Quiñones <manuq@laptop.org>
    ---
     src/sugar3/graphics/palettewindow.py | 21 ++++++++++++++++++---
     1 file changed, 18 insertions(+), 3 deletions(-)
    
    diff --git a/src/sugar3/graphics/palettewindow.py b/src/sugar3/graphics/palettewindow.py
    index 7063681..a9081cc 100644
    a b class Invoker(GObject.GObject): 
    770770        self.parent = None
    771771
    772772        self._screen_area = Gdk.Rectangle()
    773         self._screen_area.x = self._screen_area.y = 0
    774         self._screen_area.width = Gdk.Screen.width()
    775         self._screen_area.height = Gdk.Screen.height()
     773        self._screen_area.x = 0
     774        self._screen_area.y = 0
     775
     776        screen = Gdk.Screen.get_default()
     777        screen.connect('size-changed', self.__size_changed_cb)
     778        self._update_screen_size(screen)
     779
    776780        self._position_hint = self.ANCHORED
    777781        self._cursor_x = -1
    778782        self._cursor_y = -1
    class Invoker(GObject.GObject): 
    782786        self._lock_palette = False
    783787        self.locked = False
    784788
     789
     790    def __size_changed_cb(self, screen):
     791        self._update_screen_size(screen)
     792        # The palette will not be in the desired position, so we hide it.
     793        if self.palette and self.palette.is_up():
     794            self.palette.popdown(immediate=True)
     795
     796    def _update_screen_size(self, screen):
     797        self._screen_area.width = screen.width()
     798        self._screen_area.height = screen.height()
     799
    785800    def attach(self, parent):
    786801        self.parent = parent
    787802