XWorkstation.st
changeset 7983 6ceb649e90f0
parent 7976 fe794c7f2caa
child 8004 1d8a9208c16a
--- a/XWorkstation.st	Wed Mar 15 21:27:32 2017 +0100
+++ b/XWorkstation.st	Sat Mar 18 16:37:04 2017 +0100
@@ -2098,18 +2098,18 @@
 !
 
 createWindowFor:aView type:typeSymbol
-		 origin:origin
-		 extent:extent
-		 minExtent:minExt
-		 maxExtent:maxExt
-		 borderWidth:bWidth
-		 subViewOf:wsuperView
-		 style:wStyle
-		 inputOnly:winputOnly
-		 label:wlabel
-		 owner:wowner
-		 icon:wicon iconMask:wiconMask
-		 iconView:wiconView
+                 origin:origin
+                 extent:extent
+                 minExtent:minExt
+                 maxExtent:maxExt
+                 borderWidth:bWidth
+                 subViewOf:wsuperView
+                 style:wStyle
+                 inputOnly:winputOnly
+                 label:wlabel
+                 owner:wowner
+                 icon:wicon iconMask:wiconMask
+                 iconView:wiconView
 
     <context: #return>
 
@@ -2120,50 +2120,46 @@
      wiconId wiconMaskId wiconViewId windowGroupWindowId|
 
     self isOpen ifFalse:[
-	self primitiveFailedOrClosedConnection.
-	^ nil
+        self primitiveFailedOrClosedConnection.
+        ^ nil
     ].
 
     origin notNil ifTrue:[
-	xpos := origin x.
-	ypos := origin y.
-    ] ifFalse:[
-	xpos := ypos := 0.
+        xpos := origin x.
+        ypos := origin y.
     ].
     extent notNil ifTrue:[
-	wwidth := extent x.
-	wheight := extent y.
-    ] ifFalse:[
-	wwidth := wheight := 100.
+        wwidth := extent x.
+        wheight := extent y.
     ].
     minExt notNil ifTrue:[
-	minWidth := minExt x.
-	minHeight := minExt y
+        minWidth := minExt x.
+        minHeight := minExt y
     ].
     maxExt notNil ifTrue:[
-	maxWidth := maxExt x.
-	maxHeight := maxExt y
+        maxWidth := maxExt x.
+        maxHeight := maxExt y
     ].
 
     wsuperView notNil ifTrue:[
-	wsuperViewId := wsuperView id
+        wsuperViewId := wsuperView id
     ] ifFalse:[
-	isTopWindow := true.
-	aView class ~~ WindowGroupWindow ifTrue:[
-	    windowGroupWindow isNil ifTrue:[
-		self getWindowGroupWindow.
-	    ].
-	    windowGroupWindowId := windowGroupWindow id.
-	].
-	wicon notNil ifTrue:[
-	    wiconId := wicon id.
-	    wiconMask notNil ifTrue:[
-		wiconMaskId := wiconMask id
-	    ]
-	].
-	wiconView notNil ifTrue:[
-	    wiconViewId := wiconView id
-	].
+        isTopWindow := true.
+        aView class ~~ WindowGroupWindow ifTrue:[
+            windowGroupWindow isNil ifTrue:[
+                self getWindowGroupWindow.
+            ].
+            windowGroupWindowId := windowGroupWindow id.
+        ].
+        wicon notNil ifTrue:[
+            wiconId := wicon id.
+            wiconMask notNil ifTrue:[
+                wiconMaskId := wiconMask id
+            ]
+        ].
+        wiconView notNil ifTrue:[
+            wiconViewId := wiconView id
+        ].
     ].
 
     weventMask := aView eventMask.
