]> gitweb.factorcode.org Git - factor.git/commitdiff
ui.gadgets.glass: constrain popup over viewport
authorJohn Benediktsson <mrjbq7@gmail.com>
Fri, 11 Feb 2022 22:18:29 +0000 (14:18 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Fri, 11 Feb 2022 22:18:29 +0000 (14:18 -0800)
basis/ui/gadgets/glass/glass.factor

index ba47f55e38d762e10cf43445d3fa35da9eaba5ac..7f3717921a2fc7e57f79bf8832afa3a074cf1890 100644 (file)
@@ -1,8 +1,9 @@
 ! Copyright (C) 2005, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors kernel math.rectangles
-math.rectangles.positioning namespaces ui.gadgets
-ui.gadgets.worlds ui.gadgets.wrappers ui.gestures vectors ;
+math.rectangles.positioning math.vectors namespaces ui.gadgets
+ui.gadgets.viewports ui.gadgets.worlds ui.gadgets.wrappers
+ui.gestures vectors ;
 FROM: ui.gadgets.wrappers => wrapper ;
 IN: ui.gadgets.glass
 
@@ -21,7 +22,9 @@ TUPLE: glass < gadget visible-rect owner ;
         swap >>owner ;
 
 : visible-rect ( glass -- rect )
-    [ visible-rect>> ] [ owner>> ] bi screen-loc offset-rect ;
+    [ visible-rect>> ] [ owner>> ] bi
+    [ screen-loc ] [ [ viewport? ] find-parent [ screen-loc vmax ] when* ] bi
+    offset-rect ;
 
 M: glass layout*
     [