Devin Jeanpierre committed 1cf1262 Draft

Fixed resizing to work properly.

Problem is that VIDEORESIZE doesn't actually resize the screen, to do that,
you need to call set_mode() again.

Black borders need to be fixed more efficiently in the future.

  • Participants
  • Parent commits 5f207c3

Comments (0)

Files changed (1)

         self._grid_dirty = set()
-    def change_surface(self, surface, size=None):
+    def change_surface(self, surface):
-        Set the screen to be attached to a new surface (with new resolution)
+        Set the screen to be attached to a new surface.
         After calling this method, all new draws will go to `surface`.
         Do not call this method in the middle of a draw operation.
-        old = self.surface
         self.surface = surface
-        if size is None:
-            size = surface.get_size()
-        # first check is in case we're changing to the same surface, in which
-        # case we maybe can't _see_ that the size has changed, but it has.
-        if old is surface or old.get_size() != size:
-            self._init_chargrid(size)
-        self.clear() # FIXME: why doesn't this clear the edges?
+        self._init_chargrid(surface.get_size())
+        self.clear()
     def set_mouse_tracking(self):
             elif evt.type == pygame.MOUSEMOTION:
             elif evt.type == pygame.VIDEORESIZE:
-                self.change_surface(self.surface, evt.size)
+                # FIXME: only update the border squares to be black
+                self.surface.fill(0)
+                pygame.display.flip()
+                self.change_surface(
+                    pygame.display.set_mode(evt.size, pygame.RESIZABLE))
                 keys.append('window resize')
         return keys, raws
     def _handle_keyup(self, k):
         if k in SHIFT_KEYS:
             self._m_shift = False
         elif k in META_KEYS:
             self._m_meta = False
         elif k in CTRL_KEYS: