--- a/XWorkstation.st Wed Apr 25 14:34:13 2018 +0200
+++ b/XWorkstation.st Thu Apr 26 11:14:51 2018 +0200
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
"
COPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
@@ -2102,18 +2104,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>
@@ -2124,46 +2126,46 @@
wiconId wiconMaskId wiconViewId windowGroupWindowId|
self isOpen ifFalse:[
- self primitiveFailedOrClosedConnection.
- ^ nil
+ self primitiveFailedOrClosedConnection.
+ ^ nil
].
origin notNil ifTrue:[
- xpos := origin x.
- ypos := origin y.
+ xpos := origin x.
+ ypos := origin y.
].
extent notNil ifTrue:[
- wwidth := extent x.
- wheight := extent y.
+ 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 drawableId.
] 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 drawableId.
+ ].
+ wicon notNil ifTrue:[
+ wiconId := wicon drawableId.
+ wiconMask notNil ifTrue:[
+ wiconMaskId := wiconMask drawableId.
+ ]
+ ].
+ wiconView notNil ifTrue:[
+ wiconViewId := wiconView drawableId.
+ ].
].
weventMask := aView eventMask.
@@ -2197,122 +2199,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 +2326,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,16 +2500,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"
+ "Modified: / 26-04-2018 / 11:02:09 / stefan"
!
destroyGC:aGCId
@@ -2815,17 +2817,18 @@
s := aString ? ''.
s isString ifFalse:[
- s := s asStringWithCRsFrom:1 to:(s size) compressTabs:false withCR:false
- ].
-
- viewID := aView id.
+ s := s asStringWithCRsFrom:1 to:(s size) compressTabs:false withCR:false
+ ].
+
+ viewID := aView drawableId.
viewID notNil ifTrue:[ "/ if the view is not already closed
- "/ for now - should add support to pass emphasis information too
- s := s string.
- self setPrimaryText:s owner:viewID.
+ "/ for now - should add support to pass emphasis information too
+ s := s string.
+ self setPrimaryText:s owner:viewID.
]
"Created: / 27-03-2012 / 14:46:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 26-04-2018 / 11:00:43 / stefan"
! !
!XWorkstation methodsFor:'color stuff'!
@@ -3300,10 +3303,12 @@
"create a cursor given 2 bitmaps (source, mask) and a hotspot"
^ self
- primCreateCursorSourceFormId:sourceForm id
- maskFormId:maskForm id
- hotX:hx hotY:hy
- width:w height:h
+ primCreateCursorSourceFormId:sourceForm drawableId
+ maskFormId:maskForm drawableId
+ hotX:hx hotY:hy
+ width:w height:h
+
+ "Modified: / 26-04-2018 / 11:02:52 / stefan"
!
destroyCursor:aCursorId
@@ -3453,134 +3458,134 @@
(msgType := self atomIDOf:#DndProtocol) notNil ifTrue:[
- "/ DND can drop files, file, dir, links, dirLink and text
- "/ check for this.
-
- dropObjects isCollection ifFalse:[
- dropColl := Array with:dropObjects
- ] ifTrue:[
- dropColl := dropObjects
- ].
- anyFile := anyDir := anyText := anyOther := false.
- dropColl do:[:aDropObject |
- aDropObject isFileObject ifTrue:[
- aDropObject theObject isDirectory ifTrue:[
- anyDir := true
- ] ifFalse:[
- anyFile := true
- ]
- ] ifFalse:[
- aDropObject isTextObject ifTrue:[
- anyText := true
- ] ifFalse:[
- anyOther := true
- ]
- ]
- ].
-
- anyOther ifTrue:[
- "/ DND does not support this ...
- Logger info:'DND can only drop files or text'.
- ^ false
- ].
- anyText ifTrue:[
- (anyFile or:[anyDir]) ifTrue:[
- "/ DND does not support mixed types
- Logger info:'DND cannot drop both files and text'.
- ^ false
- ]
- ].
-
- dropCollSize := dropColl size.
- anyFile ifTrue:[
- dropType := #DndFiles.
- dropCollSize == 1 ifTrue:[
- dropType := #DndFile
- ]
- ] ifFalse:[
- anyDir ifTrue:[
- dropType := #DndFiles.
- dropCollSize == 1 ifTrue:[
- dropType := #DndDir
- ]
- ] ifFalse:[
- anyText ifTrue:[
- dropCollSize == 1 ifTrue:[
- dropType := #DndText
- ] ifFalse:[
- "/ can only drop a single text object
- Logger info:'DND can only drop a single text'.
- ^ false
- ]
- ] ifFalse:[
- "/ mhmh ...
- Logger info:'DND cannot drop this'.
- ^ false
- ]
- ]
- ].
-
- dropTypeCode := self dndDropTypes indexOf:dropType.
- dropTypeCode == 0 ifTrue:[
- Logger info:'DND cannot drop this'.
- ^ false
- ].
- dropTypeCode := dropTypeCode - 1.
-
-
- "/ place the selection inTo the DndSelection property
- "/ of the rootView ...
- "/ ... need a single string, with 0-terminated parts.
-
- strings := OrderedCollection new.
- sz := 0.
- dropColl do:[:anObject |
- |s o|
-
- o := anObject theObject.
- anObject isFileObject ifTrue:[
- o := o pathName
- ].
- s := o asString.
- strings add:s.
- sz := sz + (s size) + 1.
- ].
- val := String new:sz.
- idx := 1.
- strings do:[:aString |
- |sz|
-
- sz := aString size.
- val replaceFrom:idx to:(idx + sz - 1) with:aString startingAt:1.
- idx := idx + sz.
- val at:idx put:(Character value:0).
- idx := idx + 1
- ].
-
- self
- setProperty:(self atomIDOf:#DndSelection)
- type:(self atomIDOf:#STRING)
- value:val
- for:rootId.
-
- ^ self
- sendClientEvent:msgType
- format:32
- to:destinationId
- propagate:true
- eventMask:nil
- window:destinationId
- data1:dropTypeCode
- data2:0
- data3:destinationId
- data4:nil
- data5:nil.
+ "/ DND can drop files, file, dir, links, dirLink and text
+ "/ check for this.
+
+ dropObjects isCollection ifFalse:[
+ dropColl := Array with:dropObjects
+ ] ifTrue:[
+ dropColl := dropObjects
+ ].
+ anyFile := anyDir := anyText := anyOther := false.
+ dropColl do:[:aDropObject |
+ aDropObject isFileObject ifTrue:[
+ aDropObject theObject isDirectory ifTrue:[
+ anyDir := true
+ ] ifFalse:[
+ anyFile := true
+ ]
+ ] ifFalse:[
+ aDropObject isTextObject ifTrue:[
+ anyText := true
+ ] ifFalse:[
+ anyOther := true
+ ]
+ ]
+ ].
+
+ anyOther ifTrue:[
+ "/ DND does not support this ...
+ Logger info:'DND can only drop files or text'.
+ ^ false
+ ].
+ anyText ifTrue:[
+ (anyFile or:[anyDir]) ifTrue:[
+ "/ DND does not support mixed types
+ Logger info:'DND cannot drop both files and text'.
+ ^ false
+ ]
+ ].
+
+ dropCollSize := dropColl size.
+ anyFile ifTrue:[
+ dropType := #DndFiles.
+ dropCollSize == 1 ifTrue:[
+ dropType := #DndFile
+ ]
+ ] ifFalse:[
+ anyDir ifTrue:[
+ dropType := #DndFiles.
+ dropCollSize == 1 ifTrue:[
+ dropType := #DndDir
+ ]
+ ] ifFalse:[
+ anyText ifTrue:[
+ dropCollSize == 1 ifTrue:[
+ dropType := #DndText
+ ] ifFalse:[
+ "/ can only drop a single text object
+ Logger info:'DND can only drop a single text'.
+ ^ false
+ ]
+ ] ifFalse:[
+ "/ mhmh ...
+ Logger info:'DND cannot drop this'.
+ ^ false
+ ]
+ ]
+ ].
+
+ dropTypeCode := self dndDropTypes indexOf:dropType.
+ dropTypeCode == 0 ifTrue:[
+ Logger info:'DND cannot drop this'.
+ ^ false
+ ].
+ dropTypeCode := dropTypeCode - 1.
+
+
+ "/ place the selection inTo the DndSelection property
+ "/ of the rootView ...
+ "/ ... need a single string, with 0-terminated parts.
+
+ strings := OrderedCollection new.
+ sz := 0.
+ dropColl do:[:anObject |
+ |s o|
+
+ o := anObject theObject.
+ anObject isFileObject ifTrue:[
+ o := o pathName
+ ].
+ s := o asString.
+ strings add:s.
+ sz := sz + (s size) + 1.
+ ].
+ val := String new:sz.
+ idx := 1.
+ strings do:[:aString |
+ |sz|
+
+ sz := aString size.
+ val replaceFrom:idx to:(idx + sz - 1) with:aString startingAt:1.
+ idx := idx + sz.
+ val at:idx put:(Character value:0).
+ idx := idx + 1
+ ].
+
+ self
+ setProperty:#DndSelection
+ type:#STRING
+ value:val
+ for:rootId.
+
+ ^ self
+ sendClientEvent:msgType
+ format:32
+ to:destinationId
+ propagate:true
+ eventMask:nil
+ window:destinationId
+ data1:dropTypeCode
+ data2:0
+ data3:destinationId
+ data4:nil
+ data5:nil.
].
^ false
- "Created: 6.4.1997 / 13:39:37 / cg"
- "Modified: 6.4.1997 / 14:30:43 / cg"
+ "Created: / 06-04-1997 / 13:39:37 / cg"
+ "Modified: / 26-04-2018 / 10:54:18 / stefan"
!
dndDropTypes
@@ -5317,7 +5322,7 @@
dndMessage:event data:data view:targetView
"handle a drag&drop protocol message"
- |sensor property dropType dropValue names i1 i2 propertyType|
+ |sensor property dropType dropValue propertyType|
dropType := data doubleWordAt:1.
@@ -5325,9 +5330,9 @@
dropType := (self dndDropTypes) at:dropType+1 ifAbsent:#DndNotDnd.
property := self
- getProperty:(self atomIDOf:#DndSelection)
- from:rootId
- delete:false.
+ getProperty:#DndSelection
+ from:rootId
+ delete:false.
propertyType := property key.
dropValue := property value.
@@ -5341,72 +5346,61 @@
"/ in the default dropMessage handling of SimpleView.
dropType == #DndFiles ifTrue:[
- "/ actually, a list of fileNames
- propertyType ~~ stringAtom ifTrue:[
- Logger info:'expected a string propertyValue in drop'.
- ^ self
- ].
-
- names := OrderedCollection new.
- i1 := 1.
- [i1 ~~ 0] whileTrue:[
- i2 := dropValue indexOf:(Character value:0) startingAt:i1.
- i2 ~~ 0 ifTrue:[
- names add:(dropValue copyFrom:i1 to:(i2-1)).
- i1 := i2 + 1.
- ] ifFalse:[
- i1 := i2
- ].
- ].
- dropValue := names.
- dropValue := dropValue collect:[:nm | nm asFilename].
- dropType := #files.
+ "/ actually, a list of fileNames
+ dropValue firstOrNil isString ifFalse:[
+ Logger info:'expected a string propertyValue in drop'.
+ ^ self
+ ].
+ dropValue := dropValue collect:[:nm | nm asFilename].
+ dropType := #files.
] ifFalse:[ (dropType == #DndFile) ifTrue:[
- propertyType ~~ stringAtom ifTrue:[
- Logger info:'expected a string propertyValue in drop'.
- ^ self
- ].
- dropValue := dropValue asFilename.
- dropType := #file.
+ dropValue isString ifFalse:[
+ Logger info:'expected a string propertyValue in drop'.
+ ^ self
+ ].
+ dropValue := dropValue asFilename.
+ dropType := #file.
] ifFalse:[ (dropType == #DndDir) ifTrue:[
- propertyType ~~ stringAtom ifTrue:[
- Logger info:'expected a string propertyValue in drop'.
- ^ self
- ].
- dropValue := dropValue asFilename.
- dropType := #directory.
+ dropValue isString ifFalse:[
+ Logger info:'expected a string propertyValue in drop'.
+ ^ self
+ ].
+ dropValue := dropValue asFilename.
+ dropType := #directory.
] ifFalse:[ (dropType == #DndText) ifTrue:[
- propertyType ~~ stringAtom ifTrue:[
- Logger info:'expected a string propertyValue in drop'.
- ^ self
- ].
- dropType := #text.
+ (dropValue isString or:[dropValue isStringCollection]) ifFalse:[
+ Logger info:'expected a string propertyValue in drop'.
+ ^ self
+ ].
+ dropValue := dropValue asString.
+ dropType := #text.
] ifFalse:[ (dropType == #DndExe) ifTrue:[
- propertyType ~~ stringAtom ifTrue:[
- Logger info:'expected a string propertyValue in drop'.
- ^ self
- ].
- dropType := #executable.
+ dropValue isString ifFalse:[
+ Logger info:'expected a string propertyValue in drop'.
+ ^ self
+ ].
+ dropType := #executable.
] ifFalse:[ (dropType == #DndLink) ifTrue:[
- propertyType ~~ stringAtom ifTrue:[
- Logger info:'expected a string propertyValue in drop'.
- ^ self
- ].
- dropType := #link.
+ dropValue isString ifFalse:[
+ Logger info:'expected a string propertyValue in drop'.
+ ^ self
+ ].
+ dropType := #link.
] ifFalse:[ (dropType == #DndRawData) ifTrue:[
- dropType := #rawData.
+ dropType := #rawData.
] ifFalse:[
- Logger info:'unsupported dropType: %1 data: %2 ' with:dropType with:dropValue.
- dropType := #unknown.
+ Logger info:'unsupported dropType: %1 data: %2 ' with:dropType with:dropValue.
+ dropType := #unknown.
]]]]]]].
sensor := targetView sensor.
"not posted, if there is no sensor ..."
sensor notNil ifTrue:[
- sensor dropMessage:dropType data:dropValue view:targetView position:nil handle:nil
- ].
-
- "Created: 4.4.1997 / 17:59:37 / cg"
+ sensor dropMessage:dropType data:dropValue view:targetView position:nil handle:nil
+ ].
+
+ "Created: / 04-04-1997 / 17:59:37 / cg"
+ "Modified (format): / 25-04-2018 / 15:12:04 / stefan"
!
expose:view x:x y:y width:w height:h count:count
@@ -5536,8 +5530,8 @@
lastEventTime := time.
aView isNil ifTrue:[
- "event arrived, after aView has been destroyed"
- ^ self
+ "event arrived, after aView has been destroyed"
+ ^ self
].
"/ 'propertyChange ' infoPrint. (self atomName:propertyId) print. ': ' print. aSymbol printCR.
@@ -5549,15 +5543,16 @@
aView sensor propertyChange:aView property:propertyId state:aSymbol time:time.
aSymbol ~~ #newValue ifTrue:[
- "I am not interested in delete notifications"
- ^ self.
- ].
- selectionFetcher := self findSelectionFetcher:aView id.
+ "I am not interested in delete notifications"
+ ^ self.
+ ].
+ selectionFetcher := self findSelectionFetcher:aView drawableId.
selectionFetcher notNil ifTrue:[
- selectionFetcher message:thisContext message.
+ selectionFetcher message:thisContext message.
].
"Modified: / 01-06-2011 / 13:40:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 26-04-2018 / 11:00:21 / stefan"
!
selectionClear:aView selection:selectionID time:time
@@ -5569,19 +5564,21 @@
lastEventTime := time.
selectionHandlers notNil ifTrue:[
- selectionHandlers do:[:eachHandler |
- eachHandler selectionClear:selectionID
- ]
+ selectionHandlers do:[:eachHandler |
+ eachHandler selectionClear:selectionID
+ ]
].
aView isNil ifTrue:[
- "event arrived, after aView has been destroyed"
- ^ self
- ].
- selectionFetcher := self findSelectionFetcher:aView id.
+ "event arrived, after aView has been destroyed"
+ ^ self
+ ].
+ selectionFetcher := self findSelectionFetcher:aView drawableId.
selectionFetcher notNil ifTrue:[
- selectionFetcher message:thisContext message.
- ].
+ selectionFetcher message:thisContext message.
+ ].
+
+ "Modified: / 26-04-2018 / 11:00:30 / stefan"
!
selectionNotify:aView selection:selectionID target:targetID property:propertyID requestor:requestorID time:time
@@ -5602,15 +5599,16 @@
lastEventTime := time.
aView isNil ifTrue:[
- "event arrived, after aView has been destroyed"
- ^ self
- ].
- selectionFetcher := self findSelectionFetcher:aView id.
+ "event arrived, after aView has been destroyed"
+ ^ self
+ ].
+ selectionFetcher := self findSelectionFetcher:aView drawableId.
selectionFetcher notNil ifTrue:[
- selectionFetcher message:thisContext message.
+ selectionFetcher message:thisContext message.
].
"Modified (format): / 14-03-2017 / 16:31:20 / cg"
+ "Modified: / 26-04-2018 / 11:00:36 / stefan"
!
selectionRequest:aView requestor:requestorID selection:selectionID target:targetID property:propertyID time:time
@@ -6601,7 +6599,9 @@
handleExposeOnlyFor:aView
"from now on, handle expose events only"
- dispatchingExpose := aView id
+ dispatchingExpose := aView drawableId.
+
+ "Modified: / 26-04-2018 / 11:01:37 / stefan"
!
registerHotKeyForWindow:aDrawableId withId:anId modifiers:aModifier virtualKeyCode:aVirtualKeyCode
@@ -7926,7 +7926,7 @@
).
Screen current
- heightOf:'hello World gggÖÜ' from:1 to:15
+ heightOf:'hello World gggÖÜ' from:1 to:15
inFont:(Screen current getDefaultFontWithEncoding:#'iso10646-1')
"
!
@@ -10632,23 +10632,75 @@
getProperty:propertySymbolOrAtomID from:aWindowOrWindowIDOrNil delete:doDelete
"get a property as an association propertyType->propertyValue"
- <context: #return>
-
- |val typeID propertyID windowID isUtf8 utf8StringAtom|
-
- isUtf8 := false.
+ |val propertyAtomID association windowIDOrNil|
+
propertySymbolOrAtomID isString ifTrue:[
- propertyID := self atomIDOf:propertySymbolOrAtomID create:false.
- propertyID isNil ifTrue:[^ nil].
+ propertyAtomID := self atomIDOf:propertySymbolOrAtomID create:false.
+ propertyAtomID isNil ifTrue:[^ nil].
] ifFalse:[
- propertyID := propertySymbolOrAtomID.
+ propertyAtomID := propertySymbolOrAtomID.
].
aWindowOrWindowIDOrNil isView ifTrue:[
- windowID := aWindowOrWindowIDOrNil id.
+ windowIDOrNil := aWindowOrWindowIDOrNil drawableId.
] ifFalse:[
- windowID := aWindowOrWindowIDOrNil.
- ].
- utf8StringAtom := self atomIDOf:#'UTF8_STRING' create:true.
+ windowIDOrNil := aWindowOrWindowIDOrNil.
+ ].
+
+ association := self primGetProperty:propertyAtomID from:windowIDOrNil delete:doDelete.
+ association isNil ifTrue:[
+ "The property does not exist in the specified window"
+ ^ nil
+ ].
+ val := association value.
+ (val isByteArray and:[association key = (self atomIDOf:#'UTF8_STRING' create:true)]) ifTrue:[
+ val := val utf8Decoded.
+ ].
+ (val isString and:[val includes:(Character codePoint:0)]) ifTrue:[
+ val := val asCollectionOfSubCollectionsSeparatedBy:(Character codePoint:0).
+ ].
+ association value:val.
+ ^ association
+
+ "
+ Display
+ getProperty:#'_NET_DESKTOP_NAMES'
+ from:nil
+ delete:false
+
+ Display
+ getProperty:#'_NET_CURRENT_DESKTOP'
+ from:nil
+ delete:false
+
+ Display
+ getProperty:#'_NET_WM_ALLOWED_ACTIONS'
+ from:Transcript
+ delete:false
+
+ Display
+ getProperty:#'_NET_SUPPORTED'
+ from:nil
+ delete:false
+
+ Transcript showCR:(
+ (Display
+ getProperty:#'_NET_SUPPORTED'
+ from:nil
+ delete:false) value
+ collect:[:eachID | Display atomName:eachID])
+
+ "
+
+ "Modified: / 31-08-2017 / 22:01:44 / cg"
+ "Modified: / 26-04-2018 / 10:58:21 / stefan"
+!
+
+primGetProperty:propertyAtomID from:aWindowIDOrNil delete:doDelete
+ "get a property as an association propertyType->propertyValue"
+
+ <context: #return>
+
+ |val typeID|
%{ /* UNLIMITEDSTACK */
#define PROPERTY_DEBUG
@@ -10664,12 +10716,12 @@
if (ISCONNECTED) {
Display *dpy = myDpy;
- if (__isAtomID(propertyID)) {
- property = __AtomVal(propertyID);
-
- if (__isExternalAddress(windowID)) {
- window = __WindowVal(windowID);
- } else if (windowID == nil) {
+ if (__isAtomID(propertyAtomID)) {
+ property = __AtomVal(propertyAtomID);
+
+ if (__isExternalAddress(aWindowIDOrNil)) {
+ window = __WindowVal(aWindowIDOrNil);
+ } else if (aWindowIDOrNil == nil) {
window = DefaultRootWindow(dpy);
} else
goto fail;
@@ -10699,7 +10751,12 @@
#ifdef PROPERTY_DEBUG
console_fprintf(stderr, "- type:%x format:%d nitems:%d bytes_after:%d\n", actual_type, actual_format, nitems, bytes_after);
#endif
+ if (actual_type == None) {
+ // The property does not exist in the specified window
+ break;
+ }
typeID = __MKATOMOBJ(actual_type);
+
nReturnedBytes = nitems * (actual_format == 32 ? sizeof(long) : actual_format / 8);
if (! cp) {
cp = cp2 = (char *)malloc(nReturnedBytes+bytes_after);
@@ -10732,163 +10789,26 @@
if (actual_type == XA_STRING) {
val = __MKSTRING_L(cp, nread);
} else {
- if (actual_type == __intVal(utf8StringAtom))
- isUtf8 = true;
val = __MKBYTEARRAY(cp, nread);
}
break;
}
+ if (cp) free(cp);
+ goto done;
}
- if (cp)
- free(cp);
}
}
-fail: ;
-%}.
- (typeID isNil or:[typeID == 0]) ifTrue:[
- "typeID == 0 (None): The property does not exist in the specified window"
- ^ nil
- ].
- isUtf8 ifTrue:[
- val := val utf8Decoded.
- ].
- (val isString and:[val includes:(Character codePoint:0)]) ifTrue:[
- val := val asCollectionOfSubCollectionsSeparatedBy:(Character codePoint:0).
- ].
+fail:
+ if (cp) free(cp);
+ RETURN(nil);
+done:;
+%}.
^ typeID->val
- "
- Display
- getProperty:#'_NET_DESKTOP_NAMES'
- from:nil
- delete:false
-
- Display
- getProperty:#'_NET_CURRENT_DESKTOP'
- from:nil
- delete:false
-
- Display
- getProperty:#'_NET_SUPPORTED'
- from:nil
- delete:false
-
- Transcript showCR:(
- (Display
- getProperty:#'_NET_SUPPORTED'
- from:nil
- delete:false) value
- collect:[:eachID | Display atomName:eachID])
-
- "
-
- "Modified: / 31-08-2017 / 22:01:44 / cg"
- "Modified (comment): / 25-04-2018 / 14:33:26 / stefan"
-!
-
-propertiesOf:aWindowOrWindowIDOrNil
- "return a collection of all properties' atomIDs of a window.
- Returns the rootWindows props for a nil window argument."
-
- <context: #return>
-
- |windowID atoms|
-
- aWindowOrWindowIDOrNil isView ifTrue:[
- windowID := aWindowOrWindowIDOrNil id.
- ] ifFalse:[
- windowID := aWindowOrWindowIDOrNil.
- ].
-
-%{
- Window window;
- Atom *atomListPtr;
- int i;
-
- if (ISCONNECTED) {
- Display *dpy = myDpy;
- int numProps = 0;
-
- if (__isExternalAddress(windowID)) {
- window = __WindowVal(windowID);
- } else if (windowID == nil) {
- window = DefaultRootWindow(dpy);
- } else if (__isInteger(windowID)) {
- window = (Window)__unsignedLongIntVal(windowID);
- } else {
- goto fail;
- }
-
- ENTER_XLIB();
- atomListPtr = XListProperties(dpy, window, &numProps);
- LEAVE_XLIB();
-
- if (atomListPtr == NULL) {
- RETURN (nil);
- }
-
- atoms = __ARRAY_NEW_INT(numProps);
-
- if (atoms == nil) {
- goto fail;
- }
-
- for (i=0; i<numProps; i++) {
- OBJ atm;
-
- atm = __MKATOMOBJ(atomListPtr[i]);
- __ArrayInstPtr(atoms)->a_element[i] = atm; __STORE(atoms, atm);
- }
- XFree(atomListPtr);
- RETURN (atoms);
- }
-fail: ;
-%}.
- ^ self primitiveFailed
-
- "
- Display propertiesOf:nil
- Display propertiesOf:Transcript view id
- "
- "
- (Display propertiesOf:nil) do:[:atm |
- |v prop|
-
- Transcript show:((Display atomName:atm) printStringLeftPaddedTo:5).
- Transcript show:': '.
- prop := Display getProperty:atm from:nil delete:false.
- Transcript showCR:prop value.
- ]
- "
-!
-
-setIcon:anIcon for:aWindowID
- |iconAtom typeAtom buffer iWidth iHeight|
-
- iconAtom := self atomIDOf:#'_NET_WM_ICON' create:false.
- iconAtom isNil ifTrue:[
- "/Hmm, no such property, not running under EWMH compliant WM?
- ^ self
- ].
- typeAtom := self atomIDOf:#'CARDINAL' create:false.
- typeAtom isNil ifTrue:[
- "/Hmm, no such property, not running under EWMH compliant WM?
- ^ self
- ].
- iWidth := anIcon width.
- iHeight := anIcon height.
- buffer := IntegerArray new:(iWidth*iHeight+2).
- buffer at:1 put:iWidth.
- buffer at:2 put:iHeight.
-
- self setProperty:iconAtom type:typeAtom value:buffer for:aWindowID
-
- "
- Display setIcon:0 for:0
- "
-!
-
-setProperty:propertyID type:typeID value:anObject for:aWindowID
+ "Created: / 25-04-2018 / 16:41:52 / stefan"
+!
+
+primSetProperty:propertyID type:typeID value:anObject for:aWindowID
"set a property in the XServer"
<context: #return>
@@ -10899,62 +10819,180 @@
%{ /* UNLIMITEDSTACK */
if (ISCONNECTED && __isAtomID(propertyID) && __isAtomID(typeID)) {
- Display *dpy = myDpy;
- Atom prop, type;
- Window window;
-
- prop = __AtomVal(propertyID);
- type = __AtomVal(typeID);
-
- if (__isExternalAddress(aWindowID)) {
- window = __WindowVal(aWindowID);
- } else if (aWindowID == nil) {
- window = DefaultRootWindow(dpy);
- } else if (__isInteger(aWindowID)) {
- window = (Window)__unsignedLongIntVal(aWindowID);
- } else {
- RETURN(false);
- }
-
- retval = true;
-
- ENTER_XLIB();
- if (__isInteger(anObject)) {
- unsigned INT value = __longIntVal(anObject);
- XChangeProperty(dpy, window, prop, type, 32,
- PropModeReplace,
- (unsigned char *)&value, 1);
- } else if (__isByteArrayLike(anObject)) {
- XChangeProperty(dpy, window, prop, type, 8,
- PropModeReplace,
- __byteArrayVal(anObject),
- __byteArraySize(anObject));
- } else if (__isWords(anObject)) {
- /* wordArray-like (16bit-string) object */
- XChangeProperty(dpy, window, prop, type, 16,
- PropModeReplace,
- __stringVal(anObject),
- __wordArraySize(anObject));
- } else if (__isIntegerArray(anObject)) {
- /* array of atoms */
- XChangeProperty(dpy, window, prop, type, 32,
- PropModeReplace,
- (char *)__integerArrayVal(anObject),
- __integerArraySize(anObject));
- } else if (__isStringLike(anObject)) {
- XChangeProperty(dpy, window, prop, type, 8,
- PropModeReplace,
- __stringVal(anObject),
- __stringSize(anObject));
- } else {
- retval = false;
- }
- LEAVE_XLIB();
-
- DPRINTF(("changeProp win=%"_lx_" prop=%"_lx_" type=%"_lx_"\n", (INT)window, (INT)prop, (INT)type));
+ Display *dpy = myDpy;
+ Atom prop, type;
+ Window window;
+
+ prop = __AtomVal(propertyID);
+ type = __AtomVal(typeID);
+
+ if (__isExternalAddress(aWindowID)) {
+ window = __WindowVal(aWindowID);
+ } else if (aWindowID == nil) {
+ window = DefaultRootWindow(dpy);
+ } else if (__isInteger(aWindowID)) {
+ window = (Window)__unsignedLongIntVal(aWindowID);
+ } else {
+ RETURN(false);
+ }
+
+ retval = true;
+
+ ENTER_XLIB();
+ if (__isInteger(anObject)) {
+ unsigned INT value = __longIntVal(anObject);
+ XChangeProperty(dpy, window, prop, type, 32,
+ PropModeReplace,
+ (unsigned char *)&value, 1);
+ } else if (__isByteArrayLike(anObject)) {
+ XChangeProperty(dpy, window, prop, type, 8,
+ PropModeReplace,
+ __byteArrayVal(anObject),
+ __byteArraySize(anObject));
+ } else if (__isWords(anObject)) {
+ /* wordArray-like (16bit-string) object */
+ XChangeProperty(dpy, window, prop, type, 16,
+ PropModeReplace,
+ __stringVal(anObject),
+ __wordArraySize(anObject));
+ } else if (__isIntegerArray(anObject)) {
+ /* array of atoms */
+ XChangeProperty(dpy, window, prop, type, 32,
+ PropModeReplace,
+ (char *)__integerArrayVal(anObject),
+ __integerArraySize(anObject));
+ } else if (__isStringLike(anObject)) {
+ XChangeProperty(dpy, window, prop, type, 8,
+ PropModeReplace,
+ __stringVal(anObject),
+ __stringSize(anObject));
+ } else {
+ retval = false;
+ }
+ LEAVE_XLIB();
+
+ DPRINTF(("changeProp win=%"_lx_" prop=%"_lx_" type=%"_lx_"\n", (INT)window, (INT)prop, (INT)type));
}
%}.
^ retval
+
+ "Created: / 26-04-2018 / 10:36:50 / stefan"
+!
+
+propertiesOf:aWindowOrWindowIDOrNil
+ "return a collection of all properties' atomIDs of a window.
+ Returns the rootWindows props for a nil window argument."
+
+ <context: #return>
+
+ |windowID propertyAtoms|
+
+ aWindowOrWindowIDOrNil isView ifTrue:[
+ windowID := aWindowOrWindowIDOrNil drawableId.
+ ] ifFalse:[
+ windowID := aWindowOrWindowIDOrNil.
+ ].
+
+%{
+ Window window;
+ Atom *atomListPtr;
+ int i;
+
+ if (ISCONNECTED) {
+ Display *dpy = myDpy;
+ int numProps = 0;
+
+ if (__isExternalAddress(windowID)) {
+ window = __WindowVal(windowID);
+ } else if (windowID == nil) {
+ window = DefaultRootWindow(dpy);
+ } else if (__isInteger(windowID)) {
+ window = (Window)__unsignedLongIntVal(windowID);
+ } else {
+ goto fail;
+ }
+
+ ENTER_XLIB();
+ atomListPtr = XListProperties(dpy, window, &numProps);
+ LEAVE_XLIB();
+
+ if (atomListPtr == NULL) {
+ RETURN (nil);
+ }
+
+ propertyAtoms = __ARRAY_NEW_INT(numProps);
+ if (propertyAtoms == nil) {
+ goto fail;
+ }
+
+ for (i=0; i<numProps; i++) {
+ OBJ atm;
+
+ atm = __MKATOMOBJ(atomListPtr[i]);
+ __ArrayInstPtr(propertyAtoms)->a_element[i] = atm; __STORE(propertyAtoms, atm);
+ }
+ XFree(atomListPtr);
+ RETURN (propertyAtoms);
+ }
+fail: ;
+%}.
+ ^ self primitiveFailed
+
+ "
+ Display propertiesOf:nil
+ Display propertiesOf:Transcript id
+
+ (Display propertiesOf:nil) collect:[:eachID | Display atomName:eachID]
+ (Display propertiesOf:Transcript id) collect:[:eachID | Display atomName:eachID]
+ "
+
+ "Modified: / 26-04-2018 / 11:00:12 / stefan"
+!
+
+setIcon:anIcon for:aWindowOrWindowID
+ |buffer iWidth iHeight|
+
+ iWidth := anIcon width.
+ iHeight := anIcon height.
+ buffer := IntegerArray new:(iWidth*iHeight+2).
+ buffer at:1 put:iWidth.
+ buffer at:2 put:iHeight.
+
+ self setProperty:#'_NET_WM_ICON' type:#CARDINAL value:buffer for:aWindowOrWindowID
+
+ "
+ Display setIcon:0 for:Transcript
+ "
+
+ "Modified (comment): / 26-04-2018 / 10:59:17 / stefan"
+!
+
+setProperty:propertySymbolOrAtomID type:typeSymbolOrAtomID value:anObject for:aWindowOrWindowIDOrNil
+ "set a property in the XServer"
+
+ |propertyAtomID typeAtomID windowIDOrNil|
+
+ propertySymbolOrAtomID isString ifTrue:[
+ propertyAtomID := self atomIDOf:propertySymbolOrAtomID create:false.
+ propertyAtomID isNil ifTrue:[^ false].
+ ] ifFalse:[
+ propertyAtomID := propertySymbolOrAtomID.
+ ].
+ typeSymbolOrAtomID isString ifTrue:[
+ typeAtomID := self atomIDOf:typeSymbolOrAtomID create:false.
+ typeAtomID isNil ifTrue:[^ false].
+ ] ifFalse:[
+ propertyAtomID := typeSymbolOrAtomID.
+ ].
+ aWindowOrWindowIDOrNil isView ifTrue:[
+ windowIDOrNil := aWindowOrWindowIDOrNil drawableId.
+ ] ifFalse:[
+ windowIDOrNil := aWindowOrWindowIDOrNil.
+ ].
+
+ ^ self primSetProperty:propertyAtomID type:typeAtomID value:anObject for:windowIDOrNil
+
+ "Modified: / 26-04-2018 / 10:43:29 / stefan"
! !
!XWorkstation methodsFor:'queries'!
@@ -12275,7 +12313,7 @@
!
mapView:aView id:aWindowId iconified:aBoolean atX:xPos y:yPos
- width:w height:h minExtent:minExt maxExtent:maxExt
+ width:w height:h minExtent:minExt maxExtent:maxExt
<context: #return>
@@ -12287,26 +12325,26 @@
|wicon wiconId iconMaskId wiconView wiconViewId wlabel minW minH maxW maxH|
aBoolean ifTrue:[
- wicon := aView icon.
- wicon notNil ifTrue:[
- wiconId := wicon id.
- wicon mask notNil ifTrue:[
- iconMaskId := wicon mask id.
- ].
- ].
- wiconView := aView iconView.
- wiconView notNil ifTrue:[
- wiconViewId := wiconView id
- ].
- wlabel := aView label.
+ wicon := aView icon.
+ wicon notNil ifTrue:[
+ wiconId := wicon drawableId.
+ wicon mask notNil ifTrue:[
+ iconMaskId := wicon mask drawableId.
+ ].
+ ].
+ wiconView := aView iconView.
+ wiconView notNil ifTrue:[
+ wiconViewId := wiconView drawableId
+ ].
+ wlabel := aView label.
].
minExt notNil ifTrue:[
- minW := minExt x.
- minH := minExt y.
+ minW := minExt x.
+ minH := minExt y.
].
maxExt notNil ifTrue:[
- maxW := maxExt x.
- maxH := maxExt y.
+ maxW := maxExt x.
+ maxH := maxExt y.
].
%{
@@ -12316,94 +12354,96 @@
if (ISCONNECTED
&& __isExternalAddress(aWindowId)) {
- Display *dpy = myDpy;
-
- win = __WindowVal(aWindowId);
-
- szhints.flags = 0;
- if (__bothSmallInteger(xPos, yPos)) {
- szhints.x = __intVal(xPos);
- szhints.y = __intVal(yPos);
- szhints.flags |= USPosition;
- }
- if (__bothSmallInteger(w, h)) {
- szhints.width = __intVal(w);
- szhints.height = __intVal(h);
- szhints.flags |= USSize;
- }
- if (__bothSmallInteger(minW, minH)) {
- szhints.flags |= PMinSize;
- szhints.min_width = __intVal(minW);
- szhints.min_height = __intVal(minH);
- }
- if (__bothSmallInteger(maxW, maxH)) {
- szhints.flags |= PMaxSize;
- szhints.max_width = __intVal(maxW);
- szhints.max_height = __intVal(maxH);
- }
-
- if (aBoolean == true) {
- char *windowName = "";
- Pixmap iconBitmap = (Pixmap)0;
- Pixmap iconMask = (Pixmap)0;
- Window iconWindow = (Window)0;
-
- if (__isExternalAddress(wiconId))
- iconBitmap = __PixmapVal(wiconId);
-
- if (__isExternalAddress(iconMaskId)) {
- iconMask = __PixmapVal(iconMaskId);
- }
-
- if (__isExternalAddress(wiconViewId))
- iconWindow = __WindowVal(wiconViewId);
-
- if (__isStringLike(wlabel))
- windowName = (char *) __stringVal(wlabel);
-
- if (iconBitmap || windowName) {
- ENTER_XLIB();
- XSetStandardProperties(dpy, win,
- windowName, windowName,
- iconBitmap,
- 0, 0, &szhints);
- LEAVE_XLIB();
- }
-
- wmhints.flags = 0;
- if (iconBitmap) {
- wmhints.flags |= IconPixmapHint;
- wmhints.icon_pixmap = iconBitmap;
- }
- if (iconMask) {
- wmhints.flags |= IconMaskHint;
- wmhints.icon_mask = iconMask;
- }
- if (iconWindow) {
- wmhints.flags |= IconWindowHint;
- wmhints.icon_window = iconWindow;
- }
-
- wmhints.initial_state = IconicState;
- wmhints.flags |= StateHint;
- ENTER_XLIB();
- XSetWMHints(dpy, win, &wmhints);
- LEAVE_XLIB();
- }
-
- if (szhints.flags) {
- ENTER_XLIB();
- XSetNormalHints(dpy, win, &szhints);
- LEAVE_XLIB();
- }
-
- ENTER_XLIB();
- XMapWindow(dpy, win);
- LEAVE_XLIB();
- RETURN ( self );
+ Display *dpy = myDpy;
+
+ win = __WindowVal(aWindowId);
+
+ szhints.flags = 0;
+ if (__bothSmallInteger(xPos, yPos)) {
+ szhints.x = __intVal(xPos);
+ szhints.y = __intVal(yPos);
+ szhints.flags |= USPosition;
+ }
+ if (__bothSmallInteger(w, h)) {
+ szhints.width = __intVal(w);
+ szhints.height = __intVal(h);
+ szhints.flags |= USSize;
+ }
+ if (__bothSmallInteger(minW, minH)) {
+ szhints.flags |= PMinSize;
+ szhints.min_width = __intVal(minW);
+ szhints.min_height = __intVal(minH);
+ }
+ if (__bothSmallInteger(maxW, maxH)) {
+ szhints.flags |= PMaxSize;
+ szhints.max_width = __intVal(maxW);
+ szhints.max_height = __intVal(maxH);
+ }
+
+ if (aBoolean == true) {
+ char *windowName = "";
+ Pixmap iconBitmap = (Pixmap)0;
+ Pixmap iconMask = (Pixmap)0;
+ Window iconWindow = (Window)0;
+
+ if (__isExternalAddress(wiconId))
+ iconBitmap = __PixmapVal(wiconId);
+
+ if (__isExternalAddress(iconMaskId)) {
+ iconMask = __PixmapVal(iconMaskId);
+ }
+
+ if (__isExternalAddress(wiconViewId))
+ iconWindow = __WindowVal(wiconViewId);
+
+ if (__isStringLike(wlabel))
+ windowName = (char *) __stringVal(wlabel);
+
+ if (iconBitmap || windowName) {
+ ENTER_XLIB();
+ XSetStandardProperties(dpy, win,
+ windowName, windowName,
+ iconBitmap,
+ 0, 0, &szhints);
+ LEAVE_XLIB();
+ }
+
+ wmhints.flags = 0;
+ if (iconBitmap) {
+ wmhints.flags |= IconPixmapHint;
+ wmhints.icon_pixmap = iconBitmap;
+ }
+ if (iconMask) {
+ wmhints.flags |= IconMaskHint;
+ wmhints.icon_mask = iconMask;
+ }
+ if (iconWindow) {
+ wmhints.flags |= IconWindowHint;
+ wmhints.icon_window = iconWindow;
+ }
+
+ wmhints.initial_state = IconicState;
+ wmhints.flags |= StateHint;
+ ENTER_XLIB();
+ XSetWMHints(dpy, win, &wmhints);
+ LEAVE_XLIB();
+ }
+
+ if (szhints.flags) {
+ ENTER_XLIB();
+ XSetNormalHints(dpy, win, &szhints);
+ LEAVE_XLIB();
+ }
+
+ ENTER_XLIB();
+ XMapWindow(dpy, win);
+ LEAVE_XLIB();
+ RETURN ( self );
}
%}.
self primitiveFailedOrClosedConnection
+
+ "Modified: / 26-04-2018 / 11:01:29 / stefan"
!
mapWindow:aWindowId
@@ -13012,23 +13052,25 @@
|iconId|
aForm notNil ifTrue:[
- iconId := aForm id
+ iconId := aForm drawableId
].
%{
if (ISCONNECTED
&& __isExternalAddress(iconId)
&& __isExternalAddress(aWindowId)) {
- XWMHints hints;
-
- hints.icon_pixmap = __PixmapVal(iconId);
- hints.flags = IconPixmapHint;
- ENTER_XLIB();
- XSetWMHints(myDpy, __WindowVal(aWindowId), &hints);
- LEAVE_XLIB();
- RETURN ( self );
+ XWMHints hints;
+
+ hints.icon_pixmap = __PixmapVal(iconId);
+ hints.flags = IconPixmapHint;
+ ENTER_XLIB();
+ XSetWMHints(myDpy, __WindowVal(aWindowId), &hints);
+ LEAVE_XLIB();
+ RETURN ( self );
}
%}.
self primitiveFailedOrClosedConnection
+
+ "Modified: / 26-04-2018 / 11:00:51 / stefan"
!
setWindowIcon:aForm mask:aMaskForm in:aWindowId
@@ -13039,32 +13081,33 @@
|iconId maskId|
aForm notNil ifTrue:[
- iconId := aForm id
+ iconId := aForm drawableId.
].
aMaskForm notNil ifTrue:[
- maskId := aMaskForm id.
+ maskId := aMaskForm drawableId.
].
%{
if (ISCONNECTED
&& __isExternalAddress(iconId)
&& __isExternalAddress(aWindowId)) {
- XWMHints hints;
-
- hints.icon_pixmap = __PixmapVal(iconId);
- hints.flags = IconPixmapHint;
- if ((maskId != nil)
- && __isExternalAddress(maskId)) {
- hints.icon_mask = __PixmapVal(maskId);
- hints.flags |= IconMaskHint;
- }
- ENTER_XLIB();
- XSetWMHints(myDpy, __WindowVal(aWindowId), &hints);
- LEAVE_XLIB();
- RETURN ( self );
+ XWMHints hints;
+
+ hints.icon_pixmap = __PixmapVal(iconId);
+ hints.flags = IconPixmapHint;
+ if ((maskId != nil)
+ && __isExternalAddress(maskId)) {
+ hints.icon_mask = __PixmapVal(maskId);
+ hints.flags |= IconMaskHint;
+ }
+ ENTER_XLIB();
+ XSetWMHints(myDpy, __WindowVal(aWindowId), &hints);
+ LEAVE_XLIB();
+ RETURN ( self );
}
%}.
self primitiveFailedOrClosedConnection
+ "Modified: / 26-04-2018 / 11:01:04 / stefan"
!
setWindowIconWindow:aView in:aWindowId
@@ -13075,23 +13118,25 @@
|iconWindowId|
aView notNil ifTrue:[
- iconWindowId := aView id
+ iconWindowId := aView drawableId.
].
%{
if (ISCONNECTED
&& __isExternalAddress(iconWindowId)
&& __isExternalAddress(aWindowId)) {
- XWMHints wmhints;
-
- wmhints.icon_window = __WindowVal(iconWindowId);
- wmhints.flags = IconWindowHint;
- ENTER_XLIB();
- XSetWMHints(myDpy, __WindowVal(aWindowId), &wmhints);
- LEAVE_XLIB();
- RETURN ( self );
+ XWMHints wmhints;
+
+ wmhints.icon_window = __WindowVal(iconWindowId);
+ wmhints.flags = IconWindowHint;
+ ENTER_XLIB();
+ XSetWMHints(myDpy, __WindowVal(aWindowId), &wmhints);
+ LEAVE_XLIB();
+ RETURN ( self );
}
%}.
self primitiveFailedOrClosedConnection
+
+ "Modified: / 26-04-2018 / 11:01:12 / stefan"
!
setWindowMinExtentX:minW y:minH maxExtentX:maxW y:maxH in:aWindowId
@@ -13177,16 +13222,13 @@
If anIntegerOrNil is nil, then PID of currently running
Smalltalk is used"
- | propertyID typeId pid |
-
- propertyID := self atomIDOf: '_NET_WM_PID' create: false.
- propertyID isNil ifTrue:[ ^ self ].
+ | pid |
+
pid := anIntegerOrNil isNil ifTrue:[OperatingSystem getProcessId] ifFalse:[anIntegerOrNil].
- typeId := self atomIDOf:#'CARDINAL' create:false.
-
- self setProperty:propertyID type:typeId value:pid for:aWindowId
+ self setProperty:#'_NET_WM_PID' type:#CARDINAL value:pid for:aWindowId
"Created: / 04-01-2013 / 16:03:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 26-04-2018 / 10:46:24 / stefan"
!
setWindowShape:aPixmapId in:aWindowId
@@ -13255,77 +13297,35 @@
"
!
-setWindowType:aSymbol in:aWindowId
+setWindowType:aSymbol in:aWindowOrWindowId
"Tell the window type to the window manager.
See Extended Window Manager Hints 1.3,
chapter 'Application Window Properties'
http://standards.freedesktop.org/wm-spec/1.3/
- JV@2012-05-15: There was some code prior 2012-05-15,
- but that code does not work anymore and I wonder if it
- ever worked correctly. I changed it to be
- EWMH compatible, as this improve UX on modern Linxu
- machines.
-
- It also helps to fix super-annoying problem with window autoraiser
- on X11 in a proper way - window manager should manage top-level
- window stacking, that's why it is called a 'window manager' :-)
-
- "
-
- | nameAtom typeAtom valueAtom |
+ It also helps to fix super-annoying problem with window autoraiser
+ on X11 in a proper way - window manager should manage top-level
+ window stacking, that's why it is called a 'window manager' :-)"
+
+ | valueAtom |
self assert:(#(_NET_WM_WINDOW_TYPE_DESKTOP
- _NET_WM_WINDOW_TYPE_DOCK
- _NET_WM_WINDOW_TYPE_TOOLBAR
- _NET_WM_WINDOW_TYPE_MENU
- _NET_WM_WINDOW_TYPE_UTILITY
- _NET_WM_WINDOW_TYPE_SPLASH
- _NET_WM_WINDOW_TYPE_DIALOG
- _NET_WM_WINDOW_TYPE_NORMAL) includes: aSymbol).
-
- nameAtom := self atomIDOf:#'_NET_WM_WINDOW_TYPE' create:false.
- nameAtom isNil ifTrue:[
- "/Hmm, no such property, not running under EWMH compliant WM?
- self breakPoint: #jv.
- ^self
- ].
- "/ Hmm, hmm, no access to XA_ATOM, XA_INTEGER and so on...
- typeAtom := self atomIDOf:#'ATOM' create:false.
- typeAtom isNil ifTrue:[
- self error:'Oops, no ATOM atom'.
- ].
- valueAtom := self atomIDOf: aSymbol create:false.
+ _NET_WM_WINDOW_TYPE_DOCK
+ _NET_WM_WINDOW_TYPE_TOOLBAR
+ _NET_WM_WINDOW_TYPE_MENU
+ _NET_WM_WINDOW_TYPE_UTILITY
+ _NET_WM_WINDOW_TYPE_SPLASH
+ _NET_WM_WINDOW_TYPE_DIALOG
+ _NET_WM_WINDOW_TYPE_NORMAL) includes: aSymbol).
+
+ valueAtom := self atomIDOf:aSymbol create:false.
valueAtom isNil ifTrue:[
- "/Hmm, no such property, not running under EWMH compliant WM?
- self breakPoint: #jv.
- ^self
- ].
-
- self setProperty: nameAtom type: typeAtom value: valueAtom for: aWindowId.
-
-
-"/ Original code that does not work (if ever worked)
-"/
-"/ |netWmWindowTypeAtom typeAtom|
-"/
-"/ netWmWindowTypeAtom := self atomIDOf:#'_NET_WM_WINDOW_TYPE' create:false.
-"/ typeAtom := self atomIDOf:aSymbol create:false.
-"/
-"/ (netWmWindowTypeAtom notNil and:[typeAtom notNil]) ifTrue:[
-"/ self
-"/ sendClientEvent:netWmWindowTypeAtom
-"/ format:32
-"/ to:(self rootWindowId)
-"/ propagate:true
-"/ eventMask:((self eventMaskFor:#substructureNotify) bitOr:(self eventMaskFor:#substructureRedirect))
-"/ window:aWindowId
-"/ data1:typeAtom
-"/ data2:nil
-"/ data3:nil
-"/ data4:nil
-"/ data5:nil.
-"/ ].
+ "/Hmm, no such property, not running under EWMH compliant WM?
+ self breakPoint: #jv.
+ ^ self
+ ].
+
+ self setProperty:#'_NET_WM_WINDOW_TYPE' type:#ATOM value:valueAtom for:aWindowOrWindowId.
"
|v|
@@ -13342,6 +13342,7 @@
"
"Modified (comment): / 15-05-2012 / 10:49:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified (format): / 26-04-2018 / 10:48:59 / stefan"
!
unmapWindow:aWindowId