[gnome-games/sudoku-vala] sudoku: Ensure number picker is always visible



commit 633b12e6ff6dcebd372ac362a111e6c68cd2329d
Author: Robert Ancell <robert ancell canonical com>
Date:   Tue Jul 12 09:54:25 2011 +1000

    sudoku: Ensure number picker is always visible

 gnome-sudoku/src/sudoku-view.vala |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/gnome-sudoku/src/sudoku-view.vala b/gnome-sudoku/src/sudoku-view.vala
index 6ff8f4c..01160f8 100644
--- a/gnome-sudoku/src/sudoku-view.vala
+++ b/gnome-sudoku/src/sudoku-view.vala
@@ -130,7 +130,20 @@ private class SudokuCellView : Gtk.DrawingArea
         int x, y, width, height;
         get_window ().get_origin (out x, out y);
         popup.get_size (out width, out height);
-        popup.move (x - (width - get_allocated_width ()) / 2, y - (height - get_allocated_height ()) / 2);
+
+        var screen = popup.get_screen ();
+        var popup_x = x - (width - get_allocated_width ()) / 2;
+        var popup_y = y - (height - get_allocated_height ()) / 2;
+        if (popup_x < 0)
+            popup_x = 0;
+        else if (popup_x + width > screen.get_width ())
+            popup_x = screen.get_width () - width;
+        if (popup_y < 0)
+            popup_y = 0;
+        else if (popup_y + height > screen.get_height ())
+            popup_y = screen.get_height () - height;
+        popup.move (popup_x, popup_y);
+
         popup.show ();
     }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]