Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#4419 closed defect (duplicate)

Bottom-frame icons (Network, Battery,Sound etc.) not working on XO-4 (build 28), in ebook-portrait mode

Reported by: ajay_garg Owned by: erikos
Priority: Unspecified by Maintainer Milestone:
Component: Sugar Version: 0.98.x
Severity: Unspecified Keywords: r?
Cc: ajay_garg Distribution/OS: Fedora
Bug Status: Unconfirmed

Description

a)
Ensure that build 28 is on XO-4.

b)
Ensure that XO-4 is in ebook-mode.

c)
Rotate the screen, to bring the screen in portrait-model.

d)
When any of these icons is clicked, the palette does not show up; instead the following stacktrace is seen.

Traceback (most recent call last):

File "/usr/lib/python2.7/site-packages/sugar3/graphics/palettewindow.py", line 679, in _invoker_toggle_state_cb

self.popup(immediate=True, state=self.SECONDARY)

File "/usr/lib/python2.7/site-packages/sugar3/graphics/palette.py", line 207, in popup

PaletteWindow.popup(self, immediate)

File "/usr/lib/python2.7/site-packages/sugar3/graphics/palettewindow.py", line 623, in popup

self._alignment = self._invoker.get_alignment(full_size_request)

File "/usr/lib/python2.7/site-packages/sugar3/graphics/palettewindow.py", line 904, in get_alignment

ph = best_alignment[0]

TypeError: 'NoneType' object has no attribute 'getitem'

Change History (7)

comment:1 Changed 8 years ago by ajay_garg

  • Cc ajay_garg added

comment:2 Changed 8 years ago by ajay_garg

Note that things work fine when the screen is in landscape-mode.

comment:3 Changed 8 years ago by erikos

  • Keywords r? added

The following does update the cached screen width and height variables when the screen dimensions change.

diff --git a/src/sugar3/graphics/palettewindow.py b/src/sugar3/graphics/palettewindow.py
index c48ae55..7fe850d 100644
--- a/src/sugar3/graphics/palettewindow.py
+++ b/src/sugar3/graphics/palettewindow.py
@@ -775,10 +775,13 @@ class Invoker(GObject.GObject):
 
         self.parent = None
 
+
         self._screen_area = Gdk.Rectangle()
         self._screen_area.x = self._screen_area.y = 0
-        self._screen_area.width = Gdk.Screen.width()
-        self._screen_area.height = Gdk.Screen.height()
+        screen = Gdk.Screen.get_default()
+        screen.connect('size-changed', self.__size_changed_cb)
+        self._set_dimensions()
+
         self._position_hint = self.ANCHORED
         self._cursor_x = -1
         self._cursor_y = -1
@@ -797,6 +800,13 @@ class Invoker(GObject.GObject):
             self._palette.destroy()
             self._palette = None
 
+    def __size_changed_cb(self, screen):
+        self._set_dimensions()
+
+    def _set_dimensions(self):
+        self._screen_area.width = Gdk.Screen.width()
+        self._screen_area.height = Gdk.Screen.height()
+
     def _get_position_for_alignment(self, alignment, palette_dim):
         palette_halign = alignment[0]
         palette_valign = alignment[1]

comment:4 Changed 8 years ago by erikos

Actually, the second option is to just not cache the dimensions:

diff --git a/src/sugar3/graphics/palettewindow.py b/src/sugar3/graphics/palettewindow.py
index c48ae55..67a4407 100644
--- a/src/sugar3/graphics/palettewindow.py
+++ b/src/sugar3/graphics/palettewindow.py
@@ -777,8 +777,6 @@ class Invoker(GObject.GObject):
 
         self._screen_area = Gdk.Rectangle()
         self._screen_area.x = self._screen_area.y = 0
-        self._screen_area.width = Gdk.Screen.width()
-        self._screen_area.height = Gdk.Screen.height()
         self._position_hint = self.ANCHORED
         self._cursor_x = -1
         self._cursor_y = -1
@@ -841,8 +839,8 @@ class Invoker(GObject.GObject):
     def _in_screen(self, rect):
         return rect.x >= self._screen_area.x and \
                rect.y >= self._screen_area.y and \
-               rect.x + rect.width <= self._screen_area.width and \
-               rect.y + rect.height <= self._screen_area.height
+               rect.x + rect.width <= Gdk.Screen.width() and \
+               rect.y + rect.height <= Gdk.Screen.height()
 
     def _get_area_in_screen(self, rect):
         """Return area of rectangle visible in the screen"""
@@ -850,9 +848,9 @@ class Invoker(GObject.GObject):
         x1 = max(rect.x, self._screen_area.x)
         y1 = max(rect.y, self._screen_area.y)
         x2 = min(rect.x + rect.width,
-                self._screen_area.x + self._screen_area.width)
+                self._screen_area.x + Gdk.Screen.width())
         y2 = min(rect.y + rect.height,
-                self._screen_area.y + self._screen_area.height)
+                self._screen_area.y + Gdk.Screen.height())
 
         return (x2 - x1) * (y2 - y1)
 
@@ -882,8 +880,8 @@ class Invoker(GObject.GObject):
         rect.x = max(0, rect.x)
         rect.y = max(0, rect.y)
 
-        rect.x = min(rect.x, self._screen_area.width - rect.width)
-        rect.y = min(rect.y, self._screen_area.height - rect.height)
+        rect.x = min(rect.x, Gdk.Screen.width() - rect.width)
+        rect.y = min(rect.y, Gdk.Screen.height() - rect.height)
 
         return rect

I think I prefer that one.

comment:5 Changed 8 years ago by manuq

  • Resolution set to duplicate
  • Status changed from new to closed

comment:6 Changed 8 years ago by manuq

Dup of #3833 - I'm moving the patches there...

comment:7 Changed 8 years ago by dnarvaez

  • Milestone 0.98 deleted

Milestone 0.98 deleted

Note: See TracTickets for help on using tickets.