@@ -2197,122 +2193,122 @@
     sizehints.y = 0;
 
     if (__bothSmallInteger(wwidth, wheight)) {
-	sizehints.flags |= PSize;
-	sizehints.width = __intVal(wwidth);
-	sizehints.height = __intVal(wheight);
+        sizehints.flags |= PSize;
+        sizehints.width = __intVal(wwidth);
+        sizehints.height = __intVal(wheight);
     }
     if (__bothSmallInteger(xpos, ypos)) {
-	sizehints.flags |= PPosition;
-	sizehints.x = __intVal(xpos);
-	sizehints.y = __intVal(ypos);
+        sizehints.flags |= PPosition;
+        sizehints.x = __intVal(xpos);
+        sizehints.y = __intVal(ypos);
     }
     if (__bothSmallInteger(minWidth, minHeight)) {
-	sizehints.flags |= PMinSize;
-	sizehints.min_width = __intVal(minWidth);
-	sizehints.min_height = __intVal(minHeight);
+        sizehints.flags |= PMinSize;
+        sizehints.min_width = __intVal(minWidth);
+        sizehints.min_height = __intVal(minHeight);
     }
     if (__bothSmallInteger(maxWidth, maxHeight)) {
-	sizehints.flags |= PMaxSize;
-	sizehints.max_width = __intVal(maxWidth);
-	sizehints.max_height = __intVal(maxHeight);
+        sizehints.flags |= PMaxSize;
+        sizehints.max_width = __intVal(maxWidth);
+        sizehints.max_height = __intVal(maxHeight);
     }
 
     bg = WhitePixel(dpy, screen);
 
     if (__isSmallInteger(bWidth)) {
-	bw = __intVal(bWidth);
+        bw = __intVal(bWidth);
     } else {
-	bw = 0;
+        bw = 0;
     }
 
     bd = BlackPixel(dpy, screen);
 
     if (__isExternalAddress(wsuperViewId)) {
-	parentWindow = __WindowVal(wsuperViewId);
+        parentWindow = __WindowVal(wsuperViewId);
     } else {
-	parentWindow = RootWindow(dpy, screen);
+        parentWindow = RootWindow(dpy, screen);
     }
 
     if (wStyle == @symbol(popUp))
-	xswa.override_redirect = 1;
+        xswa.override_redirect = 1;
     else
-	xswa.override_redirect = 0;
+        xswa.override_redirect = 0;
 
     if (winputOnly == true)
-	ioClass = InputOnly;
+        ioClass = InputOnly;
     else
-	ioClass = InputOutput;
+        ioClass = InputOutput;
 
     if (__isSmallInteger(weventMask)) {
-	xswa.event_mask = __intVal(weventMask);
+        xswa.event_mask = __intVal(weventMask);
     } else {
-	xswa.event_mask = 0;
+        xswa.event_mask = 0;
     }
 
     if (ioClass == InputOnly) {
-	bw = 0;
-	depth = 0;
-	flags |= CWEventMask;
+        bw = 0;
+        depth = 0;
+        flags |= CWEventMask;
     } else {
-	depth = DefaultDepth(dpy,screen);
-	flags |= CWEventMask | CWBorderPixel | CWOverrideRedirect;
-
-	if (backPixmap != (Pixmap)0) {
-	    xswa.background_pixmap = backPixmap;
-	    flags |= CWBackPixmap;
-	} else {
-	    xswa.background_pixel = bg;
-	    flags |= CWBackPixel;
-	}
-	xswa.border_pixel = bd;
+        depth = DefaultDepth(dpy,screen);
+        flags |= CWEventMask | CWBorderPixel | CWOverrideRedirect;
+
+        if (backPixmap != (Pixmap)0) {
+            xswa.background_pixmap = backPixmap;
+            flags |= CWBackPixmap;
+        } else {
+            xswa.background_pixel = bg;
+            flags |= CWBackPixel;
+        }
+        xswa.border_pixel = bd;
     }
 
     visual.visualid = CopyFromParent;
     if (__isSmallInteger(preferredDepth)) {
-	depth = __intVal(preferredDepth);
+        depth = __intVal(preferredDepth);
     }
 
 
     if (preferredVisual != nil) {
-	XVisualInfo vi;
-	int cls;
-
-	if (preferredVisual == @symbol(StaticGray))
-	    cls = StaticGray;
-	else if (preferredVisual == @symbol(GrayScale))
-	    cls = GrayScale;
-	else if (preferredVisual == @symbol(StaticColor))
-	    cls = StaticColor;
-	else if (preferredVisual == @symbol(PseudoColor))
-	    cls = PseudoColor;
-	else if (preferredVisual == @symbol(TrueColor))
-	    cls = TrueColor;
-	else if (preferredVisual == @symbol(DirectColor))
-	    cls = DirectColor;
-	else
-	    cls = PseudoColor;
-
-	ENTER_XLIB();
-	if (XMatchVisualInfo(dpy, screen, depth, cls, &vi)) {
-	    visual.visualid = vi.visualid;
+        XVisualInfo vi;
+        int cls;
+
+        if (preferredVisual == @symbol(StaticGray))
+            cls = StaticGray;
+        else if (preferredVisual == @symbol(GrayScale))
+            cls = GrayScale;
+        else if (preferredVisual == @symbol(StaticColor))
+            cls = StaticColor;
+        else if (preferredVisual == @symbol(PseudoColor))
+            cls = PseudoColor;
+        else if (preferredVisual == @symbol(TrueColor))
+            cls = TrueColor;
+        else if (preferredVisual == @symbol(DirectColor))
+            cls = DirectColor;
+        else
+            cls = PseudoColor;
+
+        ENTER_XLIB();
+        if (XMatchVisualInfo(dpy, screen, depth, cls, &vi)) {
+            visual.visualid = vi.visualid;
 /*
-	    console_fprintf(stderr, "visualId=%x\n", vi.visualid);
+            console_fprintf(stderr, "visualId=%x\n", vi.visualid);
 */
-	}
-	LEAVE_XLIB();
+        }
+        LEAVE_XLIB();
     }
 
     ENTER_XLIB2();
     newWindow = XCreateWindow(dpy, parentWindow,
-			   sizehints.x, sizehints.y,
-			   sizehints.width, sizehints.height,
-			   bw, depth, ioClass, &visual,
-			   flags, &xswa);
+                           sizehints.x, sizehints.y,
+                           sizehints.width, sizehints.height,
+                           bw, depth, ioClass, &visual,
+                           flags, &xswa);
     LEAVE_XLIB();
 
 
     if (! newWindow) {
-	RETURN ( nil );
+        RETURN ( nil );
     }
 
 #ifdef COUNT_RESOURCES
@@ -2324,168 +2320,168 @@
      * (only makes sense for topWindows)
      */
     if (isTopWindow == true) {
-	XWMHints wmhints;
-
-	wmhints.flags = 0;
-
-	if (__isExternalAddress(wiconId)) {
-	    wmhints.icon_pixmap = __PixmapVal(wiconId);
-	    wmhints.flags = IconPixmapHint;
-	    if (__isExternalAddress(wiconMaskId)) {
-		wmhints.icon_mask = __PixmapVal(wiconMaskId);
-		wmhints.flags |= IconMaskHint;
-	    }
-	}
-
-	if (__isExternalAddress(windowGroupWindowId)) {
-	    wmhints.window_group = __WindowVal(windowGroupWindowId);
-	    wmhints.flags |= WindowGroupHint;
-	}
-
-	if (__isExternalAddress(wiconViewId)) {
-	    wmhints.flags |= IconWindowHint;
-	    wmhints.icon_window = __WindowVal(wiconViewId);
-	};
+        XWMHints wmhints;
+
+        wmhints.flags = 0;
+
+        if (__isExternalAddress(wiconId)) {
+            wmhints.icon_pixmap = __PixmapVal(wiconId);
+            wmhints.flags = IconPixmapHint;
+            if (__isExternalAddress(wiconMaskId)) {
+                wmhints.icon_mask = __PixmapVal(wiconMaskId);
+                wmhints.flags |= IconMaskHint;
+            }
+        }
+
+        if (__isExternalAddress(windowGroupWindowId)) {
+            wmhints.window_group = __WindowVal(windowGroupWindowId);
+            wmhints.flags |= WindowGroupHint;
+        }
+
+        if (__isExternalAddress(wiconViewId)) {
+            wmhints.flags |= IconWindowHint;
+            wmhints.icon_window = __WindowVal(wiconViewId);
+        };
 
 /*
-	wmhints.flags |= InputHint;
-	wmhints.input = True;
+        wmhints.flags |= InputHint;
+        wmhints.input = True;
 */
-	ENTER_XLIB();
-	XSetWMHints(dpy, newWindow, &wmhints);
-	XSetWMNormalHints(dpy, newWindow, &sizehints);
-	LEAVE_XLIB();
-
-	/*
-	 * get atoms first (if not already known)
-	 */
-	if (__INST(protocolsAtom) == nil) {
-	    ENTER_XLIB();
-	    WmProtocolsAtom = XInternAtom(dpy, "WM_PROTOCOLS", False);
-	    __INST(protocolsAtom) = __MKATOMOBJ(WmProtocolsAtom);
+        ENTER_XLIB();
+        XSetWMHints(dpy, newWindow, &wmhints);
+        XSetWMNormalHints(dpy, newWindow, &sizehints);
+        LEAVE_XLIB();
+
+        /*
+         * get atoms first (if not already known)
+         */
+        if (__INST(protocolsAtom) == nil) {
+            ENTER_XLIB();
+            WmProtocolsAtom = XInternAtom(dpy, "WM_PROTOCOLS", False);
+            __INST(protocolsAtom) = __MKATOMOBJ(WmProtocolsAtom);
 #ifdef USE_SAVEYOURSELF_ATOM
-	    WmSaveYourselfAtom = XInternAtom(dpy, "WM_SAVE_YOURSELF", False);
-	    __INST(saveYourselfAtom) = __MKATOMOBJ(WmSaveYourselfAtom);
+            WmSaveYourselfAtom = XInternAtom(dpy, "WM_SAVE_YOURSELF", False);
+            __INST(saveYourselfAtom) = __MKATOMOBJ(WmSaveYourselfAtom);
 #endif
 #ifdef USE_QUIT_APP_ATOM
-	    WmQuitAppAtom = XInternAtom(dpy, "_WM_QUIT_APP", False);
-	    __INST(quitAppAtom) = __MKATOMOBJ(WmQuitAppAtom);
-#endif
-	    WmDeleteWindowAtom = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
-	    __INST(deleteWindowAtom) = __MKATOMOBJ(WmDeleteWindowAtom);
-
-	    UUIDAtom = XInternAtom(dpy, "UUID", False);
-	    __INST(uuidAtom) = __MKATOMOBJ(UUIDAtom);
-	    STXDeviceAtom = XInternAtom(dpy, "STX_DEVICE_ID", False);
-	    __INST(stxDeviceAtom) = __MKATOMOBJ(STXDeviceAtom);
-
-	    LEAVE_XLIB();
-	} else {
+            WmQuitAppAtom = XInternAtom(dpy, "_WM_QUIT_APP", False);
+            __INST(quitAppAtom) = __MKATOMOBJ(WmQuitAppAtom);
+#endif
+            WmDeleteWindowAtom = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
+            __INST(deleteWindowAtom) = __MKATOMOBJ(WmDeleteWindowAtom);
+
+            UUIDAtom = XInternAtom(dpy, "UUID", False);
+            __INST(uuidAtom) = __MKATOMOBJ(UUIDAtom);
+            STXDeviceAtom = XInternAtom(dpy, "STX_DEVICE_ID", False);
+            __INST(stxDeviceAtom) = __MKATOMOBJ(STXDeviceAtom);
+
+            LEAVE_XLIB();
+        } else {
 #ifdef USE_QUIT_APP_ATOM
-	    WmQuitAppAtom = __AtomVal(__INST(quitAppAtom));
+            WmQuitAppAtom = __AtomVal(__INST(quitAppAtom));
 #else
-	    WmQuitAppAtom = 0;
-#endif
-	    WmProtocolsAtom = __AtomVal(__INST(protocolsAtom));
-	    WmDeleteWindowAtom = __AtomVal(__INST(deleteWindowAtom));
+            WmQuitAppAtom = 0;
+#endif
+            WmProtocolsAtom = __AtomVal(__INST(protocolsAtom));
+            WmDeleteWindowAtom = __AtomVal(__INST(deleteWindowAtom));
 #ifdef USE_SAVEYOURSELF_ATOM
-	    WmSaveYourselfAtom = __AtomVal(__INST(saveYourselfAtom));
+            WmSaveYourselfAtom = __AtomVal(__INST(saveYourselfAtom));
 #else
-	    WmSaveYourselfAtom = 0;
-#endif
-	    UUIDAtom = __AtomVal(__INST(uuidAtom));;
-	    STXDeviceAtom = __AtomVal(__INST(stxDeviceAtom));;
-	}
-
-	/*
-	 * tell window manager to not kill us but send an event instead
-	 */
-	atoms[0] = WmDeleteWindowAtom; atomCount++;
+            WmSaveYourselfAtom = 0;
+#endif
+            UUIDAtom = __AtomVal(__INST(uuidAtom));;
+            STXDeviceAtom = __AtomVal(__INST(stxDeviceAtom));;
+        }
+
+        /*
+         * tell window manager to not kill us but send an event instead
+         */
+        atoms[0] = WmDeleteWindowAtom; atomCount++;
 #ifdef USE_SAVEYOURSELF_ATOM
-	atoms[atomCount] = WmSaveYourselfAtom; atomCount++;
+        atoms[atomCount] = WmSaveYourselfAtom; atomCount++;
 #endif
 #ifdef USE_QUIT_APP_ATOM
-	atoms[atomCount] = WmQuitAppAtom; atomCount++;
-#endif
-	ENTER_XLIB();
-	XChangeProperty(dpy, newWindow, WmProtocolsAtom, XA_ATOM,
-			32, PropModeReplace, (unsigned char *)atoms, atomCount);
-	LEAVE_XLIB();
-
-	/*
-	 * an optional unique id (to mark stx-windows)
-	 */
-	if (__isBytes(__INST(uniqueDeviceID))) {
-	    int numUUIDBytes = __byteArraySize(__INST(uniqueDeviceID));
-	    unsigned char uuidBytes[32];
-
-	    if (numUUIDBytes <= sizeof(uuidBytes)) {
-		Atom uuidAtom;
-
-		bcopy(__byteArrayVal(__INST(uniqueDeviceID)), uuidBytes, numUUIDBytes);
-
-		ENTER_XLIB();
-		XChangeProperty (dpy, newWindow, STXDeviceAtom, UUIDAtom, 8, PropModeReplace,
-				 uuidBytes, numUUIDBytes );
-		LEAVE_XLIB();
-	    }
-	}
+        atoms[atomCount] = WmQuitAppAtom; atomCount++;
+#endif
+        ENTER_XLIB();
+        XChangeProperty(dpy, newWindow, WmProtocolsAtom, XA_ATOM,
+                        32, PropModeReplace, (unsigned char *)atoms, atomCount);
+        LEAVE_XLIB();
+
+        /*
+         * an optional unique id (to mark stx-windows)
+         */
+        if (__isBytes(__INST(uniqueDeviceID))) {
+            int numUUIDBytes = __byteArraySize(__INST(uniqueDeviceID));
+            unsigned char uuidBytes[32];
+
+            if (numUUIDBytes <= sizeof(uuidBytes)) {
+                Atom uuidAtom;
+
+                bcopy(__byteArrayVal(__INST(uniqueDeviceID)), uuidBytes, numUUIDBytes);
+
+                ENTER_XLIB();
+                XChangeProperty (dpy, newWindow, STXDeviceAtom, UUIDAtom, 8, PropModeReplace,
+                                 uuidBytes, numUUIDBytes );
+                LEAVE_XLIB();
+            }
+        }
 
 #ifdef SUPPORT_MOTIF_WM_HINTS
-	/*
-	 * less decoration
-	 */
-	if ((wStyle == @symbol(undecorated))
-	 || (wStyle == @symbol(dialog2))
-	 || (wStyle == @symbol(notitle))
-	) {
-	    if (__INST(motifWMHintsAtom) == nil) {
-		ENTER_XLIB();
-		MotifWMHintsAtom = XInternAtom(dpy, "_MOTIF_WM_HINTS", False);
-		__INST(motifWMHintsAtom) = __MKATOMOBJ(MotifWMHintsAtom);
-		LEAVE_XLIB();
-	    } else {
-		MotifWMHintsAtom = __AtomVal(__INST(motifWMHintsAtom));
-	    }
-
-	    {
-		struct hints {
-		    unsigned long flags;
-		    unsigned long functions;
-		    unsigned long decorations;
-		    long input_mode;
-		    unsigned long status;
-		} mvm_hints;
-
-		if (wStyle == @symbol(undecorated)) {
-		    mvm_hints.decorations = MWM_DECOR_NONE;
-		}
-		if (wStyle == @symbol(dialog2)) {
-		    mvm_hints.decorations = MWM_DECOR_BORDER
-					    | MWM_DECOR_RESIZEH
-					    | MWM_DECOR_TITLE
-					    /* | MWM_DECOR_MENU */
-					    /* | MWM_DECOR_MINIMIZE */
-					    /* | MWM_DECOR_MAXIMIZE */
-					    ;
-		}
-		if (wStyle == @symbol(notitle)) {
-		    mvm_hints.decorations = MWM_DECOR_BORDER
-					    /* | MWM_DECOR_RESIZEH  */
-					    /* | MWM_DECOR_TITLE    */
-					    /* | MWM_DECOR_MENU     */
-					    /* | MWM_DECOR_MINIMIZE */
-					    /* | MWM_DECOR_MAXIMIZE */
-					    ;
-		}
-		mvm_hints.flags =  MWM_HINTS_DECORATIONS;
-		ENTER_XLIB();
-		XChangeProperty (dpy, newWindow, MotifWMHintsAtom,
-				     MotifWMHintsAtom, 32, PropModeReplace,
-				     (unsigned char*)&mvm_hints, 5 );
-		LEAVE_XLIB();
-	    }
-	}
+        /*
+         * less decoration
+         */
+        if ((wStyle == @symbol(undecorated))
+         || (wStyle == @symbol(dialog2))
+         || (wStyle == @symbol(notitle))
+        ) {
+            if (__INST(motifWMHintsAtom) == nil) {
+                ENTER_XLIB();
+                MotifWMHintsAtom = XInternAtom(dpy, "_MOTIF_WM_HINTS", False);
+                __INST(motifWMHintsAtom) = __MKATOMOBJ(MotifWMHintsAtom);
+                LEAVE_XLIB();
+            } else {
+                MotifWMHintsAtom = __AtomVal(__INST(motifWMHintsAtom));
+            }
+
+            {
+                struct hints {
+                    unsigned long flags;
+                    unsigned long functions;
+                    unsigned long decorations;
+                    long input_mode;
+                    unsigned long status;
+                } mvm_hints;
+
+                if (wStyle == @symbol(undecorated)) {
+                    mvm_hints.decorations = MWM_DECOR_NONE;
+                }
+                if (wStyle == @symbol(dialog2)) {
+                    mvm_hints.decorations = MWM_DECOR_BORDER
+                                            | MWM_DECOR_RESIZEH
+                                            | MWM_DECOR_TITLE
+                                            /* | MWM_DECOR_MENU */
+                                            /* | MWM_DECOR_MINIMIZE */
+                                            /* | MWM_DECOR_MAXIMIZE */
+                                            ;
+                }
+                if (wStyle == @symbol(notitle)) {
+                    mvm_hints.decorations = MWM_DECOR_BORDER
+                                            /* | MWM_DECOR_RESIZEH  */
+                                            /* | MWM_DECOR_TITLE    */
+                                            /* | MWM_DECOR_MENU     */
+                                            /* | MWM_DECOR_MINIMIZE */
+                                            /* | MWM_DECOR_MAXIMIZE */
+                                            ;
+                }
+                mvm_hints.flags =  MWM_HINTS_DECORATIONS;
+                ENTER_XLIB();
+                XChangeProperty (dpy, newWindow, MotifWMHintsAtom,
+                                     MotifWMHintsAtom, 32, PropModeReplace,
+                                     (unsigned char*)&mvm_hints, 5 );
+                LEAVE_XLIB();
+            }
+        }
 #endif /* SUPPORT_MOTIF_WM_HINTS */
     }
 
@@ -2498,15 +2494,16 @@
 
     (wsuperView isNil "this is a topwindow"
      and:[wlabel notEmptyOrNil]) ifTrue:[
-	self
-	    setIconName:wlabel in:windowId;
-	    setWindowName:wlabel in:windowId.
+        self
+            setIconName:wlabel in:windowId;
+            setWindowName:wlabel in:windowId.
     ].
 
     self addKnownView:aView withId:windowId.
     ^ windowId
 
     "Modified: / 09-01-2013 / 10:43:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 18-03-2017 / 00:00:44 / stefan"
 !
 
 destroyGC:aGCId