Multi Screen Support
authorMichael Beyl <mb@exept.de>
Mon, 11 Oct 2010 11:05:37 +0200
changeset 5611 4c8229c880fd
parent 5610 9c727f792bd2
child 5612 f7b84930b3fb
Multi Screen Support
ModalBox.st
--- a/ModalBox.st	Mon Oct 11 11:05:20 2010 +0200
+++ b/ModalBox.st	Mon Oct 11 11:05:37 2010 +0200
@@ -37,7 +37,7 @@
 documentation
 "
     this class implements modal boxes; ModalBoxes are different from
-    others, in that they take control over the current topview, until 
+    others, in that they take control over the current topview, until
     all processing is done (i.e. the currently active topview and all of
     its subviews will not handle user events while the box is active).
 
@@ -47,12 +47,12 @@
     change the default setting from your display.rc file.
 
     [see also:]
-        StandardSystemView 
-        DialogBox
-        ( introduction to view programming :html: programming/viewintro.html )
+	StandardSystemView
+	DialogBox
+	( introduction to view programming :html: programming/viewintro.html )
 
     [author:]
-        Claus Gittinger
+	Claus Gittinger
 "
 ! !
 
@@ -109,11 +109,11 @@
     "Modified: 20.10.1997 / 15:07:37 / cg"
 !
 
-useTransientViews:aBoolean 
+useTransientViews:aBoolean
     "change the way modalBoxes are created on the Display.
-     If the argument is true, transient views are used; 
-     otherwise override redirect views are used. 
-     Depending on your windowmanager, either one may have problems. 
+     If the argument is true, transient views are used;
+     otherwise override redirect views are used.
+     Depending on your windowmanager, either one may have problems.
      You may want to change the setting
      from your display.rc or d_xxx.rc file.
      This is now obsolete - transient views work and are always used."
@@ -122,14 +122,14 @@
 
     "
      ModalBox useTransientViews:false
-     ModalBox useTransientViews:true 
+     ModalBox useTransientViews:true
     "
 
     "Modified: 28.2.1997 / 22:27:46 / cg"
 !
 
-usingTransientViews 
-    "return true, if transient views are used 
+usingTransientViews
+    "return true, if transient views are used
      for modalBoxes. This is somewhat obsolete."
 
     ^ UseTransientViews
@@ -155,9 +155,9 @@
      If set, the box will take total control over the
      keyboard, not allowing input to other views/boxes
      while active.
-     DANGER: 
-        only use this for very very urgent boxes, since
-        no interaction with ANY view on the screen is possible then."
+     DANGER:
+	only use this for very very urgent boxes, since
+	no interaction with ANY view on the screen is possible then."
 
     exclusiveKeyboard := aBoolean
 
@@ -177,26 +177,26 @@
      bring myself to the front again.
     "
     aView isPopUpView ifFalse:[
-        "
-         if I have a mainGroup,
-         only raise if its one of my maingroup-views
-        "
-        windowGroup notNil ifTrue:[
-            mainGroup := windowGroup mainGroup.
-            mainGroup notNil ifTrue:[
-                topViews := mainGroup topViews.
-                topViews notNil ifTrue:[
-                    topViews do:[:eachTopView |
-                        aView == eachTopView ifTrue:[
-                            self raise.     
-                            ^ self
-                        ]
-                    ]
-                ].
-                ^ self
-            ]
-        ].
-        self raise
+	"
+	 if I have a mainGroup,
+	 only raise if its one of my maingroup-views
+	"
+	windowGroup notNil ifTrue:[
+	    mainGroup := windowGroup mainGroup.
+	    mainGroup notNil ifTrue:[
+		topViews := mainGroup topViews.
+		topViews notNil ifTrue:[
+		    topViews do:[:eachTopView |
+			aView == eachTopView ifTrue:[
+			    self raise.
+			    ^ self
+			]
+		    ]
+		].
+		^ self
+	    ]
+	].
+	self raise
     ]
 !
 
@@ -269,11 +269,11 @@
      and to release the global keyboard grab (if there is one)"
 
     shadowView notNil ifTrue:[
-        shadowView destroy.
-        shadowView := nil
+	shadowView destroy.
+	shadowView := nil
     ].
     exclusiveKeyboard ifTrue:[
-        self forceUngrabKeyboard
+	self forceUngrabKeyboard
     ].
     super destroy.
 
@@ -298,10 +298,10 @@
     super initStyle.
     style := styleSheet name.
     ((style ~~ #normal) and:[style ~~ #mswindows]) ifTrue:[
-        self borderWidth:0.
-        UseTransientViews ifFalse:[
-            self level:2
-        ]
+	self borderWidth:0.
+	UseTransientViews ifFalse:[
+	    self level:2
+	]
     ]
 
     "Modified: 22.1.1997 / 11:57:35 / cg"
@@ -312,7 +312,7 @@
 
     super initialize.
 
-    "/ self beDialogView. 
+    "/ self beDialogView.
     self beToolDialog.
 
     exclusiveKeyboard := false.
@@ -321,55 +321,55 @@
 "/    label := 'Popup'.
 
     UseTransientViews ifFalse:[
-        (PopUpView shadowsOnDevice:device) ifTrue:[
-            shadowView := (ShadowView onDevice:device) for:self
-        ].
+	(PopUpView shadowsOnDevice:device) ifTrue:[
+	    shadowView := (ShadowView onDevice:device) for:self
+	].
 
-        form := Form width:8 height:8 
-                     fromArray:#[2r00000000
-                                 2r00000000 
-                                 2r00000000 
-                                 2r00000001
-                                 2r00000011
-                                 2r00000111 
-                                 2r00001111
-                                 2r00011111 
-                                ]
-                     onDevice:device.
-        resizeButton := Button label:form in:self.
-        resizeButton origin:1.0 @ 1.0 corner:1.0@1.0.
-        resizeButton activeForegroundColor:(resizeButton foregroundColor).
-        resizeButton activeBackgroundColor:(resizeButton backgroundColor).
-        resizeButton enteredBackgroundColor:(resizeButton backgroundColor).
-        resizeButton leftInset:-8; topInset:-8.
-        resizeButton releaseAction:[].
-        resizeButton pressAction:[resizeButton turnOff; redraw. self doResize].
-        resizeButton borderWidth:0.
-        resizeButton activeLevel:0; passiveLevel:0.
-        resizeButton cursor:(Cursor corner).
+	form := Form width:8 height:8
+		     fromArray:#[2r00000000
+				 2r00000000
+				 2r00000000
+				 2r00000001
+				 2r00000011
+				 2r00000111
+				 2r00001111
+				 2r00011111
+				]
+		     onDevice:device.
+	resizeButton := Button label:form in:self.
+	resizeButton origin:1.0 @ 1.0 corner:1.0@1.0.
+	resizeButton activeForegroundColor:(resizeButton foregroundColor).
+	resizeButton activeBackgroundColor:(resizeButton backgroundColor).
+	resizeButton enteredBackgroundColor:(resizeButton backgroundColor).
+	resizeButton leftInset:-8; topInset:-8.
+	resizeButton releaseAction:[].
+	resizeButton pressAction:[resizeButton turnOff; redraw. self doResize].
+	resizeButton borderWidth:0.
+	resizeButton activeLevel:0; passiveLevel:0.
+	resizeButton cursor:(Cursor corner).
 
-        form := Form width:8 height:8 
-                     fromArray:#[2r11111000
-                                 2r11110000 
-                                 2r11100000 
-                                 2r11000000
-                                 2r10000000
-                                 2r00000000 
-                                 2r00000000
-                                 2r00000000 
-                                ]
-                     onDevice:device.
-        moveButton := Button label:form in:self.
-        moveButton origin:0.0 @ 0.0 corner:0.0@0.0.
-        moveButton activeForegroundColor:(moveButton foregroundColor).
-        moveButton activeBackgroundColor:(moveButton backgroundColor).
-        moveButton enteredBackgroundColor:(moveButton backgroundColor).
-        moveButton rightInset:-8; bottomInset:-8.
-        moveButton releaseAction:[].
-        moveButton pressAction:[moveButton turnOff; redraw. self doMove].
-        moveButton borderWidth:0.
-        moveButton activeLevel:0; passiveLevel:0.
-        moveButton cursor:(Cursor origin)
+	form := Form width:8 height:8
+		     fromArray:#[2r11111000
+				 2r11110000
+				 2r11100000
+				 2r11000000
+				 2r10000000
+				 2r00000000
+				 2r00000000
+				 2r00000000
+				]
+		     onDevice:device.
+	moveButton := Button label:form in:self.
+	moveButton origin:0.0 @ 0.0 corner:0.0@0.0.
+	moveButton activeForegroundColor:(moveButton foregroundColor).
+	moveButton activeBackgroundColor:(moveButton backgroundColor).
+	moveButton enteredBackgroundColor:(moveButton backgroundColor).
+	moveButton rightInset:-8; bottomInset:-8.
+	moveButton releaseAction:[].
+	moveButton pressAction:[moveButton turnOff; redraw. self doMove].
+	moveButton borderWidth:0.
+	moveButton activeLevel:0; passiveLevel:0.
+	moveButton cursor:(Cursor origin)
     ].
 
     "Modified: 24.7.1997 / 16:08:11 / cg"
@@ -395,7 +395,7 @@
 reinitialize
     "if I have already been reinited - return"
     drawableId notNil ifTrue:[
-        ^ self
+	^ self
     ].
     "physically create the view & subviews"
     self recreate.
@@ -415,17 +415,17 @@
     newExtent := self preferredExtent.
     maxExtent := self maxExtent.
     maxExtent notNil ifTrue:[
-        newExtent := newExtent min:maxExtent.
+	newExtent := newExtent min:maxExtent.
     ].
     newExtent ~= self extent ifTrue:[
-        (shown and:[shadowView notNil]) ifTrue:[
-            shadowView unmap.
-            self extent:newExtent.
-            shadowView realize.
-            self raise
-        ] ifFalse:[
-            self extent:newExtent.
-        ].
+	(shown and:[shadowView notNil]) ifTrue:[
+	    shadowView unmap.
+	    self extent:newExtent.
+	    shadowView realize.
+	    self raise
+	] ifFalse:[
+	    self extent:newExtent.
+	].
     ].
 !
 
@@ -441,26 +441,26 @@
     newExtent = self extent ifTrue:[^ self].
 
     shown ifTrue:[
-        delta := width - newExtent x.
-        newLeft := left + delta.
-        (((newLeft @ top) extent:newExtent) 
-            containsPoint:device pointerPosition)
-        ifFalse:[newLeft := left].
-        newLeft < 0 ifTrue:[newLeft := 0].
-        screenWidth := device usableWidth.
-        newLeft + newExtent x > screenWidth ifTrue:[
-            newLeft := screenWidth - newExtent x
-        ].
-        shadowView notNil ifTrue:[
-            shadowView unmap.
-        ].
-        self origin:(newLeft @ top) extent:newExtent.
-        shadowView notNil ifTrue:[
-            shadowView realize.
-            self raise.
-        ].
+	delta := width - newExtent x.
+	newLeft := left + delta.
+	(((newLeft @ top) extent:newExtent)
+	    containsPoint:device pointerPosition)
+	ifFalse:[newLeft := left].
+	newLeft < 0 ifTrue:[newLeft := 0].
+	screenWidth := device usableWidth.
+	newLeft + newExtent x > screenWidth ifTrue:[
+	    newLeft := screenWidth - newExtent x
+	].
+	shadowView notNil ifTrue:[
+	    shadowView unmap.
+	].
+	self origin:(newLeft @ top) extent:newExtent.
+	shadowView notNil ifTrue:[
+	    shadowView realize.
+	    self raise.
+	].
     ] ifFalse:[
-        self extent:newExtent.
+	self extent:newExtent.
     ].
 
     "Modified: 6.9.1995 / 15:31:21 / claus"
@@ -478,12 +478,12 @@
 
     r := device rectangleFromUser:(self origin corner:self corner) keepExtent:true.
     shadowView notNil ifTrue:[
-        shadowView unmap
+	shadowView unmap
     ].
     self origin:r origin extent:(self extent).
     shadowView notNil ifTrue:[
-        shadowView realize.
-        self raise.
+	shadowView realize.
+	self raise.
     ].
 
     "Modified: 3.5.1996 / 23:47:38 / stefan"
@@ -499,12 +499,12 @@
 
     r := device rectangleFromUser:(self origin corner:self corner).
     shadowView notNil ifTrue:[
-        shadowView unmap
+	shadowView unmap
     ].
     self origin:r origin extent:(r extent max:(100@100)).
     shadowView notNil ifTrue:[
-        shadowView realize.
-        self raise
+	shadowView realize.
+	self raise
     ].
 
     "Modified: 3.5.1996 / 23:47:47 / stefan"
@@ -526,7 +526,7 @@
      (may be used internally by the device as a decoration hint)"
 
     UseTransientViews ifFalse:[
-        ^ #popUp
+	^ #popUp
     ].
     ^ super windowStyle
 
@@ -545,11 +545,11 @@
     "the implementation is simple: just fork of a process
      to hide me."
     [
-        Delay waitForSeconds:seconds.
-        self shown ifTrue:[
-            self hide. 
-            anAction value
-        ]
+	Delay waitForSeconds:seconds.
+	self shown ifTrue:[
+	    self hide.
+	    anAction value
+	]
     ] forkAt:4.
 
     "
@@ -580,28 +580,28 @@
 
     shadowView notNil ifTrue:[shadowView unmap].
     windowGroup notNil ifTrue:[
-        windowGroup focusView:nil.
-        masterGroup := windowGroup previousGroup.
+	windowGroup focusView:nil.
+	masterGroup := windowGroup previousGroup.
     ].
 
     exclusiveKeyboard ifTrue:[
-        self forceUngrabKeyboard
+	self forceUngrabKeyboard
     ].
 
     self unmap.
 
     masterGroup notNil ifTrue:[
-        "
-         this is a kludge for IRIS and others which do not provide backingstore:
-         when we hide a modalbox (such as a searchbox) which covered
-         a scrollbar, the scrollbars bitblt-method will copy from the
-         not-yet redrawn area - effectively clearing the scroller.
-         We need a short delay here, since at this time, the expose event has
-         not yet arrived.
-        "
-        device sync.     "/ thats a round trip, to ensure that all expose events are present..."
-        Delay waitForSeconds:0.05.
-        masterGroup processExposeEvents   
+	"
+	 this is a kludge for IRIS and others which do not provide backingstore:
+	 when we hide a modalbox (such as a searchbox) which covered
+	 a scrollbar, the scrollbars bitblt-method will copy from the
+	 not-yet redrawn area - effectively clearing the scroller.
+	 We need a short delay here, since at this time, the expose event has
+	 not yet arrived.
+	"
+	device sync.     "/ thats a round trip, to ensure that all expose events are present..."
+	Delay waitForSeconds:0.05.
+	masterGroup processExposeEvents
     ].
 
     "Modified: 3.5.1996 / 23:47:57 / stefan"
@@ -629,8 +629,8 @@
      if I am a super-modal box, take the keyboard
     "
     exclusiveKeyboard ifTrue:[
-        self forceUngrabKeyboard.
-        self grabKeyboard.
+	self forceUngrabKeyboard.
+	self grabKeyboard.
     ].
 "/
 "/"/    UseTransientViews ifFalse:[
@@ -646,7 +646,7 @@
     "default for modalboxes is to come up modal at the pointer position"
 
     ForceModalBoxesToOpenAtCenter == true ifTrue:[
-        ^ self showAtCenter
+	^ self showAtCenter
     ].
     ^ self showAtPointer
 !
@@ -781,30 +781,42 @@
      return that offset (usually redefined, since we dont know here,
      which button should be under cursor)."
 
-    |first positionOffset pos|
+    |first pointerPosition positionOffset pos monitorBounds alignedPos|
+
+"/ ****** MULTI SCREEN
+
+    pointerPosition := device pointerPosition.
+    monitorBounds := device monitorBoundsAt:pointerPosition.
 
     self fixSize.
     positionOffset := self positionOffset.
-    pos := device pointerPosition - positionOffset.
-    self fixPosition:pos.
+    pos := pointerPosition - positionOffset.
+
+    alignedPos := Point
+	x:(pos x max:monitorBounds left)
+	y:(pos y max:monitorBounds top).
+
+    positionOffset := pointerPosition - alignedPos.
+
+    self fixPosition:alignedPos.
     pos := self origin.
 
-    "We have got a problem here: 
-        X11 adds some window decoration. The size of the decoration is only known
-        after the view is visible!!
+    "We have got a problem here:
+	X11 adds some window decoration. The size of the decoration is only known
+	after the view is visible!!
 
-        So there is a (hopefully) small offset from the pointer to the requested
-        position. The only way to resolve this, is to move the pointer to
-        the requested position after the view is visible"
+	So there is a (hopefully) small offset from the pointer to the requested
+	position. The only way to resolve this, is to move the pointer to
+	the requested position after the view is visible"
 
     first := true.
     self openModal:[
-        (first and:[shown]) ifTrue:[
-            self origin:pos.
-            first := false.
-            self setPointerPosition:positionOffset.
-        ].
-        true
+	(first and:[shown]) ifTrue:[
+	    self origin:pos.
+	    first := false.
+	    self setPointerPosition:positionOffset.
+	].
+	true
     ].
 
     "/ cannot use:
@@ -832,31 +844,31 @@
 
     pos := device pointerPosition - self positionOffset.
 
-    ((Rectangle origin:pos extent:self extent) 
-        intersects: (aView origin corner: aView corner)) 
+    ((Rectangle origin:pos extent:self extent)
+	intersects: (aView origin corner: aView corner))
     ifTrue:[
-        "
-         try to the right of the untouchable view
-        "
-        newX := (aView origin x + aView width).
-        newX + width > device usableWidth ifTrue:[
-            newX := device usableWidth - width
-        ].
-        pos x:newX.
+	"
+	 try to the right of the untouchable view
+	"
+	newX := (aView origin x + aView width).
+	newX + width > device usableWidth ifTrue:[
+	    newX := device usableWidth - width
+	].
+	pos x:newX.
 
 
-        ((Rectangle origin:pos extent:self extent) 
-            intersects: (aView origin corner: aView corner)) 
-        ifTrue:[
-            "
-             try to the left of the untouchable view
-            "
-            newX := aView origin x - width.
-            "
-             should look for vertical possibilities too ...
-            "
-            pos x:newX.
-        ]
+	((Rectangle origin:pos extent:self extent)
+	    intersects: (aView origin corner: aView corner))
+	ifTrue:[
+	    "
+	     try to the left of the untouchable view
+	    "
+	    newX := aView origin x - width.
+	    "
+	     should look for vertical possibilities too ...
+	    "
+	    pos x:newX.
+	]
 
     ].
     self showAt:pos
@@ -898,11 +910,11 @@
 !ModalBox class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/ModalBox.st,v 1.103 2010-10-05 15:58:14 mb Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/ModalBox.st,v 1.104 2010-10-11 09:05:37 mb Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libview/ModalBox.st,v 1.103 2010-10-05 15:58:14 mb Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/ModalBox.st,v 1.104 2010-10-11 09:05:37 mb Exp $'
 ! !
 
 ModalBox initialize!