XWorkstation.st
author Claus Gittinger <cg@exept.de>
Mon, 15 Jan 1996 13:49:50 +0100
changeset 366 4783fabc35c0
parent 353 5be3ae3c8838
child 374 17c544cc1fad
permissions -rw-r--r--
validate GC before freeing
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
48194c26a46c Initial revision
claus
parents:
diff changeset
     1
"
6
7ee0cfde237d *** empty log message ***
claus
parents: 5
diff changeset
     2
COPYRIGHT (c) 1989 by Claus Gittinger
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
     3
	      All Rights Reserved
0
48194c26a46c Initial revision
claus
parents:
diff changeset
     4
48194c26a46c Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
48194c26a46c Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
48194c26a46c Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
48194c26a46c Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
48194c26a46c Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
48194c26a46c Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
48194c26a46c Initial revision
claus
parents:
diff changeset
    11
"
48194c26a46c Initial revision
claus
parents:
diff changeset
    12
48194c26a46c Initial revision
claus
parents:
diff changeset
    13
DeviceWorkstation subclass:#XWorkstation
341
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
    14
	instanceVariableNames:'screen hasShapeExtension hasFaxExtension hasShmExtension
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
    15
		hasDPSExtension hasMbufExtension hasXVideoExtension hasSaveUnder
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
    16
		hasPEXExtension hasImageExtension hasInputExtension
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
    17
		ignoreBackingStore blackpixel whitepixel protocolsAtom
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
    18
		deleteWindowAtom saveYourselfAtom quitAppAtom primaryAtom
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
    19
		secondaryAtom cutBuffer0Atom stringAtom lengthAtom listOfXFonts
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
    20
		buttonsPressed eventRootX eventRootY displayName eventTrace
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
    21
		dispatchingExpose rgbVisual virtualRootId rootId eventBuffer
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
    22
		altModifierMask metaModifierMask'
341
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
    23
	classVariableNames:'RawKeysymTranslation'
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
    24
	poolDictionaries:''
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
    25
	category:'Interface-Graphics'
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
    26
!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    27
78
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
    28
!XWorkstation primitiveDefinitions!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    29
%{
46
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
    30
/*
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
    31
 * x does a typedef Time - I need Object Time ...
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
    32
 */
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    33
#define Time XTime
48194c26a46c Initial revision
claus
parents:
diff changeset
    34
37
c2dc1832c0f1 *** empty log message ***
claus
parents: 36
diff changeset
    35
#ifdef memset
c2dc1832c0f1 *** empty log message ***
claus
parents: 36
diff changeset
    36
# undef memset
c2dc1832c0f1 *** empty log message ***
claus
parents: 36
diff changeset
    37
#endif
c2dc1832c0f1 *** empty log message ***
claus
parents: 36
diff changeset
    38
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    39
#include <stdio.h>
48194c26a46c Initial revision
claus
parents:
diff changeset
    40
#include <X11/Xlib.h>
48194c26a46c Initial revision
claus
parents:
diff changeset
    41
#include <X11/Xutil.h>
48194c26a46c Initial revision
claus
parents:
diff changeset
    42
#include <X11/Xatom.h>
48194c26a46c Initial revision
claus
parents:
diff changeset
    43
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
    44
#define XK_MISCELLANY
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
    45
#include <X11/keysymdef.h>
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
    46
277
eb67c44da084 testing new inline-expression feature of stc - no real change
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
    47
#include <X11/cursorfont.h>
eb67c44da084 testing new inline-expression feature of stc - no real change
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
    48
90
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
    49
/*
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
    50
 * this define adds support for two-byte-strings.
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
    51
 * leaving it undefined does not really save you much
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
    52
 * (the define will vanish)
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
    53
 */
36
b297468551c6 *** empty log message ***
claus
parents: 31
diff changeset
    54
#define TWOBYTESTRINGS
b297468551c6 *** empty log message ***
claus
parents: 31
diff changeset
    55
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    56
/*
48194c26a46c Initial revision
claus
parents:
diff changeset
    57
 * shape support works; enabled by -DSHAPE in makefile
48194c26a46c Initial revision
claus
parents:
diff changeset
    58
 * see RoundClock and RoundGlobe examples
48194c26a46c Initial revision
claus
parents:
diff changeset
    59
 */
48194c26a46c Initial revision
claus
parents:
diff changeset
    60
#ifdef SHAPE
48194c26a46c Initial revision
claus
parents:
diff changeset
    61
# include <X11/extensions/shape.h>
48194c26a46c Initial revision
claus
parents:
diff changeset
    62
#endif
48194c26a46c Initial revision
claus
parents:
diff changeset
    63
48194c26a46c Initial revision
claus
parents:
diff changeset
    64
/*
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
    65
 * shared memory extension access is currently not supported
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    66
 * (only query is implemented)
48194c26a46c Initial revision
claus
parents:
diff changeset
    67
 */
48194c26a46c Initial revision
claus
parents:
diff changeset
    68
#ifdef SHM
48194c26a46c Initial revision
claus
parents:
diff changeset
    69
# include <X11/extensions/XShm.h>
48194c26a46c Initial revision
claus
parents:
diff changeset
    70
#endif
48194c26a46c Initial revision
claus
parents:
diff changeset
    71
48194c26a46c Initial revision
claus
parents:
diff changeset
    72
/*
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
    73
 * multiBuffer extension access is currently not supported
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
    74
 * (only query is implemented)
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
    75
 */
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
    76
#ifdef MBUF
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
    77
# include <X11/extensions/multibuf.h>
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
    78
#endif
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
    79
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
    80
/*
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
    81
 * XVideo extension access is currently not supported
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
    82
 * (only query is implemented)
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
    83
 */
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
    84
#ifdef XVIDEO
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
    85
# include <X11/extensions/Xv.h>
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
    86
#endif
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
    87
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
    88
/*
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    89
 * this is a non-standard fax-image decompression extension
48194c26a46c Initial revision
claus
parents:
diff changeset
    90
 * (only found in megascan servers ported by myself)
48194c26a46c Initial revision
claus
parents:
diff changeset
    91
 */
48194c26a46c Initial revision
claus
parents:
diff changeset
    92
#ifdef FAX
48194c26a46c Initial revision
claus
parents:
diff changeset
    93
# include <X11/extensions/XFAXImage.h>
48194c26a46c Initial revision
claus
parents:
diff changeset
    94
#endif
48194c26a46c Initial revision
claus
parents:
diff changeset
    95
48194c26a46c Initial revision
claus
parents:
diff changeset
    96
/*
186
claus
parents: 180
diff changeset
    97
 * PEX extension - if available
claus
parents: 180
diff changeset
    98
 */
claus
parents: 180
diff changeset
    99
#ifdef PEX5
claus
parents: 180
diff changeset
   100
# include <PEX5/PEX.h>
claus
parents: 180
diff changeset
   101
#endif
claus
parents: 180
diff changeset
   102
claus
parents: 180
diff changeset
   103
/*
claus
parents: 180
diff changeset
   104
 * XImage extension - if available
claus
parents: 180
diff changeset
   105
 */
claus
parents: 180
diff changeset
   106
#ifdef XIE
claus
parents: 180
diff changeset
   107
# include <X11/extensions/XIE.h>
claus
parents: 180
diff changeset
   108
#endif
claus
parents: 180
diff changeset
   109
claus
parents: 180
diff changeset
   110
/*
90
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   111
 * when I have more time to check it out, I will support display-PS
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   112
 */
48194c26a46c Initial revision
claus
parents:
diff changeset
   113
#ifdef DPS
48194c26a46c Initial revision
claus
parents:
diff changeset
   114
# ifdef sgi
48194c26a46c Initial revision
claus
parents:
diff changeset
   115
#  include <X11/extensions/XDPS.h>
48194c26a46c Initial revision
claus
parents:
diff changeset
   116
#  include <X11/extensions/XDPSlib.h>
48194c26a46c Initial revision
claus
parents:
diff changeset
   117
#  include <X11/extensions/dpsXclient.h>
48194c26a46c Initial revision
claus
parents:
diff changeset
   118
# else
48194c26a46c Initial revision
claus
parents:
diff changeset
   119
#  include <DPS/XDPS.h>
48194c26a46c Initial revision
claus
parents:
diff changeset
   120
#  include <DPS/XDPSlib.h>
48194c26a46c Initial revision
claus
parents:
diff changeset
   121
#  include <DPS/dpsXclient.h>
48194c26a46c Initial revision
claus
parents:
diff changeset
   122
# endif
48194c26a46c Initial revision
claus
parents:
diff changeset
   123
#endif
48194c26a46c Initial revision
claus
parents:
diff changeset
   124
90
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   125
#if defined(IRIX5) || (XlibSpecificationRelease == 6)
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   126
  /*
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   127
   * accessing private data in Display ... sorry
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   128
   */
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   129
# define DISPLAYACCESS(d) ((_XPrivDisplay)d)
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   130
#else
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   131
# define DISPLAYACCESS(d) d
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   132
#endif
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   133
78
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   134
/*
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   135
 * some defines - tired of typing ...
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   136
 */
207
9124817bbb03 use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents: 206
diff changeset
   137
#define _DisplayVal(o)       (Display *)(__MKCP(o))
9124817bbb03 use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents: 206
diff changeset
   138
#define _WindowVal(o)        (Window)(__MKCP(o))
9124817bbb03 use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents: 206
diff changeset
   139
#define _PixmapVal(o)        (Pixmap)(__MKCP(o))
9124817bbb03 use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents: 206
diff changeset
   140
#define _GCVal(o)            (GC)(__MKCP(o))
9124817bbb03 use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents: 206
diff changeset
   141
#define _CursorVal(o)        (Cursor)(__MKCP(o))
9124817bbb03 use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents: 206
diff changeset
   142
#define _FontVal(o)          (XFontStruct *)(__MKCP(o))
9124817bbb03 use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents: 206
diff changeset
   143
#define _DPSContextVal(o)    (DPSContext)(__MKCP(o))
9124817bbb03 use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents: 206
diff changeset
   144
211
b5f925b56e8e Fix example.
Stefan Vogel <sv@exept.de>
parents: 208
diff changeset
   145
#define __MKATOMOBJ(a)       __MKSMALLINT(a)
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
   146
#define _AtomVal(o)          __intVal(o)
211
b5f925b56e8e Fix example.
Stefan Vogel <sv@exept.de>
parents: 208
diff changeset
   147
#define __isAtomID(o)        __isSmallInteger(o)
b5f925b56e8e Fix example.
Stefan Vogel <sv@exept.de>
parents: 208
diff changeset
   148
b5f925b56e8e Fix example.
Stefan Vogel <sv@exept.de>
parents: 208
diff changeset
   149
#define myDpy                _DisplayVal(_INST(displayId))
b5f925b56e8e Fix example.
Stefan Vogel <sv@exept.de>
parents: 208
diff changeset
   150
#define ISCONNECTED          (_INST(displayId) != nil)
78
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   151
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   152
#ifndef THISCONTEXT_IN_REGISTER
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   153
# define BEGIN_INTERRUPTSBLOCKED /* */
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   154
# define END_INTERRUPTSBLOCKED /* */
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   155
#else
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   156
extern int __interruptsBlocked;
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   157
# define BEGIN_INTERRUPTSBLOCKED        \
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   158
    {                                   \
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   159
	int needUnblock = 0;            \
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   160
	extern OBJ __thisContext__;     \
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   161
					\
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   162
	__thisContext__ = __thisContext;\
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   163
	if (!__interruptsBlocked) {     \
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   164
	    __BLOCKINTERRUPTS();        \
78
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   165
	    needUnblock = 1;            \
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   166
	}
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   167
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   168
# define END_INTERRUPTSBLOCKED          \
158
claus
parents: 157
diff changeset
   169
	__thisContext = __thisContext;  \
claus
parents: 157
diff changeset
   170
	__thisContext__ = 0;            \
78
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   171
	if (needUnblock) {              \
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   172
	    __UNBLOCKINTERRUPTS();      \
78
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   173
	}                               \
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   174
    }
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   175
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   176
#endif
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   177
%}
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   178
! !
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   179
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   180
!XWorkstation primitiveVariables!
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   181
%{
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   182
/*
146
claus
parents: 145
diff changeset
   183
 * remembered info from private error handler
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   184
 */
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   185
static char lastErrorMsg[80] = "";
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   186
static unsigned lastRequestCode = 0;
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   187
static unsigned lastMinorCode = 0;
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   188
static unsigned lastResource = 0;
129
752fbb07635a *** empty log message ***
claus
parents: 125
diff changeset
   189
752fbb07635a *** empty log message ***
claus
parents: 125
diff changeset
   190
static int __debug__ = 0;
752fbb07635a *** empty log message ***
claus
parents: 125
diff changeset
   191
#define DPRINTF(x)      if (__debug__) { printf x; }
78
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   192
%}
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   193
! !
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   194
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   195
!XWorkstation primitiveFunctions!
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   196
%{
18
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   197
/*
144
claus
parents: 143
diff changeset
   198
 * catch X-errors and forward as errorInterrupt:#DisplayError,
claus
parents: 143
diff changeset
   199
 * (which itself invokes my handler and optionally raises an exceptionSignal)
90
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   200
 * the implementation below is somewhat wrong: it will
78
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   201
 * report all errors for Display, even though there could be
162
claus
parents: 160
diff changeset
   202
 * more than one display connection. (being fixed, new errorInterrupt mechanism
claus
parents: 160
diff changeset
   203
 * allows passing an additional argument, which is the displayID ...)
18
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   204
 */
168
claus
parents: 163
diff changeset
   205
static
12
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
   206
__XErrorHandler__(dpy, event)
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   207
    Display *dpy;
48194c26a46c Initial revision
claus
parents:
diff changeset
   208
    XErrorEvent *event;
48194c26a46c Initial revision
claus
parents:
diff changeset
   209
{
163
claus
parents: 162
diff changeset
   210
#ifdef _AIX
claus
parents: 162
diff changeset
   211
printf("XError\n"); fflush(stdout);
claus
parents: 162
diff changeset
   212
#endif
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   213
    XGetErrorText(dpy, event->error_code, lastErrorMsg, 80);
48194c26a46c Initial revision
claus
parents:
diff changeset
   214
    if (lastErrorMsg[0] == '\0') {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
   215
	sprintf(lastErrorMsg, "code: %d", event->error_code);
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   216
    }
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   217
    lastRequestCode = event->request_code;
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   218
    lastMinorCode = event->minor_code;
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   219
    lastResource = event->resourceid;
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   220
254
d6f12ecd7767 ErrorPrinting variable now correctly detected by stc
Claus Gittinger <cg@exept.de>
parents: 250
diff changeset
   221
    if (@global(ErrorPrinting) == true) {
219
9ff0660f447f uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   222
	fprintf(stderr, "XWORKSTAT: x-error cought maj=%d (0x%x) min=%d (0x%x) resource=%x\n",
9ff0660f447f uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   223
			event->request_code, event->request_code, 
9ff0660f447f uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   224
			event->minor_code, event->minor_code, event->resourceid);
9ff0660f447f uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   225
	fprintf(stderr, "XWORKSTAT: x-error message is '%s'\n", lastErrorMsg);
218
10072d9beba5 can now turn off Xlib error messages from the errorHandler
Claus Gittinger <cg@exept.de>
parents: 217
diff changeset
   226
    }
43
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
   227
207
9124817bbb03 use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents: 206
diff changeset
   228
    __errorInterruptWithIDAndParameter__(@symbol(DisplayError), __MKOBJ(dpy));
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   229
    return 0;
48194c26a46c Initial revision
claus
parents:
diff changeset
   230
}
48194c26a46c Initial revision
claus
parents:
diff changeset
   231
90
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   232
#ifdef VIRTUAL_ROOT
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   233
/*
18
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   234
 * added since RootWindow-macro is not suficient
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   235
 * when virtual root-windows are involved (i.e. tvtwm)
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   236
 */
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   237
static Window
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   238
getRootWindow(dpy, screen)
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   239
    Display *dpy;
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   240
{
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   241
    Window root;
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   242
    Atom vRootAtom = None;
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   243
    int i;
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   244
    Window rootReturn, parentReturn;
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   245
    Window* children;
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   246
    unsigned int numChildren;
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   247
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   248
    root = RootWindow(dpy, screen);
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   249
    /*
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   250
     * on IRIS, this creates a badwindow error - why ?
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   251
     * children contains a funny window (000034)
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   252
     */
90
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   253
# if !defined(IRIS) || defined(IRIX5)
18
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   254
    if (XQueryTree(dpy, root, &rootReturn, &parentReturn, &children, &numChildren)) {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
   255
	vRootAtom = XInternAtom(dpy, "__SWM_VROOT", True );
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
   256
	if (vRootAtom != None) {
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
   257
	    for (i=0; i < numChildren; i++) {
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
   258
		Atom actual_type;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
   259
		int actual_format;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
   260
		unsigned long nitems, bytesafter;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
   261
		Window* newRoot = (Window*) 0;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
   262
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
   263
		if (children[i]) {
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
   264
		    if (XGetWindowProperty(dpy, children[i], vRootAtom,
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
   265
					   0L, 1L, False, XA_WINDOW,
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
   266
					   &actual_type, &actual_format, &nitems, &bytesafter,
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
   267
					   (unsigned char**) &newRoot) == Success && newRoot) {
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
   268
			root = *newRoot;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
   269
			break;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
   270
		    }
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
   271
		}
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
   272
	    }
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
   273
	    if (children) XFree( children );
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
   274
	}
18
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   275
    }
90
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   276
# endif
18
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   277
    return root;
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   278
}
90
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   279
#endif
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   280
%}
78
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   281
! !
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   282
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   283
!XWorkstation class methodsFor:'documentation'!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   284
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   285
copyright
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   286
"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   287
COPYRIGHT (c) 1989 by Claus Gittinger
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   288
	      All Rights Reserved
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   289
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   290
 This software is furnished under a license and may be used
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   291
 only in accordance with the terms of that license and with the
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   292
 inclusion of the above copyright notice.   This software may not
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   293
 be provided or otherwise made available to, or used by, any
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   294
 other person.  No title to or ownership of the software is
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   295
 hereby transferred.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   296
"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   297
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   298
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   299
documentation
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   300
"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   301
    this class provides the interface to X11. It redefines all required methods
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   302
    from DeviceWorkstation. Notice, that in Smalltalk/X you are not technically
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   303
    limited to one display - in theory, you can create Views on many displays
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   304
    simultanously. However, the default setup is for one display only.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   305
    To support multiple displays, you will have to start another event dispatcher
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   306
    process for the other display(s) and create the other views with a slightly
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   307
    different protocol. However, 'normal' applications do not have to care for
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   308
    all of this ...
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   309
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   310
    See more documentation in my superclass, DeviceWorkstation.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   311
"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   312
! !
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   313
250
eaa532ebcad7 modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
   314
!XWorkstation class methodsFor:'initialization'!
eaa532ebcad7 modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
   315
eaa532ebcad7 modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
   316
initialize
eaa532ebcad7 modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
   317
    |d|
eaa532ebcad7 modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
   318
eaa532ebcad7 modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
   319
    super initialize.
eaa532ebcad7 modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
   320
eaa532ebcad7 modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
   321
    "/ the following table maps X-keyevents to ST/X
eaa532ebcad7 modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
   322
    "/ device independed events. 
eaa532ebcad7 modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
   323
    "/ It is NOT meant as a keyboardMap replacement.
eaa532ebcad7 modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
   324
eaa532ebcad7 modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
   325
    RawKeysymTranslation := d := Dictionary new.
eaa532ebcad7 modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
   326
    d at:'Delete_line' put:#DeleteLine.
eaa532ebcad7 modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
   327
    d at:'Delete_word' put:#DeleteWord.
eaa532ebcad7 modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
   328
    d at:'Down' put:#CursorDown.
eaa532ebcad7 modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
   329
    d at:'Up' put:#CursorUp.
eaa532ebcad7 modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
   330
    d at:'Left' put:#CursorLeft.
eaa532ebcad7 modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
   331
    d at:'Right' put:#CursorRight.
eaa532ebcad7 modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
   332
! !
eaa532ebcad7 modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
   333
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   334
!XWorkstation class methodsFor:'error handling'!
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   335
129
752fbb07635a *** empty log message ***
claus
parents: 125
diff changeset
   336
debug:aBoolean
752fbb07635a *** empty log message ***
claus
parents: 125
diff changeset
   337
%{  /* NOCONTEXT */
752fbb07635a *** empty log message ***
claus
parents: 125
diff changeset
   338
752fbb07635a *** empty log message ***
claus
parents: 125
diff changeset
   339
    __debug__ = (aBoolean == true) ? 1 : 0;
752fbb07635a *** empty log message ***
claus
parents: 125
diff changeset
   340
%}
752fbb07635a *** empty log message ***
claus
parents: 125
diff changeset
   341
!
752fbb07635a *** empty log message ***
claus
parents: 125
diff changeset
   342
78
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   343
errorStringOfLastError
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   344
%{
216
f4fd44038317 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   345
    RETURN ( __MKSTRING(lastErrorMsg COMMA_CON) );
78
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   346
%}
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   347
!
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   348
135
claus
parents: 133
diff changeset
   349
lastErrorString
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   350
    "return the last X-error string - 
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   351
     when buffering is on, this may be
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   352
     an error for a long-ago operation"
78
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   353
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   354
    |string requestCode s match line|
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   355
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   356
    string := self errorStringOfLastError.
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   357
    requestCode := self requestCodeOfLastError.
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   358
    "
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   359
     X specific: search the requestCode in '/usr/lib/X11/XErrorDB',
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   360
     and append the name of the corresponding X-request
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   361
    "
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   362
    s := '/usr/lib/X11/XErrorDB' asFilename readStream.
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   363
    s notNil ifTrue:[
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   364
	match := 'XRequest.' , requestCode printString.
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   365
	line := s peekForLineStartingWith:match.
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   366
	line notNil ifTrue:[
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   367
	    string := string , ' in ' , (line copyFrom:(line indexOf:$:)+1)
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   368
	].
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   369
	s close.
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   370
    ].
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   371
    ^ string
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   372
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   373
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   374
minorCodeOfLastError
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   375
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   376
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   377
    RETURN ( __MKSMALLINT(lastMinorCode) );
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   378
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   379
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   380
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   381
requestCodeOfLastError
152
claus
parents: 150
diff changeset
   382
%{  /* NOCONTEXT */
claus
parents: 150
diff changeset
   383
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   384
    RETURN ( __MKSMALLINT(lastRequestCode) );
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   385
%}
135
claus
parents: 133
diff changeset
   386
!
claus
parents: 133
diff changeset
   387
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   388
resourceIdOfLastError
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   389
%{  /* NOCONTEXT */
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   390
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   391
    RETURN ( __MKOBJ(lastResource) );
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   392
%}
48194c26a46c Initial revision
claus
parents:
diff changeset
   393
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
   394
104
aa39cabdc13b *** empty log message ***
claus
parents: 98
diff changeset
   395
!XWorkstation class methodsFor:'queries'!
aa39cabdc13b *** empty log message ***
claus
parents: 98
diff changeset
   396
aa39cabdc13b *** empty log message ***
claus
parents: 98
diff changeset
   397
platformName
133
claus
parents: 132
diff changeset
   398
    "ST-80 compatibility.
claus
parents: 132
diff changeset
   399
     Return a string describing the display systems platform."
claus
parents: 132
diff changeset
   400
claus
parents: 132
diff changeset
   401
    ^ 'X'  "I don't know what ST-80 returns for X ..."
104
aa39cabdc13b *** empty log message ***
claus
parents: 98
diff changeset
   402
! !
aa39cabdc13b *** empty log message ***
claus
parents: 98
diff changeset
   403
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   404
!XWorkstation methodsFor:'accessing & queries'!
48194c26a46c Initial revision
claus
parents:
diff changeset
   405
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   406
blackpixel
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   407
    "return the colornumber of black"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   408
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   409
    ^ blackpixel
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   410
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   411
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   412
button1MotionMask
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   413
    "return the state-mask for button1 in motion events state-field.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   414
     For backward compatibility."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   415
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   416
%{  /* NOCONTEXT */
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   417
    RETURN (__MKSMALLINT(Button1MotionMask));
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   418
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   419
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   420
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   421
button2MotionMask
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   422
    "return the state-mask for button2 in motion events state-field
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   423
     For backward compatibility."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   424
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   425
%{  /* NOCONTEXT */
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   426
    RETURN (__MKSMALLINT(Button2MotionMask));
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   427
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   428
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   429
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   430
button3MotionMask
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   431
    "return the state-mask for button3 in motion events state-field
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   432
     For backward compatibility."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   433
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   434
%{  /* NOCONTEXT */
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   435
    RETURN (__MKSMALLINT(Button3MotionMask));
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   436
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   437
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   438
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   439
buttonMotionMask:aButton
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   440
    "return the state-mask for button1 in motion events state-field.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   441
     This is the devices mask."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   442
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   443
%{  /* NOCONTEXT */
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   444
    if (aButton == __MKSMALLINT(1)) {
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   445
	RETURN (__MKSMALLINT(Button1MotionMask));
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   446
    }
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   447
    if (aButton == __MKSMALLINT(2)) {
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   448
	RETURN (__MKSMALLINT(Button2MotionMask));
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   449
    }
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   450
    if (aButton == __MKSMALLINT(3)) {
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   451
	RETURN (__MKSMALLINT(Button3MotionMask));
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   452
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   453
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   454
    ^ nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   455
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   456
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   457
defaultEventMask
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   458
    "return a mask to enable some events by default."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   459
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   460
%{  /* NOCONTEXT */
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   461
    RETURN (__MKSMALLINT( ExposureMask | StructureNotifyMask |
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   462
			 KeyPressMask | KeyReleaseMask |
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   463
			 EnterWindowMask | LeaveWindowMask |
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   464
			 ButtonPressMask | ButtonMotionMask | ButtonReleaseMask ));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   465
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   466
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   467
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   468
displayFileDescriptor
48194c26a46c Initial revision
claus
parents:
diff changeset
   469
    "return the displays fileNumber - for select"
48194c26a46c Initial revision
claus
parents:
diff changeset
   470
48194c26a46c Initial revision
claus
parents:
diff changeset
   471
%{  /* NOCONTEXT */
48194c26a46c Initial revision
claus
parents:
diff changeset
   472
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   473
    if (ISCONNECTED) {
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
   474
	RETURN ( __MKSMALLINT(ConnectionNumber(myDpy)) );
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   475
    }
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   476
    RETURN (nil);
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   477
%}
48194c26a46c Initial revision
claus
parents:
diff changeset
   478
!
48194c26a46c Initial revision
claus
parents:
diff changeset
   479
133
claus
parents: 132
diff changeset
   480
displayName
claus
parents: 132
diff changeset
   481
    "return the X-connections display name.
claus
parents: 132
diff changeset
   482
     This is (currently) nil for the default display, 
claus
parents: 132
diff changeset
   483
     something like foo:0 for any other remote display.
claus
parents: 132
diff changeset
   484
     Future versions may return non-nil strings for the default display as well."
claus
parents: 132
diff changeset
   485
claus
parents: 132
diff changeset
   486
    ^ displayName
claus
parents: 132
diff changeset
   487
!
claus
parents: 132
diff changeset
   488
341
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   489
protocolVersion
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   490
    "return the X-servers protocol version - should normally not be of
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   491
     any interest"
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   492
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   493
%{  /* NOCONTEXT */
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   494
    if (ISCONNECTED) {
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   495
	RETURN ( __MKSMALLINT(XProtocolVersion(myDpy)) );
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   496
    }
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   497
    RETURN (nil);
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   498
%}
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   499
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   500
    "
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   501
     Display protocolVersion
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   502
    "
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   503
!
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   504
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   505
rootView
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   506
    rootView isNil ifTrue:[
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   507
	rootView := DisplayRootView on:self
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   508
    ].
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   509
    ^ rootView
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   510
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   511
    "
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   512
     |v|
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   513
     v := Display rootView.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   514
     v paint:Color red.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   515
     v noClipByChildren.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   516
     v fillRectangleX:10 y:10 width:100 height:100.  
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   517
    "
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   518
!
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   519
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   520
serverVendor
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   521
    "return the X-server vendor string - this should normally not be of
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   522
     any interest, but can be for special cases
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   523
     (to avoid bugs in certain implementations)"
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   524
%{
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   525
    if (ISCONNECTED) {
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   526
	RETURN ( __MKSTRING(XServerVendor(myDpy) COMMA_CON) );
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   527
    }
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   528
    RETURN (nil);
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   529
%}
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   530
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   531
    "
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   532
     Display serverVendor
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   533
    "
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   534
!
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   535
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   536
translatePoint:aPoint from:windowId1 to:windowId2
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   537
    "given a point in window1, return the coordinate in window2.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   538
     This expects a device coordinate (relative to the first views origin)
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   539
     in aPoint and returns a device coordinate relative to the 2nd views origin.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   540
     - use to xlate points from a window to rootwindow"
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   541
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   542
    |x1 y1 x2 y2|
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   543
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   544
    x1 := x2 := aPoint x truncated.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   545
    y1 := y2 := aPoint y truncated.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   546
%{
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   547
    int xpos, ypos;
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   548
    Window w1, w2, child_return;
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   549
    int screen = _intVal(_INST(screen));
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   550
    Display *dpy = myDpy;
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   551
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   552
    if (__isExternalAddress(windowId1)
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   553
     && __isExternalAddress(windowId2)
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   554
     && __bothSmallInteger(x1, y1)) {
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   555
	w1 = _WindowVal(windowId1);
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   556
	w2 = _WindowVal(windowId2);
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   557
#ifdef VIRTUAL_ROOT
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   558
	if ((w1 == RootWindow(dpy, screen))
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   559
	 || (w2 == RootWindow(dpy, screen))) {
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   560
	    if (w1 == RootWindow(dpy, screen)) {
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   561
		w1 = getRootWindow(dpy, screen);
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   562
	    }
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   563
	    if (w2 == RootWindow(dpy, screen)) {
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   564
		w2 = getRootWindow(dpy, screen);
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   565
	    }
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   566
	}
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   567
#endif
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   568
	BEGIN_INTERRUPTSBLOCKED
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   569
	XTranslateCoordinates(dpy, w1, w2,
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   570
			      _intVal(x1), _intVal(y1), 
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   571
			      &xpos, &ypos, &child_return);
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   572
	END_INTERRUPTSBLOCKED
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   573
	x2 = __MKSMALLINT(xpos);
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   574
	y2 = __MKSMALLINT(ypos);
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   575
    }
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   576
%}.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   577
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   578
    ^ (x2 @ y2)
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   579
!
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   580
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   581
vendorRelease
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   582
    "return the X-servers vendor release - should normally not be of
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   583
     any interest, but can be for special cases.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   584
     (to avoid bugs in certain implementations)"
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   585
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   586
%{  /* NOCONTEXT */
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   587
    if (ISCONNECTED) {
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   588
	RETURN ( __MKSMALLINT(XVendorRelease(myDpy)) );
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   589
    }
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   590
    RETURN (nil);
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   591
%}
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   592
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   593
    "
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   594
     Display vendorRelease
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   595
    "
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   596
!
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   597
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   598
viewIdFromPoint:aPoint in:windowId
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   599
    "given a point in rootWindow, return the viewId of the subview of windowId
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   600
     hit by this coordinate. Return nil if no view was hit.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   601
     The returned id may be the id of a non ST view.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   602
     - used to find the window to drop objects after a cross-view drag."
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   603
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   604
%{  /* NOCONTEXT */
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   605
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   606
    Display *dpy = myDpy;
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   607
    int screen = _intVal(_INST(screen));
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   608
    OBJ xp, yp;
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   609
    int xpos, ypos;
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   610
    Window child_return;
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   611
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   612
    if (__isExternalAddress(windowId)
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   613
     && __isPoint(aPoint)) {
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   614
	xp = _point_X(aPoint);
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   615
	yp = _point_Y(aPoint);
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   616
	if (__bothSmallInteger(xp, yp)) {
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   617
	    BEGIN_INTERRUPTSBLOCKED
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   618
	    XTranslateCoordinates(dpy,
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   619
				  RootWindow(dpy, screen),
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   620
				  _WindowVal(windowId),
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   621
				  _intVal(xp), _intVal(yp), 
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   622
				  &xpos, &ypos, &child_return);
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   623
	    END_INTERRUPTSBLOCKED
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   624
	    if (child_return) {
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   625
		RETURN ( __MKOBJ(child_return) );
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   626
	    }
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   627
	    RETURN ( nil );
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   628
	}
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   629
    }
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   630
%}.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   631
    windowId notNil ifTrue:[
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   632
	aPoint isPoint ifTrue:[
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   633
	    ^ self viewIdFromPoint:aPoint asPoint truncated in:windowId
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   634
	]
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   635
    ].
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   636
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   637
    ^ nil
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   638
!
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   639
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   640
virtualExtent
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   641
    "return the virtual extent of the display (in pixels).
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   642
     On most systems, this is the same as the physical width;
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   643
     except, if a window manager with a virtual desktop like olvwm
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   644
     (simulating a bigger screen) is running."
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   645
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   646
%{
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   647
    if ((_INST(rootId) != _INST(virtualRootId)) 
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   648
     && __isExternalAddress(_INST(virtualRootId))) {
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   649
	Window vRootWin;
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   650
	Window root;
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   651
	int x, y;
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   652
	unsigned int width, height;
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   653
	unsigned int dummy;
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   654
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   655
	vRootWin = _WindowVal(_INST(virtualRootId));
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   656
	if (XGetGeometry(myDpy, vRootWin, &root, &x, &y, &width, &height,
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   657
					  &dummy, &dummy)) {
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   658
	    RETURN ( __MKPOINT_INT(width, height) );
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   659
	}
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   660
    }
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   661
%}.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   662
    ^ width @ height
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   663
!
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   664
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   665
whitepixel
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   666
    "return the colornumber of white"
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   667
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   668
    ^ whitepixel
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   669
! !
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   670
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   671
!XWorkstation methodsFor:'accessing display capabilities'!
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   672
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   673
hasDPS
186
claus
parents: 180
diff changeset
   674
    "return true, if this workstation supports display postscript.
claus
parents: 180
diff changeset
   675
     Both the server must support it, and the feature must have been
claus
parents: 180
diff changeset
   676
     enabled in the smalltalk system, for true to be returned."
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   677
48194c26a46c Initial revision
claus
parents:
diff changeset
   678
    ^ hasDPSExtension
186
claus
parents: 180
diff changeset
   679
claus
parents: 180
diff changeset
   680
    "
claus
parents: 180
diff changeset
   681
     Display hasDPS 
claus
parents: 180
diff changeset
   682
    "
claus
parents: 180
diff changeset
   683
!
claus
parents: 180
diff changeset
   684
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   685
hasExtension:extensionString
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   686
    "query for an X extension. The argument, extensionString
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   687
     should be the name of the extension (i.e. 'SHAPE', 'XInputExtension' etc).
186
claus
parents: 180
diff changeset
   688
     Return true, if that extension is available in the server.
claus
parents: 180
diff changeset
   689
     (which does not imply, that there is support in smalltalk for it."
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   690
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   691
%{
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   692
    int dummy;
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   693
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   694
    if (__isString(extensionString) && ISCONNECTED) {
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   695
	if (XQueryExtension(myDpy, __stringVal(extensionString), &dummy, &dummy, &dummy)) {
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   696
	    RETURN ( true );
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   697
	}
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   698
    }
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   699
%}.
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   700
    ^ false
186
claus
parents: 180
diff changeset
   701
claus
parents: 180
diff changeset
   702
    "
claus
parents: 180
diff changeset
   703
     Display hasExtension:'XVideo' 
claus
parents: 180
diff changeset
   704
     Display hasExtension:'Input' 
claus
parents: 180
diff changeset
   705
     Display hasExtension:'GLX' 
claus
parents: 180
diff changeset
   706
     Display hasExtension:'X3D-PEX' 
claus
parents: 180
diff changeset
   707
     Display hasExtension:'XInputExtension' 
claus
parents: 180
diff changeset
   708
     Display hasExtension:'SHAPE' 
claus
parents: 180
diff changeset
   709
     Display hasExtension:'MIT-SHM' 
claus
parents: 180
diff changeset
   710
     Display hasExtension:'SGIFullScreenStereo' 
claus
parents: 180
diff changeset
   711
    "
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   712
!
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   713
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   714
hasFax
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   715
    "return true, if this workstation supports decompression of fax images.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   716
     Both the server must support it, and the feature must have been
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   717
     enabled in the smalltalk system, for true to be returned."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   718
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   719
    ^ hasFaxExtension
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   720
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   721
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   722
     Display hasFaxExtension
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   723
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   724
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   725
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   726
hasImageExtension
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   727
    "return true, if this workstation supports the X image extension.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   728
     Both the server must support it, and the feature must have been
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   729
     enabled in the smalltalk system, for true to be returned."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   730
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   731
    ^ hasImageExtension
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   732
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   733
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   734
     Display hasImageExtension 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   735
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   736
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   737
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   738
hasInputExtension
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   739
    "return true, if this workstation supports the X input extension.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   740
     Both the server must support it, and the feature must have been
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   741
     enabled in the smalltalk system, for true to be returned."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   742
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   743
    ^ hasInputExtension
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   744
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   745
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   746
     Display hasInputExtension 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   747
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   748
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   749
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   750
hasMultibuffer
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   751
    "return true, if this workstation supports the multibuffer extension.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   752
     Both the server must support it, and the feature must have been
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   753
     enabled in the smalltalk system, for true to be returned."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   754
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   755
    ^ hasMbufExtension
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   756
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   757
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   758
     Display hasMultibuffer 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   759
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   760
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   761
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   762
hasPEX
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   763
    "return true, if this workstation supports PEX 3D graphics.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   764
     Both the server must support it, and the feature must have been
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   765
     enabled in the smalltalk system, for true to be returned."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   766
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   767
    ^ hasPEXExtension
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   768
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   769
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   770
     Display hasPEX 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   771
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   772
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   773
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   774
hasShape
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   775
    "return true, if this workstation supports non-rectangular windows.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   776
     Both the server must support it, and the feature must have been
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   777
     enabled in the smalltalk system, for true to be returned."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   778
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   779
    ^ hasShapeExtension
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   780
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   781
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   782
     Display hasShape   
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   783
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   784
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   785
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   786
hasShm
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   787
    "return true, if this workstation supports the shared pixmap extension.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   788
     Both the server must support it, and the feature must have been
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   789
     enabled in the smalltalk system, for true to be returned."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   790
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   791
    ^ hasShmExtension
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   792
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   793
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   794
     Display hasShm 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   795
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   796
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   797
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   798
hasXVideo
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   799
    "return true, if this workstation supports the XVideo extension.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   800
     Both the server must support it, and the feature must have been
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   801
     enabled in the smalltalk system, for true to be returned."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   802
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   803
    ^ hasXVideoExtension
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   804
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   805
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   806
     Display hasXVideo 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   807
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   808
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   809
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   810
iconSizes
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   811
    "Get the preferrer icon sizes. These are set by the window manager.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   812
     We return nil (if not set) or an OrderedCollection of Intervals."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   813
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   814
    |xIconSizes count ret|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   815
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   816
%{
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   817
    Display *dpy = myDpy;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   818
    int screen = _intVal(_INST(screen));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   819
    XIconSize *sizeList;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   820
    int cnt;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   821
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   822
    if (ISCONNECTED) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   823
	if (XGetIconSizes(myDpy, RootWindow(dpy, screen), &sizeList, &cnt) > 0) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   824
	   xIconSizes = __MKEXTERNALBYTES(sizeList);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   825
	   count = __MKSMALLINT(cnt);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   826
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   827
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   828
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   829
    xIconSizes isNil ifTrue:[^ nil].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   830
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   831
    ret := OrderedCollection new:count.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   832
    1 to:count do:[ :i |
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   833
	| startX startY stopX stopY stepX stepY|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   834
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   835
%{
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   836
	XIconSize *slp;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   837
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   838
	slp = &((XIconSize *)__externalBytesAddress(xIconSizes))[__intVal(i)-1];
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   839
	startX = __MKSMALLINT(slp->min_width);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   840
	startY = __MKSMALLINT(slp->min_height);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   841
	stopX = __MKSMALLINT(slp->max_width);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   842
	stopY = __MKSMALLINT(slp->max_height);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   843
	stepX = __MKSMALLINT(slp->width_inc);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   844
	stepY = __MKSMALLINT(slp->height_inc);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   845
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   846
	ret add:(Interval from:startX@startY to:stopX@stopY by:stepX@stepY)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   847
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   848
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   849
    xIconSizes free.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   850
    ^ ret
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   851
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   852
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   853
	Display iconSizes
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   854
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   855
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   856
341
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   857
ignoreBackingStore:aBoolean
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   858
    "if the argument is true, the views backingStore setting will be ignored, and
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   859
     no backing store used - this can be used on servers where backing store is
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   860
     very slow or is broken (can be put into display-rc-file)"
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   861
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   862
    ignoreBackingStore := aBoolean
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   863
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   864
43
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
   865
supportedImageFormats
235
579f3f804a46 padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents: 233
diff changeset
   866
    "return an array with supported image formats; 
579f3f804a46 padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents: 233
diff changeset
   867
     each array entry is an attribute dictionary, consisting of 
579f3f804a46 padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents: 233
diff changeset
   868
     depth, bitsPerPixel and padding values."
43
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
   869
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   870
    |nFormats "{ Class: SmallInteger }"
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   871
     formatArray|
43
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
   872
%{
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
   873
    Display *dpy = myDpy;
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   874
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   875
    if (! ISCONNECTED) {
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   876
	RETURN (nil);
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   877
    }
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   878
    nFormats = __MKSMALLINT(DISPLAYACCESS(dpy)->nformats);
43
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
   879
%}.
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
   880
    formatArray := Array new:nFormats.
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   881
    1 to:nFormats do:[:index |
235
579f3f804a46 padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents: 233
diff changeset
   882
	|info bitsPerPixelInfo depthInfo paddingInfo i|
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   883
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   884
	i := index.
43
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
   885
%{
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
   886
	ScreenFormat *format;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
   887
	Display *dpy = myDpy;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
   888
90
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   889
	format = DISPLAYACCESS(dpy)->pixmap_format;
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
   890
	format += (_intVal(i)-1);
235
579f3f804a46 padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents: 233
diff changeset
   891
	bitsPerPixelInfo = __MKSMALLINT(format->bits_per_pixel);
579f3f804a46 padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents: 233
diff changeset
   892
	depthInfo = __MKSMALLINT(format->depth);
579f3f804a46 padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents: 233
diff changeset
   893
	paddingInfo = __MKSMALLINT(format->scanline_pad);
43
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
   894
%}.
235
579f3f804a46 padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents: 233
diff changeset
   895
	info := IdentityDictionary new.
579f3f804a46 padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents: 233
diff changeset
   896
	info at:#depth put:depthInfo.
579f3f804a46 padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents: 233
diff changeset
   897
	info at:#bitsPerPixel put:bitsPerPixelInfo.
579f3f804a46 padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents: 233
diff changeset
   898
	info at:#padding put:paddingInfo.
579f3f804a46 padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents: 233
diff changeset
   899
	formatArray at:index put:info.
43
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
   900
    ].
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
   901
    ^ formatArray
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
   902
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
   903
    "
235
579f3f804a46 padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents: 233
diff changeset
   904
     Display supportedImageFormats 
43
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
   905
    "
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
   906
!
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
   907
81
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
   908
supportsDeepIcons
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
   909
    "return true, if this device supports non b&w (i.e. greyScale
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
   910
     or colored icons). Many Xservers (and/or windowManagers) crash,
186
claus
parents: 180
diff changeset
   911
     if you pass them a deep form as icon; therefore, we return false.
claus
parents: 180
diff changeset
   912
     It may be a good idea to check for the server vendor/release and
claus
parents: 180
diff changeset
   913
     return trie sometimes."
81
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
   914
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
   915
    ^ false
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
   916
!
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
   917
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
   918
supportsViewGravity
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
   919
    "return true, if this device supports gravity attributes.
82
98a70bce6d51 *** empty log message ***
claus
parents: 81
diff changeset
   920
     We do not depend on it being implemented, but some resizing operations
81
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
   921
     are faster, it is is."
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
   922
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
   923
    ^ true
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   924
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
   925
48194c26a46c Initial revision
claus
parents:
diff changeset
   926
!XWorkstation methodsFor:'bitmap/window creation'!
48194c26a46c Initial revision
claus
parents:
diff changeset
   927
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   928
createBitmapFromArray:anArray width:w height:h
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   929
    |bitmapId|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   930
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   931
    bitmapId := self primCreateBitmapFromArray:anArray width:w height:h.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   932
    bitmapId isNil ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   933
	self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   934
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   935
    ^ bitmapId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   936
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   937
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   938
createBitmapFromFile:aString for:aForm
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   939
    |id w h|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   940
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   941
%{
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   942
    Display *dpy = myDpy;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   943
    int screen = _intVal(_INST(screen));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   944
    Pixmap newBitmap;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   945
    char *filename;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   946
    unsigned b_width, b_height;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   947
    int b_x_hot, b_y_hot;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   948
    int status;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   949
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   950
    if (ISCONNECTED) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   951
	if (__isString(aString) || __isSymbol(aString)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   952
	    filename = (char *)_stringVal(aString);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   953
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   954
	    BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   955
	    status = XReadBitmapFile(dpy, RootWindow(dpy, screen),
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   956
				     filename, &b_width, &b_height, &newBitmap,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   957
				     &b_x_hot, &b_y_hot);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   958
	    END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   959
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   960
	    if (status == BitmapSuccess) {
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   961
		w = __MKSMALLINT(b_width);
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   962
		h = __MKSMALLINT(b_height);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   963
		id = __MKOBJ(newBitmap);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   964
	    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   965
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   966
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   967
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   968
    id notNil ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   969
	aForm setWidth:w height:h
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   970
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   971
    ^ id
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   972
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   973
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   974
createBitmapWidth:w height:h
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   975
    "allocate a bitmap on the Xserver, the contents is undefined
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   976
     (i.e. random). Return a bitmap id or nil"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   977
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   978
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   979
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   980
    Display *dpy = myDpy;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   981
    int screen = _intVal(_INST(screen));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   982
    Pixmap newBitmap;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   983
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   984
    if (__bothSmallInteger(w, h) && ISCONNECTED) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   985
	BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   986
	newBitmap = XCreatePixmap(dpy, RootWindow(dpy, screen),
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   987
				       _intVal(w), _intVal(h), 1);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   988
	END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   989
	RETURN ( (newBitmap != (Pixmap)0) ? __MKOBJ(newBitmap) : nil );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   990
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   991
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   992
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   993
    self primitiveFailed.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   994
    ^ nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   995
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   996
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   997
createFaxImageFromArray:data width:w height:h type:type k:k msbFirst:msbFirst
48194c26a46c Initial revision
claus
parents:
diff changeset
   998
    "create a new faxImage in the workstation
48194c26a46c Initial revision
claus
parents:
diff changeset
   999
     type: 0 -> uncompressed
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1000
	   1 -> group3 1D (k is void)
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1001
	   2 -> group3 2D
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1002
	   3 -> group4 2D (k is void)"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1003
48194c26a46c Initial revision
claus
parents:
diff changeset
  1004
    |nBytes|
48194c26a46c Initial revision
claus
parents:
diff changeset
  1005
48194c26a46c Initial revision
claus
parents:
diff changeset
  1006
    hasFaxExtension ifFalse:[^ nil].
48194c26a46c Initial revision
claus
parents:
diff changeset
  1007
    nBytes := data size.
48194c26a46c Initial revision
claus
parents:
diff changeset
  1008
%{
48194c26a46c Initial revision
claus
parents:
diff changeset
  1009
#ifdef FAX
48194c26a46c Initial revision
claus
parents:
diff changeset
  1010
    Display *dpy = myDpy;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1011
    int screen = _intVal(_INST(screen));
48194c26a46c Initial revision
claus
parents:
diff changeset
  1012
    FAXImage newImage;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1013
    int _type, _msb, _k = 0;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1014
    unsigned char *bits;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1015
97
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  1016
    if (__bothSmallInteger(w, h)
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  1017
     && __bothSmallInteger(type, k)
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  1018
     && __isSmallInteger(nBytes)
44
e45356abd276 *** empty log message ***
claus
parents: 43
diff changeset
  1019
     && __isByteArray(data)) {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1020
	if (msbFirst == true)
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1021
	    _msb = 1;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1022
	else
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1023
	    _msb = 0;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1024
	_type = _intVal(type);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1025
	if ((_type < 0) || (_type > 3)) {
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1026
	    RETURN ( nil );
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1027
	}
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1028
	if (_type == 2) {
97
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  1029
	    if (! __isSmallInteger(k)) {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1030
		RETURN ( nil );
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1031
	    }
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1032
	    _k = _intVal(k);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1033
	}
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1034
	bits =  _ByteArrayInstPtr(data)->ba_element;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1035
	BEGIN_INTERRUPTSBLOCKED
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1036
	newImage = XFAXImageCreateImage(dpy, _intVal(w), _intVal(h),
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1037
					_type, _k, _msb,
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1038
					_intVal(nBytes), bits);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1039
	END_INTERRUPTSBLOCKED
207
9124817bbb03 use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents: 206
diff changeset
  1040
	RETURN ( (newImage != (FAXImage)0) ? __MKOBJ(newImage) : nil );
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1041
    }
48194c26a46c Initial revision
claus
parents:
diff changeset
  1042
#else
48194c26a46c Initial revision
claus
parents:
diff changeset
  1043
    RETURN ( nil );
48194c26a46c Initial revision
claus
parents:
diff changeset
  1044
#endif
48194c26a46c Initial revision
claus
parents:
diff changeset
  1045
%}
48194c26a46c Initial revision
claus
parents:
diff changeset
  1046
.
43
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
  1047
    self primitiveFailed.
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
  1048
    ^ nil
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1049
!
48194c26a46c Initial revision
claus
parents:
diff changeset
  1050
48194c26a46c Initial revision
claus
parents:
diff changeset
  1051
createPixmapWidth:w height:h depth:d
48194c26a46c Initial revision
claus
parents:
diff changeset
  1052
    "allocate a pixmap on the Xserver, the contents is undefined
48194c26a46c Initial revision
claus
parents:
diff changeset
  1053
     (i.e. random). Return a bitmap id or nil"
48194c26a46c Initial revision
claus
parents:
diff changeset
  1054
48194c26a46c Initial revision
claus
parents:
diff changeset
  1055
%{  /* NOCONTEXT */
48194c26a46c Initial revision
claus
parents:
diff changeset
  1056
48194c26a46c Initial revision
claus
parents:
diff changeset
  1057
    Display *dpy = myDpy;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1058
    int screen = _intVal(_INST(screen));
48194c26a46c Initial revision
claus
parents:
diff changeset
  1059
    Pixmap newBitmap;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1060
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1061
    if (__bothSmallInteger(w, h) && ISCONNECTED) {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1062
	BEGIN_INTERRUPTSBLOCKED
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1063
	newBitmap = XCreatePixmap(dpy, RootWindow(dpy, screen),
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1064
				       _intVal(w), _intVal(h), _intVal(d));
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1065
	END_INTERRUPTSBLOCKED
207
9124817bbb03 use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents: 206
diff changeset
  1066
	RETURN ( (newBitmap != (Pixmap)0) ? __MKOBJ(newBitmap) : nil );
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1067
    }
48194c26a46c Initial revision
claus
parents:
diff changeset
  1068
%}
48194c26a46c Initial revision
claus
parents:
diff changeset
  1069
.
43
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
  1070
    self primitiveFailed.
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
  1071
    ^ nil
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1072
!
48194c26a46c Initial revision
claus
parents:
diff changeset
  1073
48194c26a46c Initial revision
claus
parents:
diff changeset
  1074
createWindowFor:aView left:xpos top:ypos width:wwidth height:wheight
46
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  1075
    "will vanish - for compatibility with previous versions"
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  1076
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  1077
    ^ self 
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1078
	  createWindowFor:aView 
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1079
	  origin:(xpos @ ypos)
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1080
	  extent:(wwidth @ wheight)
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1081
	  minExtent:(aView minExtent)
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1082
	  maxExtent:(aView maxExtent)
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1083
	  borderWidth:(aView borderWidth)
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1084
	  subViewOf:(aView superView)
157
claus
parents: 154
diff changeset
  1085
	  onTop:(aView isPopUpView)
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1086
	  inputOnly:(aView inputOnly)
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1087
	  label:(aView label)
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1088
	  cursor:(aView cursor)
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1089
	  icon:(aView icon)
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1090
	  iconView:(aView iconView)
46
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  1091
!
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  1092
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  1093
createWindowFor:aView
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1094
		 origin:origin
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1095
		 extent:extent
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1096
		 minExtent:minExt 
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1097
		 maxExtent:maxExt
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1098
		 borderWidth:bWidth
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1099
		 subViewOf:wsuperView
157
claus
parents: 154
diff changeset
  1100
		 onTop:wisPopUpView
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1101
		 inputOnly:winputOnly
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1102
		 label:wlabel
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1103
		 cursor:wcursor
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1104
		 icon:wicon
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1105
		 iconView:wiconView
46
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  1106
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  1107
    |xpos ypos wwidth wheight minWidth minHeight maxWidth maxHeight 
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  1108
     bColorId wsuperViewId wcursorId wiconId windowId
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  1109
     weventMask wiconViewId bitGravity viewGravity vBgColor
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1110
     vBgForm deepForm preferredVisual preferredDepth|
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1111
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1112
    displayId isNil ifTrue:[
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1113
	self primitiveFailed.
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1114
	^ nil
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1115
    ].
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1116
46
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  1117
    origin notNil ifTrue:[
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1118
	xpos := origin x.
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1119
	ypos := origin y.
46
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  1120
    ] ifFalse:[
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1121
	xpos := ypos := 0.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1122
    ].
46
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  1123
    extent notNil ifTrue:[
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1124
	wwidth := extent x.
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1125
	wheight := extent y.
46
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  1126
    ] ifFalse:[
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1127
	wwidth := wheight := 100.
46
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  1128
    ].
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  1129
    minExt notNil ifTrue:[
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1130
	minWidth := minExt x.
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1131
	minHeight := minExt y
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1132
    ].
46
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  1133
    maxExt notNil ifTrue:[
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1134
	maxWidth := maxExt x.
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1135
	maxHeight := maxExt y
46
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  1136
    ].
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  1137
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1138
    wsuperView notNil ifTrue:[
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1139
	wsuperViewId := wsuperView id
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1140
    ].
48194c26a46c Initial revision
claus
parents:
diff changeset
  1141
    wcursor isNil ifTrue:[
145
claus
parents: 144
diff changeset
  1142
	'XWORKSTATION: cursor nil - defaulted' errorPrintNL
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1143
    ] ifFalse:[
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1144
	wcursorId := wcursor id
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1145
    ].
48194c26a46c Initial revision
claus
parents:
diff changeset
  1146
48194c26a46c Initial revision
claus
parents:
diff changeset
  1147
    wicon notNil ifTrue:[
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1148
	wiconId := wicon id
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1149
    ].
48194c26a46c Initial revision
claus
parents:
diff changeset
  1150
    wiconView notNil ifTrue:[
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1151
	wiconViewId := wiconView id
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1152
    ].
48194c26a46c Initial revision
claus
parents:
diff changeset
  1153
    weventMask := aView eventMask.
48194c26a46c Initial revision
claus
parents:
diff changeset
  1154
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1155
    preferredVisual := aView preferredVisual.
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1156
    preferredDepth := aView preferredDepth.
23
4a7e02de7b72 *** empty log message ***
claus
parents: 21
diff changeset
  1157
72
3e84121988c3 *** empty log message ***
claus
parents: 70
diff changeset
  1158
%{  /* STACK:16000 */
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1159
    Display *dpy = myDpy;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1160
    int screen = _intVal(_INST(screen));
48194c26a46c Initial revision
claus
parents:
diff changeset
  1161
    Visual visual;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1162
    XGCValues xgcv;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1163
    XSetWindowAttributes xswa;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1164
    XSizeHints sizehints;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1165
    XWMHints wmhints;
46
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  1166
    int bw, bd, bg;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1167
    Window newWindow, parentWindow;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1168
    char *windowName;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1169
    XFontStruct *f;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1170
    Pixmap backPixmap = (Pixmap)0, iconBitmap = (Pixmap)0;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1171
    int flags = 0, depth, ioClass;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1172
    Window iconWindow;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1173
    Atom WmDeleteWindowAtom, WmSaveYourselfAtom, WmProtocolsAtom;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1174
    Atom WmQuitAppAtom;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1175
    Atom atoms[3];
48194c26a46c Initial revision
claus
parents:
diff changeset
  1176
    int atomCount = 0, isTopWindow = 0;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1177
48194c26a46c Initial revision
claus
parents:
diff changeset
  1178
    sizehints.flags = 0;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1179
    sizehints.width = 100;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1180
    sizehints.height = 100;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1181
    sizehints.x = 0;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1182
    sizehints.y = 0;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1183
97
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  1184
    if (__bothSmallInteger(wwidth, wheight)) {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1185
	sizehints.flags |= PSize;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1186
	sizehints.width = _intVal(wwidth);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1187
	sizehints.height = _intVal(wheight);
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1188
    }
97
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  1189
    if (__bothSmallInteger(xpos, ypos)) {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1190
	sizehints.flags |= PPosition;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1191
	sizehints.x = _intVal(xpos);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1192
	sizehints.y = _intVal(ypos);
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1193
    }
97
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  1194
    if (__bothSmallInteger(minWidth, minHeight)) {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1195
	sizehints.flags |= PMinSize;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1196
	sizehints.min_width = _intVal(minWidth);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1197
	sizehints.min_height = _intVal(minHeight);
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1198
    }
97
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  1199
    if (__bothSmallInteger(maxWidth, maxHeight)) {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1200
	sizehints.flags |= PMaxSize;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1201
	sizehints.max_width = _intVal(maxWidth);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1202
	sizehints.max_height = _intVal(maxHeight);
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1203
    }
48194c26a46c Initial revision
claus
parents:
diff changeset
  1204
37
c2dc1832c0f1 *** empty log message ***
claus
parents: 36
diff changeset
  1205
    bg = WhitePixel(dpy, screen);
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1206
97
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  1207
    if (__isSmallInteger(bWidth)) {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1208
	bw = _intVal(bWidth);
46
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  1209
    } else {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1210
	bw = 0;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1211
    }
48194c26a46c Initial revision
claus
parents:
diff changeset
  1212
72
3e84121988c3 *** empty log message ***
claus
parents: 70
diff changeset
  1213
    bd = BlackPixel(dpy, screen);
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  1214
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  1215
    if (__isExternalAddress(wsuperViewId)) {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1216
	parentWindow = _WindowVal(wsuperViewId);
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1217
    } else {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1218
	parentWindow = RootWindow(dpy, screen);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1219
	isTopWindow = 1;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1220
    }
48194c26a46c Initial revision
claus
parents:
diff changeset
  1221
157
claus
parents: 154
diff changeset
  1222
    if (wisPopUpView == true)
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1223
	xswa.override_redirect = 1;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1224
    else 
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1225
	xswa.override_redirect = 0;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1226
48194c26a46c Initial revision
claus
parents:
diff changeset
  1227
    if (winputOnly == true) 
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1228
	ioClass = InputOnly;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1229
    else 
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1230
	ioClass = InputOutput;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1231
97
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  1232
    if (__isSmallInteger(weventMask)) {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1233
	xswa.event_mask = _intVal(weventMask);
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1234
    } else {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1235
	xswa.event_mask = 0;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1236
    }
48194c26a46c Initial revision
claus
parents:
diff changeset
  1237
48194c26a46c Initial revision
claus
parents:
diff changeset
  1238
    if (ioClass == InputOnly) {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1239
	bw = 0;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1240
	depth = 0;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1241
	flags |= CWEventMask;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1242
    } else {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1243
	depth = DefaultDepth(dpy,screen);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1244
	flags |= CWEventMask | CWBorderPixel | CWOverrideRedirect;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1245
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1246
	if (backPixmap != (Pixmap)0) {
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1247
	    xswa.background_pixmap = backPixmap;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1248
	    flags |= CWBackPixmap;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1249
	} else {
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1250
	    xswa.background_pixel = bg;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1251
	    flags |= CWBackPixel;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1252
	}
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1253
	xswa.border_pixel = bd;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1254
    }
23
4a7e02de7b72 *** empty log message ***
claus
parents: 21
diff changeset
  1255
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1256
    visual.visualid = CopyFromParent;
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1257
    if (__isSmallInteger(preferredDepth)) {
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1258
	depth = _intVal(preferredDepth);
23
4a7e02de7b72 *** empty log message ***
claus
parents: 21
diff changeset
  1259
    }
54
29a6b2f8e042 *** empty log message ***
claus
parents: 46
diff changeset
  1260
29a6b2f8e042 *** empty log message ***
claus
parents: 46
diff changeset
  1261
    BEGIN_INTERRUPTSBLOCKED
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1262
    if (preferredVisual != nil) {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1263
	XVisualInfo vi;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1264
	int cls;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1265
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1266
	if (preferredVisual == @symbol(StaticGray))
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1267
	    cls = StaticGray;
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1268
	else if (preferredVisual == @symbol(GrayScale)) 
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1269
	    cls = StaticGray;
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1270
	else if (preferredVisual == @symbol(StaticColor)) 
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1271
	    cls = StaticColor;
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1272
	else if (preferredVisual == @symbol(PseudoColor)) 
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1273
	    cls = PseudoColor;
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1274
	else if (preferredVisual == @symbol(TrueColor)) 
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1275
	    cls = TrueColor;
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1276
	else if (preferredVisual == @symbol(DirectColor)) 
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1277
	    cls = DirectColor;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1278
	else
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1279
	    cls = PseudoColor;
200
aa66f76133ab New Method: atomName:
Stefan Vogel <sv@exept.de>
parents: 193
diff changeset
  1280
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1281
	if (XMatchVisualInfo(dpy, screen, depth, cls, &vi)) {
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1282
	    visual.visualid = vi.visualid;
163
claus
parents: 162
diff changeset
  1283
/*
claus
parents: 162
diff changeset
  1284
	    printf("visualId=%x\n", vi.visualid);
claus
parents: 162
diff changeset
  1285
*/
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1286
	}
23
4a7e02de7b72 *** empty log message ***
claus
parents: 21
diff changeset
  1287
    }
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1288
48194c26a46c Initial revision
claus
parents:
diff changeset
  1289
    newWindow = XCreateWindow(dpy, parentWindow,
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1290
			   sizehints.x, sizehints.y,
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1291
			   sizehints.width, sizehints.height,
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1292
			   bw, depth, ioClass, &visual,
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1293
			   flags, &xswa);
54
29a6b2f8e042 *** empty log message ***
claus
parents: 46
diff changeset
  1294
    END_INTERRUPTSBLOCKED
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1295
48194c26a46c Initial revision
claus
parents:
diff changeset
  1296
    if (! newWindow) {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1297
	RETURN ( nil );
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1298
    }
48194c26a46c Initial revision
claus
parents:
diff changeset
  1299
54
29a6b2f8e042 *** empty log message ***
claus
parents: 46
diff changeset
  1300
    BEGIN_INTERRUPTSBLOCKED
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1301
    /*
48194c26a46c Initial revision
claus
parents:
diff changeset
  1302
     * define its cursor
48194c26a46c Initial revision
claus
parents:
diff changeset
  1303
     */
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  1304
    if (__isExternalAddress(wcursorId)) {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1305
	XDefineCursor(dpy, newWindow, _CursorVal(wcursorId));
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1306
    }
48194c26a46c Initial revision
claus
parents:
diff changeset
  1307
48194c26a46c Initial revision
claus
parents:
diff changeset
  1308
    /*
48194c26a46c Initial revision
claus
parents:
diff changeset
  1309
     * define its icon and name
48194c26a46c Initial revision
claus
parents:
diff changeset
  1310
     * (only makes sense for topWindows)
48194c26a46c Initial revision
claus
parents:
diff changeset
  1311
     */
48194c26a46c Initial revision
claus
parents:
diff changeset
  1312
    if (isTopWindow) {
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  1313
	if (__isExternalAddress(wiconId))
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1314
	    iconBitmap = _PixmapVal(wiconId);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1315
	else
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1316
	    iconBitmap = (Pixmap)0;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1317
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  1318
	if (__isExternalAddress(wiconViewId))
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1319
	    iconWindow = _WindowVal(wiconViewId);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1320
	else
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1321
	    iconWindow = (Window)0;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1322
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1323
	if (__isString(wlabel) || __isSymbol(wlabel))
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1324
	    windowName = (char *)_stringVal(wlabel);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1325
	else
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1326
	    windowName = "";
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1327
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1328
	if (iconBitmap || windowName) {
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1329
	    XSetStandardProperties(dpy, newWindow,
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1330
					windowName, windowName,
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1331
					iconBitmap,
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1332
					0, 0, &sizehints);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1333
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1334
	}
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1335
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1336
	wmhints.flags = 0;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1337
	if (iconBitmap) {
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1338
	    wmhints.flags |= IconPixmapHint;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1339
	    wmhints.icon_pixmap = iconBitmap;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1340
	}
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1341
	if (iconWindow) {
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1342
	    wmhints.flags |= IconWindowHint;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1343
	    wmhints.icon_window = iconWindow;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1344
	}
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1345
/*
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1346
	wmhints.flags |= InputHint;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1347
	wmhints.input = True;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1348
*/
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1349
	XSetWMHints(dpy, newWindow, &wmhints);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1350
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1351
	/*
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1352
	 * tell window manager to not kill us but send an event instead
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1353
	 */
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1354
	/*
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1355
	 * get atoms first (if not already known)
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1356
	 */
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1357
	if (_INST(protocolsAtom) == nil) {
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1358
	    WmProtocolsAtom = XInternAtom(dpy, "WM_PROTOCOLS", False);
207
9124817bbb03 use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents: 206
diff changeset
  1359
	    _INST(protocolsAtom) = __MKATOMOBJ(WmProtocolsAtom);
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1360
#ifdef USE_SAVEYOURSELF_ATOM
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1361
	    WmSaveYourselfAtom = XInternAtom(dpy, "WM_SAVE_YOURSELF", False);
207
9124817bbb03 use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents: 206
diff changeset
  1362
	    _INST(saveYourselfAtom) = __MKATOMOBJ(WmSaveYourselfAtom);
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1363
#endif
48194c26a46c Initial revision
claus
parents:
diff changeset
  1364
#ifdef USE_QUIT_APP_ATOM
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1365
	    WmQuitAppAtom = XInternAtom(dpy, "_WM_QUIT_APP", False);
207
9124817bbb03 use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents: 206
diff changeset
  1366
	    _INST(quitAppAtom) = __MKATOMOBJ(WmQuitAppAtom);
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1367
#endif
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1368
	    WmDeleteWindowAtom = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
207
9124817bbb03 use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents: 206
diff changeset
  1369
	    _INST(deleteWindowAtom) = __MKATOMOBJ(WmDeleteWindowAtom);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1370
	} else {
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1371
#ifdef USE_QUIT_APP_ATOM
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  1372
	    WmQuitAppAtom = _AtomVal(_INST(quitAppAtom));
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1373
#else
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1374
	    WmQuitAppAtom = 0;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1375
#endif
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  1376
	    WmProtocolsAtom = _AtomVal(_INST(protocolsAtom));
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  1377
	    WmDeleteWindowAtom = _AtomVal(_INST(deleteWindowAtom));
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1378
#ifdef USE_SAVEYOURSELF_ATOM
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  1379
	    WmSaveYourselfAtom = _AtomVal(_INST(saveYourselfAtom));
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1380
#else
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1381
	    WmSaveYourselfAtom = 0;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1382
#endif
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1383
	}
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1384
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1385
	atoms[0] = WmDeleteWindowAtom; atomCount++;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1386
#ifdef USE_SAVEYOURSELF_ATOM
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1387
	atoms[atomCount] = WmSaveYourselfAtom; atomCount++;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1388
#endif
48194c26a46c Initial revision
claus
parents:
diff changeset
  1389
#ifdef USE_QUIT_APP_ATOM
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1390
	atoms[atomCount] = WmQuitAppAtom; atomCount++;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1391
#endif
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1392
	XChangeProperty(dpy, newWindow, WmProtocolsAtom, XA_ATOM,
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1393
			32, PropModeReplace, (unsigned char *)atoms, atomCount);
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1394
    }
48194c26a46c Initial revision
claus
parents:
diff changeset
  1395
54
29a6b2f8e042 *** empty log message ***
claus
parents: 46
diff changeset
  1396
    END_INTERRUPTSBLOCKED
29a6b2f8e042 *** empty log message ***
claus
parents: 46
diff changeset
  1397
207
9124817bbb03 use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents: 206
diff changeset
  1398
    windowId = __MKOBJ(newWindow);
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  1399
%}.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1400
    self addKnownView:aView withId:windowId.
48194c26a46c Initial revision
claus
parents:
diff changeset
  1401
    ^ windowId
48194c26a46c Initial revision
claus
parents:
diff changeset
  1402
!
48194c26a46c Initial revision
claus
parents:
diff changeset
  1403
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1404
destroyFaxImage:aFaxImageId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1405
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1406
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1407
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1408
#ifdef FAX
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1409
    if (__isExternalAddress(aFaxImageId)) {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1410
	BEGIN_INTERRUPTSBLOCKED
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1411
	XFAXImageFreeImage(myDpy, (FAXImage)_WindowVal(aFaxImageId));
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1412
	END_INTERRUPTSBLOCKED
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1413
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1414
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1415
#endif
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  1416
%}.
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1417
    self primitiveFailed
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1418
!
48194c26a46c Initial revision
claus
parents:
diff changeset
  1419
48194c26a46c Initial revision
claus
parents:
diff changeset
  1420
destroyGC:aGCId
48194c26a46c Initial revision
claus
parents:
diff changeset
  1421
48194c26a46c Initial revision
claus
parents:
diff changeset
  1422
%{  /* NOCONTEXT */
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  1423
    if (__isExternalAddress(aGCId) && ISCONNECTED) {
366
4783fabc35c0 validate GC before freeing
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
  1424
	GC gc = _GCVal(aGCId);
4783fabc35c0 validate GC before freeing
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
  1425
4783fabc35c0 validate GC before freeing
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
  1426
	if (gc) {
4783fabc35c0 validate GC before freeing
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
  1427
	    BEGIN_INTERRUPTSBLOCKED
4783fabc35c0 validate GC before freeing
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
  1428
	    XFreeGC(myDpy, gc);
4783fabc35c0 validate GC before freeing
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
  1429
	    END_INTERRUPTSBLOCKED
4783fabc35c0 validate GC before freeing
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
  1430
	}
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1431
	RETURN ( self );
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1432
    }
118
25e775072a89 *** empty log message ***
claus
parents: 115
diff changeset
  1433
%}.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1434
    self primitiveFailed
48194c26a46c Initial revision
claus
parents:
diff changeset
  1435
!
48194c26a46c Initial revision
claus
parents:
diff changeset
  1436
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1437
destroyPixmap:aDrawableId
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1438
48194c26a46c Initial revision
claus
parents:
diff changeset
  1439
%{  /* NOCONTEXT */
48194c26a46c Initial revision
claus
parents:
diff changeset
  1440
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  1441
    if (__isExternalAddress(aDrawableId) && ISCONNECTED) {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1442
	BEGIN_INTERRUPTSBLOCKED
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1443
	XFreePixmap(myDpy, _PixmapVal(aDrawableId));
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1444
	END_INTERRUPTSBLOCKED
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1445
	RETURN ( self );
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1446
    }
118
25e775072a89 *** empty log message ***
claus
parents: 115
diff changeset
  1447
%}.
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1448
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1449
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1450
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1451
destroyView:aView withId:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1452
%{
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1453
    if (__isExternalAddress(aWindowId) && ISCONNECTED) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1454
	BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1455
	XDestroyWindow(myDpy, _WindowVal(aWindowId));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1456
	END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1457
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1458
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1459
    self removeKnownView:aView
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1460
!
48194c26a46c Initial revision
claus
parents:
diff changeset
  1461
48194c26a46c Initial revision
claus
parents:
diff changeset
  1462
dpsContextFor:aDrawableId and:aGCId
48194c26a46c Initial revision
claus
parents:
diff changeset
  1463
48194c26a46c Initial revision
claus
parents:
diff changeset
  1464
%{  /* NOCONTEXT */
48194c26a46c Initial revision
claus
parents:
diff changeset
  1465
#ifdef XXDPS
48194c26a46c Initial revision
claus
parents:
diff changeset
  1466
    int screen = _intVal(_INST(screen));
48194c26a46c Initial revision
claus
parents:
diff changeset
  1467
    DPSContext dps;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1468
    int height;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1469
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  1470
    if (__isExternalAddress(aDrawableId)
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  1471
     && __isExternalAddress(aGCId)
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  1472
     && ISCONNECTED) {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1473
	BEGIN_INTERRUPTSBLOCKED
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1474
	dps = XDPSCreateContext(myDpy, (Drawable)_WindowVal(aDrawableId),
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1475
				       _GCVal(aGCId),
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1476
				       0, height, 0, colormap, NULL, 0,
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1477
				       XDPSDefaultTextBackstop,
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1478
				       XDPSDefaultErrorProc,
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1479
				       NULL);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1480
	END_INTERRUPTSBLOCKED
207
9124817bbb03 use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents: 206
diff changeset
  1481
	RETURN ( dps ? __MKOBJ(dps) : nil );
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1482
    }
48194c26a46c Initial revision
claus
parents:
diff changeset
  1483
#endif
48194c26a46c Initial revision
claus
parents:
diff changeset
  1484
%}
48194c26a46c Initial revision
claus
parents:
diff changeset
  1485
.
43
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
  1486
    self primitiveFailed.
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
  1487
    ^ nil
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1488
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1489
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1490
gcFor:aDrawableId
132
claus
parents: 129
diff changeset
  1491
claus
parents: 129
diff changeset
  1492
%{  /* NOCONTEXT */
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1493
    int screen = _intVal(_INST(screen));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1494
    GC gc;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1495
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1496
    if (__isExternalAddress(aDrawableId) && ISCONNECTED) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1497
	BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1498
	gc = XCreateGC(myDpy, (Drawable)_WindowVal(aDrawableId),
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1499
			      0L, (XGCValues *)0);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1500
	END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1501
	RETURN ( gc ? __MKOBJ(gc) : nil );
200
aa66f76133ab New Method: atomName:
Stefan Vogel <sv@exept.de>
parents: 193
diff changeset
  1502
    }
aa66f76133ab New Method: atomName:
Stefan Vogel <sv@exept.de>
parents: 193
diff changeset
  1503
%}.
aa66f76133ab New Method: atomName:
Stefan Vogel <sv@exept.de>
parents: 193
diff changeset
  1504
    self primitiveFailed.
aa66f76133ab New Method: atomName:
Stefan Vogel <sv@exept.de>
parents: 193
diff changeset
  1505
    ^ nil
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1506
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1507
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1508
primCreateBitmapFromArray:anArray width:w height:h
154
claus
parents: 153
diff changeset
  1509
claus
parents: 153
diff changeset
  1510
%{  /* UNLIMITEDSTACK */
claus
parents: 153
diff changeset
  1511
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1512
    Display *dpy = myDpy;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1513
    int screen = _intVal(_INST(screen));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1514
    Pixmap newBitmap;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1515
    unsigned int b_width, b_height;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1516
    REGISTER unsigned char *cp;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1517
    REGISTER unsigned char *pBits;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1518
    unsigned char *b_bits, *allocatedBits;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1519
    int index, row;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1520
    REGISTER int col;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1521
    unsigned bits;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1522
    static char reverseBitTable[256];
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1523
    static firstCall = 1;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1524
    int nBytes;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1525
    unsigned char fastBits[10000];
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1526
    OBJ num, *op;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1527
    int bytesPerRow;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1528
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1529
    if (firstCall) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1530
	for (index=0; index < 256; index++) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1531
	    reverseBitTable[index] = 0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1532
	    if (index & 128) reverseBitTable[index] |=   1;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1533
	    if (index &  64) reverseBitTable[index] |=   2;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1534
	    if (index &  32) reverseBitTable[index] |=   4;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1535
	    if (index &  16) reverseBitTable[index] |=   8;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1536
	    if (index &   8) reverseBitTable[index] |=  16;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1537
	    if (index &   4) reverseBitTable[index] |=  32;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1538
	    if (index &   2) reverseBitTable[index] |=  64;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1539
	    if (index &   1) reverseBitTable[index] |= 128;
154
claus
parents: 153
diff changeset
  1540
	}
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1541
	firstCall = 0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1542
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1543
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1544
    if (__bothSmallInteger(w, h) && _isNonNilObject(anArray)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1545
	b_width = _intVal(w);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1546
	b_height = _intVal(h);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1547
	bytesPerRow = (b_width + 7) / 8;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1548
	nBytes = b_height * bytesPerRow;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1549
	if (nBytes < sizeof(fastBits)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1550
	    cp = b_bits = fastBits;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1551
	    allocatedBits = 0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1552
	} else {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1553
	    cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1554
	    if (! cp) goto fail;
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1555
	}
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1556
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1557
	if (__qClass(anArray) == Array) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1558
	    index = 1;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1559
	    op = &(_ArrayInstPtr(anArray)->a_element[index - 1]);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1560
	    for (row = b_height; row; row--) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1561
		for (col = bytesPerRow; col; col--) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1562
		    num = *op++;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1563
		    if (! __isSmallInteger(num)) goto fail;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1564
		    bits = _intVal(num);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1565
		    *cp++ = reverseBitTable[bits];
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1566
		}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1567
	    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1568
	} else {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1569
	    if (__qClass(anArray) == ByteArray) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1570
		pBits = _ByteArrayInstPtr(anArray)->ba_element;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1571
		for (col = b_height*bytesPerRow; col; col--) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1572
		    *cp++ = reverseBitTable[*pBits++];
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1573
		}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1574
	    } else {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1575
		goto fail;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1576
	    }
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1577
	}
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1578
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1579
	BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1580
	newBitmap = XCreateBitmapFromData(dpy, RootWindow(dpy, screen),
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1581
					       (char *)b_bits, 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1582
					       b_width, b_height);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1583
	END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1584
fail: ;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1585
	if (allocatedBits)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1586
	    free(allocatedBits);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1587
	RETURN ( newBitmap ? __MKOBJ(newBitmap) : nil );
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1588
    }
48194c26a46c Initial revision
claus
parents:
diff changeset
  1589
%}
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1590
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1591
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1592
realRootWindowFor:aView
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1593
    "the name of this method is historic;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1594
     - it will vanish"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1595
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1596
    |id|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1597
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1598
    id := self realRootWindowId.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1599
    self addKnownView:aView withId:id.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1600
    ^ id
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1601
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1602
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1603
realRootWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1604
    "return the id of the real root window.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1605
     This may not be the window you see as background,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1606
     since some window managers install a virtual root window on top
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1607
     of it. Except for very special cases, use #rootWindowId, which takes
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1608
     care of any virtual root."
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1609
48194c26a46c Initial revision
claus
parents:
diff changeset
  1610
%{  /* NOCONTEXT */
48194c26a46c Initial revision
claus
parents:
diff changeset
  1611
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1612
    int screen = _intVal(_INST(screen));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1613
    Window root;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1614
    OBJ id;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1615
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1616
    if (_INST(rootId) != nil) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1617
	RETURN (_INST(rootId));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1618
    }
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1619
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1620
    if (ISCONNECTED) {
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1621
	root = RootWindow(myDpy, screen);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1622
	if (! root) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1623
	    id = nil;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1624
	} else {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1625
	    _INST(rootId) = id = __MKOBJ(root); __STORE(self, id);
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  1626
	}
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1627
	RETURN (id);
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  1628
    }
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  1629
%}.
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1630
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1631
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1632
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1633
rootWindowFor:aView
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1634
    |id|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1635
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1636
    id := self rootWindowId.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1637
    self addKnownView:aView withId:id.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1638
    ^ id
48194c26a46c Initial revision
claus
parents:
diff changeset
  1639
!
48194c26a46c Initial revision
claus
parents:
diff changeset
  1640
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1641
rootWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1642
    "return the id of the root window.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1643
     This is the window you see as background, 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1644
     however, it may or may not be the real physical root window,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1645
     since some window managers install a virtual root window on top
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1646
     of the real one. If this is the case, that views id is returned here."
23
4a7e02de7b72 *** empty log message ***
claus
parents: 21
diff changeset
  1647
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1648
%{  /* NOCONTEXT */
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1649
    int screen = _intVal(_INST(screen));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1650
    Window rootWin, vRootWin;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1651
    OBJ id;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1652
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1653
    if (_INST(virtualRootId) != nil) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1654
	RETURN (_INST(virtualRootId));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1655
    }
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1656
169
claus
parents: 168
diff changeset
  1657
    if (ISCONNECTED) {
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1658
	vRootWin = rootWin = RootWindow(myDpy, screen);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1659
#ifndef IRIS
180
claus
parents: 176
diff changeset
  1660
	BEGIN_INTERRUPTSBLOCKED
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1661
	/*
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1662
	 * on IRIS, this creates a badwindow error - why ?
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1663
	 * children contains a funny window (000034)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1664
	 */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1665
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1666
	/*
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1667
	 * care for virtual root windows (tvtwm & friends)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1668
	 */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1669
	{
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1670
	    Atom vRootAtom = None;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1671
	    int i;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1672
	    Window rootReturn, parentReturn;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1673
	    Window* children;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1674
	    unsigned int numChildren;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1675
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1676
	    if (XQueryTree(myDpy, rootWin, 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1677
			   &rootReturn, &parentReturn, 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1678
			   &children, &numChildren)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1679
		vRootAtom = XInternAtom(myDpy, "__SWM_VROOT", True );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1680
		if (vRootAtom != None) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1681
		    for (i=0; i < numChildren; i++) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1682
			Atom actual_type;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1683
			int actual_format;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1684
			unsigned long nitems, bytesafter;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1685
			Window* newRoot = (Window*) 0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1686
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1687
			if (children[i]) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1688
			    if (XGetWindowProperty(myDpy, children[i], vRootAtom, 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1689
						     0L, 1L, False, XA_WINDOW,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1690
						     &actual_type, &actual_format, 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1691
						     &nitems, &bytesafter,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1692
						     (unsigned char**) &newRoot
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1693
						   ) == Success && newRoot) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1694
				vRootWin = *newRoot;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1695
				break;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1696
			    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1697
			}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1698
		    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1699
		    if (children) XFree( children );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1700
		}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1701
	    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1702
	}
180
claus
parents: 176
diff changeset
  1703
	END_INTERRUPTSBLOCKED
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1704
#endif
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1705
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1706
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1707
    /* cannot happen */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1708
    if (! vRootWin) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1709
	vRootWin = rootWin;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1710
	if (! rootWin) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1711
	    RETURN ( nil );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1712
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1713
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1714
    _INST(rootId) = id = __MKOBJ(rootWin); __STORE(self, id);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1715
    _INST(virtualRootId) = id = __MKOBJ(vRootWin); __STORE(self, id);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1716
    RETURN ( id );
63
b9d17e2b6c92 keyRelease and more event masks
claus
parents: 55
diff changeset
  1717
%}
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1718
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
  1719
48194c26a46c Initial revision
claus
parents:
diff changeset
  1720
!XWorkstation methodsFor:'color stuff'!
48194c26a46c Initial revision
claus
parents:
diff changeset
  1721
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1722
colorCell
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1723
    "allocate a color cell - return index.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1724
     This method will return nil for StaticGrey and StaticGrey displays."
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1725
48194c26a46c Initial revision
claus
parents:
diff changeset
  1726
%{  /* NOCONTEXT */
48194c26a46c Initial revision
claus
parents:
diff changeset
  1727
48194c26a46c Initial revision
claus
parents:
diff changeset
  1728
    Display *dpy = myDpy;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1729
    int screen = _intVal(_INST(screen));
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1730
    XColor color;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1731
    unsigned long dummy;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1732
    Status ok;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1733
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1734
    BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1735
    ok = XAllocColorCells(dpy, DefaultColormap(dpy, screen), (Bool)0,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1736
			       &dummy, 0, &color.pixel, 1);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1737
    END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1738
    if (ok) {
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  1739
	RETURN ( __MKSMALLINT(color.pixel) );
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1740
    }
48194c26a46c Initial revision
claus
parents:
diff changeset
  1741
%}
48194c26a46c Initial revision
claus
parents:
diff changeset
  1742
.
43
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
  1743
    ^ nil
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1744
!
48194c26a46c Initial revision
claus
parents:
diff changeset
  1745
48194c26a46c Initial revision
claus
parents:
diff changeset
  1746
colorNamed:aString
48194c26a46c Initial revision
claus
parents:
diff changeset
  1747
    "allocate a color with color name - return index.
48194c26a46c Initial revision
claus
parents:
diff changeset
  1748
     Dont use this method, colornames are mostly X specific"
48194c26a46c Initial revision
claus
parents:
diff changeset
  1749
48194c26a46c Initial revision
claus
parents:
diff changeset
  1750
%{  /* NOCONTEXT */
48194c26a46c Initial revision
claus
parents:
diff changeset
  1751
48194c26a46c Initial revision
claus
parents:
diff changeset
  1752
    char *colorname;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1753
    Display *dpy = myDpy;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1754
    XColor scolor, ecolor;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1755
    int screen =_intVal(_INST(screen));
54
29a6b2f8e042 *** empty log message ***
claus
parents: 46
diff changeset
  1756
    Status ok;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1757
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1758
    if (ISCONNECTED) {
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1759
	if (__isString(aString) || __isSymbol(aString)) {
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1760
	    colorname = (char *)_stringVal(aString);
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1761
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1762
	    BEGIN_INTERRUPTSBLOCKED
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1763
	    ok = XParseColor(dpy, DefaultColormap(dpy, screen), colorname, &ecolor);
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1764
	    if (ok) {
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1765
		ok = XAllocColor(dpy, DefaultColormap(dpy, screen), &ecolor);
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1766
	    }
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1767
	    END_INTERRUPTSBLOCKED
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1768
	    if (! ok) {
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1769
		RETURN ( nil );
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1770
	    }
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  1771
	    RETURN ( __MKSMALLINT(ecolor.pixel) );
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1772
	}
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1773
    }
48194c26a46c Initial revision
claus
parents:
diff changeset
  1774
%}
48194c26a46c Initial revision
claus
parents:
diff changeset
  1775
.
43
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
  1776
    self primitiveFailed.
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
  1777
    ^ nil
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1778
!
48194c26a46c Initial revision
claus
parents:
diff changeset
  1779
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1780
colorRed:redVal green:greenVal blue:blueVal
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1781
    "allocate a color with rgb values (0..100) - return index"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1782
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1783
    |r g b|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1784
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1785
    r := self percentToXColorValue:redVal.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1786
    g := self percentToXColorValue:greenVal.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1787
    b := self percentToXColorValue:blueVal.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1788
%{
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1789
    Display *dpy = myDpy;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1790
    XColor ecolor;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1791
    int screen = _intVal(_INST(screen));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1792
    Status ok;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1793
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1794
    if (__bothSmallInteger(r, g) 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1795
     && __isSmallInteger(b)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1796
     && ISCONNECTED) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1797
	ecolor.red = _intVal(r);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1798
	ecolor.green= _intVal(g);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1799
	ecolor.blue = _intVal(b);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1800
	BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1801
	ok = XAllocColor(dpy, DefaultColormap(dpy, screen), &ecolor);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1802
	END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1803
	if (! ok) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1804
	    RETURN ( nil );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1805
	}
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  1806
	RETURN ( __MKSMALLINT(ecolor.pixel) );
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1807
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1808
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1809
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1810
    self primitiveFailed.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1811
    ^ nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1812
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1813
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1814
freeColor:colorIndex
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1815
    "free a display color when its no longer needed"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1816
48194c26a46c Initial revision
claus
parents:
diff changeset
  1817
%{  /* NOCONTEXT */
48194c26a46c Initial revision
claus
parents:
diff changeset
  1818
48194c26a46c Initial revision
claus
parents:
diff changeset
  1819
    Display *dpy = myDpy;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1820
    unsigned long color;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1821
    int screen = _intVal(_INST(screen));
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1822
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1823
#ifdef LATER
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1824
    if (_INST(visualType) == @symbol(TrueColor)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1825
	/* no need to do anything on TrueColor displays ... */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1826
	RETURN (self);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1827
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1828
#endif
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1829
    if (__isSmallInteger(colorIndex) && ISCONNECTED) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1830
	color = (long) _intVal(colorIndex);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1831
	BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1832
	XFreeColors(dpy, DefaultColormap(dpy, screen), &color, 1, 0L);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1833
	END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1834
	RETURN ( self );
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1835
    }
48194c26a46c Initial revision
claus
parents:
diff changeset
  1836
%}
48194c26a46c Initial revision
claus
parents:
diff changeset
  1837
.
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1838
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1839
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1840
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1841
getRGBFrom:index into:aBlock
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1842
    "get rgb components (0..100) of color in map at:index,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1843
     and evaluate the 3-arg block, aBlock with them"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1844
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1845
    |r g b|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1846
%{
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1847
    Display *dpy = myDpy;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1848
    int screen = _intVal(_INST(screen));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1849
    XColor color;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1850
    double fr, fg, fb;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1851
    double floor();
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1852
    int bits, scale, shift;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1853
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1854
    if (__isSmallInteger(index)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1855
	color.pixel = _intVal(index);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1856
	BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1857
	XQueryColor(dpy, DefaultColormap(dpy, screen), &color);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1858
	END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1859
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1860
	/* scale to 0..100 and round to the first decimal */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1861
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1862
	/* 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1863
	 * have to compensate for an error in X ?, which does not scale
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1864
	 * colors correctly if lesser than 16bits are valid in a color,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1865
	 * (for example, color white on a 4bitsPerRGB server will return
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1866
	 * (16rF000 16rF000 16rF000) instead of (16rFFFF 16rFFFF 16rFFFF)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1867
	 */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1868
	bits = _intVal(_INST(bitsPerRGB));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1869
	scale = (1<<bits) - 1;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1870
	shift = 16 - bits;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1871
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1872
	fr = floor( ( ((double)(color.red>>shift) * 1000.0) / scale) + 0.5) / 10.0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1873
	fg = floor( ( ((double)(color.green>>shift) * 1000.0) / scale) + 0.5) / 10.0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1874
	fb = floor( ( ((double)(color.blue>>shift) * 1000.0) / scale) + 0.5) / 10.0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1875
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  1876
	r = __MKFLOAT(fr COMMA_CON);
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  1877
	g = __MKFLOAT(fg COMMA_CON);
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  1878
	b = __MKFLOAT(fb COMMA_CON);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1879
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1880
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1881
    aBlock value:r value:g value:b
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1882
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1883
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1884
getRGBFromName:colorName into:aBlock
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1885
    "get rgb components (0..100) of color named colorName,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1886
     and evaluate the 3-arg block, aBlock with them"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1887
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1888
    |r g b|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1889
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1890
    displayId isNil ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1891
	self pimitiveFailed.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1892
	^ nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1893
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1894
%{
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1895
    Display *dpy = myDpy;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1896
    int screen = _intVal(_INST(screen));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1897
    XColor color;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1898
    double fr, fg, fb;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1899
    double floor();
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1900
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1901
    if (__isString(colorName) || __isSymbol(colorName)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1902
	BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1903
	if (XParseColor(dpy, DefaultColormap(dpy, screen), 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1904
			     (char *)_stringVal(colorName), &color)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1905
	    /* 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1906
	     * scale to 0..100 and round to the first decimal
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1907
	     */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1908
	    fr = floor( ((((double)color.red) * 1000.0) / 0xFFFF) + 0.5) / 10.0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1909
	    fg = floor( ((((double)color.green) * 1000.0) / 0xFFFF) + 0.5) / 10.0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1910
	    fb = floor( ((((double)color.blue) * 1000.0) / 0xFFFF) + 0.5) / 10.0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1911
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  1912
	    r = __MKFLOAT(fr COMMA_CON);
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  1913
	    g = __MKFLOAT(fg COMMA_CON);
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  1914
	    b = __MKFLOAT(fb COMMA_CON);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1915
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1916
	END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1917
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1918
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1919
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1920
    aBlock value:r value:g value:b
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1921
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1922
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1923
listOfAvailableColors
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1924
    "return a list of all available colornames.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1925
     This should not be used, since colornames are very
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1926
     display-specific (here X-specific)."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1927
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1928
    |aStream list line index colorName|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1929
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1930
    aStream := FileStream readonlyFileNamed:'/usr/lib/X11/rgb.txt'.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1931
    aStream isNil ifTrue:[^ nil].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1932
    list := OrderedCollection new.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1933
    [aStream atEnd] whileFalse:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1934
	line := aStream nextLine.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1935
	line notNil ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1936
	    "skip the r/g/b numbers"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1937
	    index := 1.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1938
	    [(line at:index) isDigit] whileTrue:[index := index + 1].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1939
	    [(line at:index) isSeparator] whileTrue:[index := index + 1].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1940
	    [(line at:index) isDigit] whileTrue:[index := index + 1].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1941
	    [(line at:index) isSeparator] whileTrue:[index := index + 1].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1942
	    [(line at:index) isDigit] whileTrue:[index := index + 1].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1943
	    [(line at:index) isSeparator] whileTrue:[index := index + 1].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1944
	    colorName := line copyFrom:index.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1945
	    ((colorName occurrencesOf:(Character space)) == 0) ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1946
		list add:colorName
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1947
	    ]
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1948
	]
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1949
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1950
    aStream close.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1951
    ^ list sort
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1952
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1953
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1954
percentToXColorValue:aPercentage
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1955
    "given a color-component value in percent (0..100), return the corresponding
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1956
     x-component value (0..65k) as an integer"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1957
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1958
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1959
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1960
    if (__isSmallInteger(aPercentage)) {
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  1961
	RETURN ( __MKSMALLINT(0xFFFF * _intVal(aPercentage) / 100) );
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1962
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1963
    if (__isFloat(aPercentage)) {
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  1964
	RETURN ( __MKSMALLINT(0xFFFF * (int)(_floatVal(aPercentage)) / 100) );
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1965
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1966
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1967
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1968
    ^ (16rFFFF * aPercentage / 100) rounded
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1969
!
48194c26a46c Initial revision
claus
parents:
diff changeset
  1970
48194c26a46c Initial revision
claus
parents:
diff changeset
  1971
setColor:index red:redVal green:greenVal blue:blueVal
48194c26a46c Initial revision
claus
parents:
diff changeset
  1972
    "change color in map at:index to rgb (0..100).
48194c26a46c Initial revision
claus
parents:
diff changeset
  1973
     This method is a noop for StaticGrey and StaticGrey displays."
48194c26a46c Initial revision
claus
parents:
diff changeset
  1974
48194c26a46c Initial revision
claus
parents:
diff changeset
  1975
%{  /* NOCONTEXT */
48194c26a46c Initial revision
claus
parents:
diff changeset
  1976
48194c26a46c Initial revision
claus
parents:
diff changeset
  1977
    char *colorname;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1978
    Display *dpy = myDpy;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1979
    XColor color;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1980
    int screen = _intVal(_INST(screen));
48194c26a46c Initial revision
claus
parents:
diff changeset
  1981
    int r, g, b;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1982
    int ok = 1;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1983
97
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  1984
    if (__isSmallInteger(redVal))
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1985
	r = 0xFFFF * _intVal(redVal) / 100;
36
b297468551c6 *** empty log message ***
claus
parents: 31
diff changeset
  1986
    else if (__isFloat(redVal))
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1987
	r = 0xFFFF * (int)(_floatVal(redVal)) / 100;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1988
    else ok = 0;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1989
97
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  1990
    if (__isSmallInteger(greenVal))
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1991
	g = 0xFFFF * _intVal(greenVal) / 100;
36
b297468551c6 *** empty log message ***
claus
parents: 31
diff changeset
  1992
    else if (__isFloat(greenVal))
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1993
	g = 0xFFFF * (int)(_floatVal(greenVal)) / 100;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1994
    else ok = 0;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1995
97
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  1996
    if (__isSmallInteger(blueVal))
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1997
	b = 0xFFFF * _intVal(blueVal) / 100;
36
b297468551c6 *** empty log message ***
claus
parents: 31
diff changeset
  1998
    else if (__isFloat(blueVal))
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1999
	b = 0xFFFF * (int)(_floatVal(blueVal)) / 100;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2000
    else ok = 0;
48194c26a46c Initial revision
claus
parents:
diff changeset
  2001
97
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  2002
    if (__isSmallInteger(index) && ok) {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2003
	color.pixel = _intVal(index);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2004
	color.red = r;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2005
	color.green = g;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2006
	color.blue = b;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2007
	color.flags = DoRed | DoGreen | DoBlue;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2008
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2009
	BEGIN_INTERRUPTSBLOCKED
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2010
	XStoreColor(dpy, DefaultColormap(dpy, screen), &color);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2011
	END_INTERRUPTSBLOCKED
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2012
	RETURN ( self );
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2013
    }
48194c26a46c Initial revision
claus
parents:
diff changeset
  2014
%}
48194c26a46c Initial revision
claus
parents:
diff changeset
  2015
.
48194c26a46c Initial revision
claus
parents:
diff changeset
  2016
    self primitiveFailed
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2017
! !
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2018
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2019
!XWorkstation methodsFor:'cursor stuff'!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2020
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2021
colorCursor:aCursorId foreground:fgColor background:bgColor
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2022
    "change a cursors colors"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2023
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2024
    |fgR fgG fgB bgR bgG bgB|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2025
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2026
    fgR := fgColor red.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2027
    fgG := fgColor green.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2028
    fgB := fgColor blue.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2029
    bgR := bgColor red.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2030
    bgG := bgColor green.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2031
    bgB := bgColor blue.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2032
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2033
    fgR := self percentToXColorValue:fgR.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2034
    fgG := self percentToXColorValue:fgG.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2035
    fgB := self percentToXColorValue:fgB.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2036
    bgR := self percentToXColorValue:bgR.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2037
    bgG := self percentToXColorValue:bgG.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2038
    bgB := self percentToXColorValue:bgB.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2039
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2040
%{
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2041
    XColor fgcolor, bgcolor;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2042
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2043
    if (__isExternalAddress(aCursorId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2044
     && __bothSmallInteger(fgG, fgB)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2045
     && __bothSmallInteger(bgR, bgG) 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2046
     && __bothSmallInteger(bgB, fgR)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2047
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2048
	fgcolor.red = _intVal(fgR);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2049
	fgcolor.green= _intVal(fgG);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2050
	fgcolor.blue = _intVal(fgB);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2051
	bgcolor.red = _intVal(bgR);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2052
	bgcolor.green= _intVal(bgG);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2053
	bgcolor.blue = _intVal(bgB);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2054
	BEGIN_INTERRUPTSBLOCKED
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2055
	XRecolorCursor(myDpy, _CursorVal(aCursorId), &fgcolor, &bgcolor);
72
3e84121988c3 *** empty log message ***
claus
parents: 70
diff changeset
  2056
	END_INTERRUPTSBLOCKED
3e84121988c3 *** empty log message ***
claus
parents: 70
diff changeset
  2057
	RETURN ( self );
3e84121988c3 *** empty log message ***
claus
parents: 70
diff changeset
  2058
    }
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2059
%}
48194c26a46c Initial revision
claus
parents:
diff changeset
  2060
.
48194c26a46c Initial revision
claus
parents:
diff changeset
  2061
    self primitiveFailed
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2062
!
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2063
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2064
createCursorShape:aShape
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2065
    "create a cursor given a shape-symbol"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2066
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2067
    |number id|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2068
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2069
    displayId isNil ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2070
	self primitiveFailed.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2071
	^ nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2072
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2073
    number := self shapeNumberFromSymbol:aShape.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2074
%{
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2075
    Cursor newCursor;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2076
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2077
    if (__isSmallInteger(number)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2078
	BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2079
	newCursor = XCreateFontCursor(myDpy, _intVal(number));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2080
	END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2081
	if (newCursor != (Cursor)0) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2082
	    id = __MKOBJ(newCursor);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2083
	}
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2084
    }
288
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  2085
%}.
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2086
    ^ id
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2087
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2088
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2089
createCursorSourceForm:sourceForm maskForm:maskForm hotX:hx hotY:hy
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2090
    "create a cursor given 2 bitmaps (source, mask) and a hotspot"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2091
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2092
    |id sourceId maskId|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2093
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2094
    displayId isNil ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2095
	self primitiveFailed.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2096
	^ nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2097
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2098
    sourceId := sourceForm id.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2099
    maskId := maskForm id.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2100
%{
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2101
    Cursor newCursor;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2102
    XColor fgColor, bgColor;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2103
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2104
    if (__isExternalAddress(sourceId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2105
     && __isExternalAddress(maskId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2106
     && __bothSmallInteger(hx, hy)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2107
	fgColor.red = 0;        /* fg is black */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2108
	fgColor.green = 0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2109
	fgColor.blue = 0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2110
	bgColor.red = 0xFFFF;   /* bg is white */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2111
	bgColor.green = 0xFFFF;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2112
	bgColor.blue = 0xFFFF;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2113
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2114
	BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2115
	newCursor = XCreatePixmapCursor(myDpy,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2116
				_PixmapVal(sourceId),
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2117
				_PixmapVal(maskId),
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2118
				&fgColor, &bgColor, _intVal(hx), _intVal(hy));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2119
	END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2120
	if (newCursor != (Cursor)0) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2121
	    id = __MKOBJ(newCursor);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2122
	}
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2123
    }
288
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  2124
%}.
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2125
    ^ id
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2126
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2127
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2128
destroyCursor:aCursorId
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2129
48194c26a46c Initial revision
claus
parents:
diff changeset
  2130
%{  /* NOCONTEXT */
48194c26a46c Initial revision
claus
parents:
diff changeset
  2131
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2132
    if (ISCONNECTED) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2133
	if (__isExternalAddress(aCursorId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2134
	    BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2135
	    XFreeCursor(myDpy, _CursorVal(aCursorId));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2136
	    END_INTERRUPTSBLOCKED
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2137
	    RETURN ( self );
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2138
	}
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2139
    }
48194c26a46c Initial revision
claus
parents:
diff changeset
  2140
%}
48194c26a46c Initial revision
claus
parents:
diff changeset
  2141
.
48194c26a46c Initial revision
claus
parents:
diff changeset
  2142
    self primitiveFailed
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2143
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2144
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2145
shapeNumberFromSymbol:shape
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2146
    "given a shape-symbol, return the corresponding cursor-number"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2147
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2148
    "this is pure X-knowlegde - but you may easily add more"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2149
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2150
    (shape == #upLeftArrow)     ifTrue:[ ^ %{ __MKSMALLINT(XC_top_left_arrow)    %} "132" ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2151
    (shape == #upRightHand)     ifTrue:[ ^ %{ __MKSMALLINT(XC_hand1)             %} "58" ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2152
    (shape == #upDownArrow)     ifTrue:[ ^ %{ __MKSMALLINT(XC_sb_v_double_arrow) %} "116" ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2153
    (shape == #leftRightArrow)  ifTrue:[ ^ %{ __MKSMALLINT(XC_sb_h_double_arrow) %} "108" ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2154
    (shape == #upLimitArrow)    ifTrue:[ ^ %{ __MKSMALLINT(XC_top_side)          %} "138" ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2155
    (shape == #downLimitArrow)  ifTrue:[ ^ %{ __MKSMALLINT(XC_bottom_side)       %} "16" ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2156
    (shape == #leftLimitArrow)  ifTrue:[ ^ %{ __MKSMALLINT(XC_left_side)         %} "70" ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2157
    (shape == #rightLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_right_side)        %} "96" ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2158
    (shape == #text)            ifTrue:[ ^ %{ __MKSMALLINT(XC_xterm)             %} "152" ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2159
    (shape == #upRightArrow)    ifTrue:[ ^ %{ __MKSMALLINT(XC_draft_large)       %} "44" ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2160
    (shape == #leftHand)        ifTrue:[ ^ %{ __MKSMALLINT(XC_hand2)             %} "60" ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2161
    (shape == #questionMark)    ifTrue:[ ^ %{ __MKSMALLINT(XC_question_arrow)    %} "92" ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2162
    (shape == #cross)           ifTrue:[ ^ %{ __MKSMALLINT(XC_X_cursor)          %} "0" ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2163
    (shape == #wait)            ifTrue:[ ^ %{ __MKSMALLINT(XC_watch)             %} "150" ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2164
    (shape == #crossHair)       ifTrue:[ ^ %{ __MKSMALLINT(XC_tcross)            %} "130" ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2165
    ((shape == #origin)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2166
    or:[shape == #topLeft])     ifTrue:[ ^ %{ __MKSMALLINT(XC_ul_angle)          %} "144" ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2167
    ((shape == #corner)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2168
    or:[shape == #bottomRight]) ifTrue:[ ^ %{ __MKSMALLINT(XC_lr_angle)          %} "78" ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2169
    (shape == #topRight)        ifTrue:[ ^ %{ __MKSMALLINT(XC_ur_angle)          %} "148" ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2170
    (shape == #bottomLeft)      ifTrue:[ ^ %{ __MKSMALLINT(XC_ll_angle)          %} "76" ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2171
    (shape == #square)          ifTrue:[ ^ %{ __MKSMALLINT(XC_dotbox)            %} "40" ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2172
    (shape == #fourWay)         ifTrue:[ ^ %{ __MKSMALLINT(XC_fleur)             %} "52" ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2173
    (shape == #crossCursor)     ifTrue:[ ^ %{ __MKSMALLINT(XC_X_cursor)          %} "0" ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2174
    ('XWORKSTATION: invalid cursorShape:' , shape printString) errorPrintNL.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2175
    ^  0
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2176
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
  2177
48194c26a46c Initial revision
claus
parents:
diff changeset
  2178
!XWorkstation methodsFor:'drawing'!
48194c26a46c Initial revision
claus
parents:
diff changeset
  2179
48194c26a46c Initial revision
claus
parents:
diff changeset
  2180
copyFromFaxImage:sourceId x:srcX y:srcY to:destId x:dstX y:dstY 
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2181
		      width:w height:h with:aGCId scaleX:scaleX scaleY:scaleY
12
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2182
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2183
    "do a bit-blt of a compressed FAX image 
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2184
     - this needs my private FAX extension"
132
claus
parents: 129
diff changeset
  2185
claus
parents: 129
diff changeset
  2186
%{  /* NOCONTEXT */
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2187
#ifdef FAX
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2188
    GC gc;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2189
    FAXImage source;
48194c26a46c Initial revision
claus
parents:
diff changeset
  2190
    Drawable dest;
48194c26a46c Initial revision
claus
parents:
diff changeset
  2191
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  2192
    if (__isExternalAddress(aGCId)
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  2193
     && __isExternalAddress(sourceId)
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  2194
     && __isExternalAddress(destId)
97
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  2195
     && __bothSmallInteger(scaleX, scaleY)
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  2196
     && __bothSmallInteger(w, h)
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  2197
     && __bothSmallInteger(srcX, srcY)
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  2198
     && __bothSmallInteger(dstX, dstY)) {
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2199
	gc = _GCVal(aGCId);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2200
	source = (FAXImage) _WindowVal(sourceId);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2201
	dest = (Drawable) _WindowVal(destId);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2202
	XFAXImageCopyImage(myDpy, source, dest, gc,
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2203
				_intVal(srcX), _intVal(srcY),
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2204
				_intVal(w), _intVal(h),
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2205
				_intVal(dstX), _intVal(dstY),
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2206
				_intVal(scaleX), _intVal(scaleY));
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2207
	RETURN ( self );
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2208
    }
48194c26a46c Initial revision
claus
parents:
diff changeset
  2209
#endif
118
25e775072a89 *** empty log message ***
claus
parents: 115
diff changeset
  2210
%}.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2211
    self primitiveFailed
48194c26a46c Initial revision
claus
parents:
diff changeset
  2212
!
48194c26a46c Initial revision
claus
parents:
diff changeset
  2213
48194c26a46c Initial revision
claus
parents:
diff changeset
  2214
copyFromId:sourceId x:srcX y:srcY to:destId x:dstX y:dstY 
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2215
		width:w height:h with:aGCId
118
25e775072a89 *** empty log message ***
claus
parents: 115
diff changeset
  2216
    "do a bit-blt; copy bits from the rectangle defined by
25e775072a89 *** empty log message ***
claus
parents: 115
diff changeset
  2217
     srcX/srcY and w/h from the sourceId drawable to the rectangle
25e775072a89 *** empty log message ***
claus
parents: 115
diff changeset
  2218
     below dstX/dstY in the destId drawable. Trigger an error if any
25e775072a89 *** empty log message ***
claus
parents: 115
diff changeset
  2219
     argument is not integer."
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2220
48194c26a46c Initial revision
claus
parents:
diff changeset
  2221
%{  /* NOCONTEXT */
48194c26a46c Initial revision
claus
parents:
diff changeset
  2222
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2223
    GC gc;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2224
    Drawable source, dest;
48194c26a46c Initial revision
claus
parents:
diff changeset
  2225
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  2226
    if (__isExternalAddress(aGCId)
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  2227
     && __isExternalAddress(sourceId)
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  2228
     && __isExternalAddress(destId)
97
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  2229
     && __bothSmallInteger(w, h)
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  2230
     && __bothSmallInteger(srcX, srcY)
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  2231
     && __bothSmallInteger(dstX, dstY)) {
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2232
	gc = _GCVal(aGCId);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2233
	source = (Drawable) _WindowVal(sourceId);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2234
	dest = (Drawable) _WindowVal(destId);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2235
	XCopyArea(myDpy, source, dest, gc,
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2236
				 _intVal(srcX), _intVal(srcY),
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2237
				_intVal(w), _intVal(h),
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2238
				_intVal(dstX), _intVal(dstY));
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2239
	RETURN ( self );
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2240
    }
118
25e775072a89 *** empty log message ***
claus
parents: 115
diff changeset
  2241
%}.
25e775072a89 *** empty log message ***
claus
parents: 115
diff changeset
  2242
    "badGC, bad sourceDrawableId or destDrawableID
25e775072a89 *** empty log message ***
claus
parents: 115
diff changeset
  2243
     or any non integer coordinate"
25e775072a89 *** empty log message ***
claus
parents: 115
diff changeset
  2244
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2245
    self primitiveFailed
48194c26a46c Initial revision
claus
parents:
diff changeset
  2246
!
48194c26a46c Initial revision
claus
parents:
diff changeset
  2247
48194c26a46c Initial revision
claus
parents:
diff changeset
  2248
copyPlaneFromId:sourceId x:srcX y:srcY to:destId x:dstX y:dstY 
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2249
		width:w height:h with:aGCId
118
25e775072a89 *** empty log message ***
claus
parents: 115
diff changeset
  2250
    "do a bit-blt, but only copy the low-bit plane; 
25e775072a89 *** empty log message ***
claus
parents: 115
diff changeset
  2251
     copy bits from the rectangle defined by
25e775072a89 *** empty log message ***
claus
parents: 115
diff changeset
  2252
     srcX/srcY and w/h from the sourceId drawable to the rectangle
25e775072a89 *** empty log message ***
claus
parents: 115
diff changeset
  2253
     below dstX/dstY in the destId drawable. Trigger an error if any
25e775072a89 *** empty log message ***
claus
parents: 115
diff changeset
  2254
     argument is not integer."
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2255
48194c26a46c Initial revision
claus
parents:
diff changeset
  2256
%{  /* NOCONTEXT */
48194c26a46c Initial revision
claus
parents:
diff changeset
  2257
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2258
    GC gc;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2259
    Drawable source, dest;
48194c26a46c Initial revision
claus
parents:
diff changeset
  2260
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  2261
    if (__isExternalAddress(aGCId)
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  2262
     && __isExternalAddress(sourceId)
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  2263
     && __isExternalAddress(destId)
97
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  2264
     && __bothSmallInteger(w, h)
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  2265
     && __bothSmallInteger(srcX, srcY)
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  2266
     && __bothSmallInteger(dstX, dstY)) {
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2267
	gc = _GCVal(aGCId);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2268
	source = (Drawable) _WindowVal(sourceId);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2269
	dest = (Drawable) _WindowVal(destId);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2270
	XCopyPlane(myDpy, source, dest, gc,
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2271
				 _intVal(srcX), _intVal(srcY),
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2272
				 _intVal(w), _intVal(h),
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2273
				 _intVal(dstX), _intVal(dstY), 1);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2274
	RETURN ( self );
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2275
    }
118
25e775072a89 *** empty log message ***
claus
parents: 115
diff changeset
  2276
%}.
25e775072a89 *** empty log message ***
claus
parents: 115
diff changeset
  2277
    "badGC, bad sourceDrawableId or destDrawableID
25e775072a89 *** empty log message ***
claus
parents: 115
diff changeset
  2278
     or any non integer coordinate"
25e775072a89 *** empty log message ***
claus
parents: 115
diff changeset
  2279
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2280
    self primitiveFailed
48194c26a46c Initial revision
claus
parents:
diff changeset
  2281
!
48194c26a46c Initial revision
claus
parents:
diff changeset
  2282
73
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2283
displayArcX:x y:y w:width h:height from:startAngle angle:angle in:aDrawableId with:aGCId
90
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
  2284
    "draw an arc. If any of x,y, w or h is not an integer, an error is triggered.
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
  2285
     The angles may be floats or integer - they are given in degrees."
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2286
48194c26a46c Initial revision
claus
parents:
diff changeset
  2287
%{  /* NOCONTEXT */
48194c26a46c Initial revision
claus
parents:
diff changeset
  2288
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2289
    GC gc;
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2290
    Window win;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2291
    int w, h, angle1, angle2;
48194c26a46c Initial revision
claus
parents:
diff changeset
  2292
    double f;
48194c26a46c Initial revision
claus
parents:
diff changeset
  2293
97
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  2294
    if (__isSmallInteger(startAngle))
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2295
	angle1 = _intVal(startAngle) * 64;
36
b297468551c6 *** empty log message ***
claus
parents: 31
diff changeset
  2296
    else if (__isFloat(startAngle)) {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2297
	f = _floatVal(startAngle);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2298
	angle1 = f * 64;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2299
    }
97
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  2300
    if (__isSmallInteger(angle))
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2301
	angle2 = _intVal(angle) * 64;
36
b297468551c6 *** empty log message ***
claus
parents: 31
diff changeset
  2302
    else if (__isFloat(angle)) {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2303
	f = _floatVal(angle);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2304
	angle2 = f * 64;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2305
    }
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  2306
    if (__isExternalAddress(aGCId)
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  2307
     && __isExternalAddress(aDrawableId)
97
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  2308
     && __bothSmallInteger(x, y)
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  2309
     && __bothSmallInteger(width, height)) {
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2310
	win = _WindowVal(aDrawableId);
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2311
	gc = _GCVal(aGCId);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2312
	w = _intVal(width);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2313
	h = _intVal(height);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2314
	/*
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2315
	 * need this check here: some servers simply dump core with bad args
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2316
	 */
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2317
	if ((w >= 0) && (h >= 0) && (angle1 >= 0) && (angle2 >= 0)) {
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2318
	    XDrawArc(myDpy, win, gc, _intVal(x), _intVal(y),
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2319
				   w, h, angle1, angle2);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2320
	}
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2321
	RETURN ( self );
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2322
    }
73
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2323
%}.
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2324
    "badGC, badDrawable or coordinates not integer"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2325
    self primitiveFailed
48194c26a46c Initial revision
claus
parents:
diff changeset
  2326
!
48194c26a46c Initial revision
claus
parents:
diff changeset
  2327
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2328
displayLineFromX:x0 y:y0 toX:x1 y:y1 in:aDrawableId with:aGCId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2329
    "draw a line. If the coordinates are not integers, an error is triggered." 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2330
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2331
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2332
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2333
    GC gc;
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2334
    Window win;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2335
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2336
    if (__isExternalAddress(aGCId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2337
     && __isExternalAddress(aDrawableId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2338
     && __bothSmallInteger(x0, y0)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2339
     && __bothSmallInteger(x1, y1)) {
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2340
	gc = _GCVal(aGCId);
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2341
	win = _WindowVal(aDrawableId);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2342
	XDrawLine(myDpy, win, gc, _intVal(x0), _intVal(y0),
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2343
				  _intVal(x1), _intVal(y1));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2344
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2345
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2346
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2347
    "badGC, badDrawable or coordinates not integer"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2348
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2349
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2350
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2351
displayPointX:x y:y in:aDrawableId with:aGCId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2352
    "draw a point. If x/y are not integers, an error is triggered." 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2353
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2354
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2355
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2356
    GC gc;
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2357
    Window win;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2358
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2359
    if (__isExternalAddress(aGCId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2360
     && __isExternalAddress(aDrawableId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2361
     && __bothSmallInteger(x, y)) {
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2362
	gc = _GCVal(aGCId);
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2363
	win = _WindowVal(aDrawableId);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2364
	XDrawPoint(myDpy, win, gc, _intVal(x), _intVal(y));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2365
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2366
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2367
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2368
    "badGC, badDrawable or x/y not integer"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2369
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2370
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2371
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2372
displayPolygon:aPolygon in:aDrawableId with:aGCId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2373
    "draw a polygon, the argument aPolygon is a Collection of individual points, which
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2374
     define the polygon.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2375
     If any coordinate is not integer, an error is triggered."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2376
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2377
    |numberOfPoints newPoints|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2378
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2379
    numberOfPoints := aPolygon size.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2380
%{
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2381
    GC gc;
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2382
    Window win;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2383
    OBJ point, x, y;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2384
    int i, num;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2385
    XPoint *points;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2386
    XPoint qPoints[100];
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2387
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2388
    if (__isExternalAddress(aGCId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2389
     && __isExternalAddress(aDrawableId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2390
     && __isSmallInteger(numberOfPoints)) {
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2391
	gc = _GCVal(aGCId);
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2392
	win = _WindowVal(aDrawableId);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2393
	num = _intVal(numberOfPoints);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2394
	/*
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2395
	 * avoid a (slow) malloc, if the number of points is small
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2396
	 */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2397
	if (num > 100) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2398
	    points = (XPoint *)malloc(sizeof(XPoint) * num);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2399
	    if (! points) goto fail;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2400
	} else
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2401
	    points = qPoints;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2402
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2403
	for (i=0; i<num; i++) {
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  2404
	    point = __AT_(aPolygon COMMA_CON, __MKSMALLINT(i+1));
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2405
	    if (! __isPoint(point)) goto fail;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2406
	    x = _point_X(point);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2407
	    y = _point_Y(point);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2408
	    if (! __bothSmallInteger(x, y))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2409
		goto fail;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2410
	    points[i].x = _intVal(x);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2411
	    points[i].y = _intVal(y);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2412
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2413
	XDrawLines(myDpy, win, gc, points, num, CoordModeOrigin);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2414
	if (num > 100)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2415
	    free(points);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2416
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2417
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2418
fail: ;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2419
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2420
    "badGC, badDrawable or coordinates not integer"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2421
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2422
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2423
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2424
displayRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2425
    "draw a rectangle. If the coordinates are not integers, an error is triggered." 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2426
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2427
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2428
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2429
    GC gc;
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2430
    Window win;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2431
    int w, h;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2432
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2433
    if (__isExternalAddress(aGCId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2434
     && __isExternalAddress(aDrawableId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2435
     && __bothSmallInteger(x, y)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2436
     && __bothSmallInteger(width, height)) {
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2437
	gc = _GCVal(aGCId);
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2438
	win = _WindowVal(aDrawableId);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2439
	w = _intVal(width);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2440
	h = _intVal(height);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2441
	/*
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2442
	 * need this check here: some servers simply dump core with bad args
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2443
	 */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2444
	if ((w >= 0) && (h >= 0)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2445
	    XDrawRectangle(myDpy, win, gc, _intVal(x), _intVal(y), w, h);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2446
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2447
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2448
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2449
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2450
    "badGC, badDrawable or coordinates not integer"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2451
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2452
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2453
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2454
displayString:aString from:index1 to:index2 x:x y:y in:aDrawableId with:aGCId opaque:opaque 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2455
    "draw a sub-string - if opaque is false, draw foreground only; otherwise, draw both
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2456
     foreground and background characters.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2457
     If the coordinates are not integers, an error is triggered."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2458
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2459
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2460
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2461
    GC gc;
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2462
    Window win;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2463
    unsigned char *cp;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2464
    OBJ cls;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2465
    int  i1, i2, l, n;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2466
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2467
    if (__isExternalAddress(aGCId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2468
     && __isExternalAddress(aDrawableId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2469
     && __isNonNilObject(aString)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2470
     && __bothSmallInteger(index1, index2)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2471
     && __bothSmallInteger(x, y)) {
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2472
	gc = _GCVal(aGCId);
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2473
	win = _WindowVal(aDrawableId);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2474
	cls = __qClass(aString);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2475
	if ((cls == String) || (cls == Symbol)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2476
	    i1 = _intVal(index1) - 1;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2477
	    i2 = _intVal(index2) - 1;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2478
	    n = _stringSize(aString);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2479
	    cp = _stringVal(aString);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2480
	    if ((i1 >= 0) && (i2 < n)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2481
		if (i2 >= i1) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2482
		    cp += i1;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2483
		    l = i2 - i1 + 1;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2484
		    if (l > 1000) l = 1000;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2485
		    if (opaque == true)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2486
			XDrawImageString(myDpy, win, gc, _intVal(x), _intVal(y), (char *)cp, l);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2487
		    else
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2488
			XDrawString(myDpy, win, gc, _intVal(x), _intVal(y), (char *)cp, l);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2489
		}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2490
		RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2491
	    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2492
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2493
#ifdef TWOBYTESTRINGS
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2494
	if (cls == @global(TwoByteString)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2495
	    i1 = _intVal(index1) - 1;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2496
	    i2 = _intVal(index2) - 1;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2497
	    n = _byteArraySize(aString) / 2;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2498
	    cp = _stringVal(aString);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2499
	    if ((i1 >= 0) && (i2 < n)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2500
		if (i2 >= i1) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2501
		    cp += (i1 * 2);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2502
		    l = i2 - i1 + 1;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2503
		    if (l > 1000) l = 1000;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2504
		    if (opaque == true)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2505
			XDrawImageString16(myDpy, win, gc, _intVal(x), _intVal(y), (XChar2b *)cp, l);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2506
		    else
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2507
			XDrawString16(myDpy, win, gc, _intVal(x), _intVal(y), (XChar2b *)cp, l);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2508
		    RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2509
		}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2510
	    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2511
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2512
#endif
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2513
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2514
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2515
    "x/y not integer, badGC or drawable, or not a string"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2516
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2517
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2518
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2519
displayString:aString x:x y:y in:aDrawableId with:aGCId opaque:opaque 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2520
    "draw a string - if opaque is false, draw foreground only; otherwise, draw both
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2521
     foreground and background characters.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2522
     If the coordinates are not integers, an error is triggered."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2523
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2524
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2525
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2526
    GC gc;
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2527
    Window win;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2528
    unsigned char *cp;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2529
    int n;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2530
    OBJ cls;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2531
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2532
    if (__isExternalAddress(aGCId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2533
     && __isExternalAddress(aDrawableId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2534
     && __isNonNilObject(aString)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2535
     && __bothSmallInteger(x, y)) {
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2536
	gc = _GCVal(aGCId);
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2537
	win = _WindowVal(aDrawableId);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2538
	cls = __qClass(aString);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2539
	if ((cls == String) || (cls == Symbol)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2540
	    cp = _stringVal(aString);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2541
	    n = _stringSize(aString);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2542
	    if (n > 1000) n = 1000;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2543
	    if (opaque == true)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2544
		XDrawImageString(myDpy, win, gc, _intVal(x), _intVal(y), (char *)cp, n);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2545
	    else
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2546
		XDrawString(myDpy, win, gc, _intVal(x), _intVal(y), (char *)cp, n);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2547
	    RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2548
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2549
#ifdef TWOBYTESTRINGS
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2550
	if (cls == @global(TwoByteString)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2551
	    cp = _stringVal(aString);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2552
	    n = _byteArraySize(aString) / 2;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2553
	    if (n > 1000) n = 1000;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2554
	    if (opaque == true)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2555
		XDrawImageString16(myDpy, win, gc, _intVal(x), _intVal(y), (XChar2b *)cp, n);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2556
	    else
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2557
		XDrawString16(myDpy, win, gc, _intVal(x), _intVal(y), (XChar2b *)cp, n);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2558
	    RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2559
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2560
#endif
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2561
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2562
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2563
    "x/y not integer, badGC or drawable, or not a string"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2564
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2565
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2566
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2567
drawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2568
			  width:imageWidth height:imageHeight 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2569
			      x:srcx y:srcy
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2570
			   into:aDrawableId 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2571
			      x:dstx y:dsty 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2572
			  width:w height:h 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2573
			   with:aGCId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2574
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2575
    "draw a bitImage which has depth id, width iw and height ih into
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2576
     the drawable. draw a region of w/h pixels from srcx/srcy to dstx/dsty.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2577
     Individual source pixels have bitsPerPixel bits, allowing to draw
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2578
     depth and pixel-units to be different.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2579
     It has to be checked elsewhere, that the server can do it with the given
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2580
     depth - otherwise, primitive failure will be signalled.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2581
     Also it is assumed, that the colormap is setup correctly and the
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2582
     colors are allocated - otherwise the colors may be wrong."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2583
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2584
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2585
     sorry; I had to separate it into 2 methods, since XPutImage needs
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2586
     an unlimited stack, and thus cannot send primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2587
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2588
    (self primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2589
					width:imageWidth height:imageHeight 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2590
					     x:srcx y:srcy
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2591
					  into:aDrawableId 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2592
					     x:dstx y:dsty 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2593
					 width:w height:h 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2594
					  with:aGCId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2595
    ifFalse:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2596
	"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2597
	 also happens, if a segmentation violation occurs in the 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2598
	 XPutImage ...
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2599
	"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2600
	self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2601
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2602
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2603
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2604
drawBits:imageBits depth:imageDepth 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2605
		   width:imageWidth height:imageHeight 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2606
		       x:srcx y:srcy
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2607
		    into:aDrawableId 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2608
		       x:dstx y:dsty 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2609
		   width:w height:h 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2610
		    with:aGCId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2611
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2612
    "draw a bitImage which has depth id, width iw and height ih into
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2613
     the drawable. draw a region of w/h pixels from srcx/srcy to dstx/dsty.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2614
     Individual source pixels must have imageDepth bits.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2615
     It has to be checked elsewhere, that the server can do it with the given
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2616
     depth - otherwise, primitive failure will be signalled.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2617
     Also it is assumed, that the colormap is setup correctly and the
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2618
     colors are allocated - otherwise the colors may be wrong."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2619
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2620
    ^ self drawBits:imageBits bitsPerPixel:imageDepth depth:imageDepth 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2621
				     width:imageWidth height:imageHeight 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2622
					 x:srcx y:srcy
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2623
				      into:aDrawableId 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2624
					 x:dstx y:dsty 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2625
				     width:w height:h 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2626
				      with:aGCId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2627
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2628
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2629
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2630
fillArcX:x y:y w:width h:height from:startAngle angle:angle
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2631
	       in:aDrawableId with:aGCId
90
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
  2632
    "fill an arc. If any coordinate is not integer, an error is triggered.
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
  2633
     The angles may be floats or integer - they are given in degrees."
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2634
48194c26a46c Initial revision
claus
parents:
diff changeset
  2635
%{  /* NOCONTEXT */
48194c26a46c Initial revision
claus
parents:
diff changeset
  2636
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2637
    GC gc;
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2638
    Window win;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2639
    int w, h, angle1, angle2;
48194c26a46c Initial revision
claus
parents:
diff changeset
  2640
    double f;
48194c26a46c Initial revision
claus
parents:
diff changeset
  2641
97
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  2642
    if (__isSmallInteger(startAngle))
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2643
	angle1 = _intVal(startAngle) * 64;
36
b297468551c6 *** empty log message ***
claus
parents: 31
diff changeset
  2644
    else if (__isFloat(startAngle)) {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2645
	f = _floatVal(startAngle);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2646
	angle1 = f * 64;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2647
    }
97
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  2648
    if (__isSmallInteger(angle))
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2649
	angle2 = _intVal(angle) * 64;
36
b297468551c6 *** empty log message ***
claus
parents: 31
diff changeset
  2650
    else if (__isFloat(angle)) {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2651
	f = _floatVal(angle);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2652
	angle2 = f * 64;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2653
    }
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  2654
    if (__isExternalAddress(aGCId)
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  2655
     && __isExternalAddress(aDrawableId)
97
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  2656
     && __bothSmallInteger(x, y)
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  2657
     && __bothSmallInteger(width, height)) {
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2658
	gc = _GCVal(aGCId);
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2659
	win = _WindowVal(aDrawableId);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2660
	w = _intVal(width);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2661
	h = _intVal(height);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2662
	/*
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2663
	 * need this check here: some servers simply dump core with bad args
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2664
	 */
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2665
	if ((w >= 0) && (h >= 0) && (angle1 >= 0) && (angle2 >= 0)) {
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2666
	    XFillArc(myDpy, win, gc, _intVal(x), _intVal(y),
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2667
				   w, h, angle1, angle2);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2668
	}
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2669
	RETURN ( self );
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2670
    }
73
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2671
%}.
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2672
    "badGC, badDrawable or coordinates not integer"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2673
    self primitiveFailed
48194c26a46c Initial revision
claus
parents:
diff changeset
  2674
!
48194c26a46c Initial revision
claus
parents:
diff changeset
  2675
48194c26a46c Initial revision
claus
parents:
diff changeset
  2676
fillPolygon:aPolygon in:aDrawableId with:aGCId
118
25e775072a89 *** empty log message ***
claus
parents: 115
diff changeset
  2677
    "fill a polygon given by its points. 
25e775072a89 *** empty log message ***
claus
parents: 115
diff changeset
  2678
     If any coordinate is not integer, an error is triggered."
73
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2679
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2680
    |numberOfPoints|
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2681
48194c26a46c Initial revision
claus
parents:
diff changeset
  2682
    numberOfPoints := aPolygon size.
48194c26a46c Initial revision
claus
parents:
diff changeset
  2683
%{
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2684
    GC gc;
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2685
    Window win;
73
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2686
    OBJ point, x, y;
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2687
    int i, num;
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2688
    XPoint *points;
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2689
    XPoint qPoints[100];
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2690
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  2691
    if (__isExternalAddress(aGCId)
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  2692
     && __isExternalAddress(aDrawableId)
97
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  2693
     && __isSmallInteger(numberOfPoints)) {
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2694
	gc = _GCVal(aGCId);
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2695
	win = _WindowVal(aDrawableId);
73
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2696
	num = _intVal(numberOfPoints);
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2697
	if (num < 3) {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2698
	    RETURN ( self );
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2699
	}
73
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2700
	/*
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2701
	 * avoid (slow) malloc, if not many points
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2702
	 */
96
claus
parents: 90
diff changeset
  2703
	if (num > 100) {
73
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2704
	    points = (XPoint *) malloc(sizeof(XPoint) * num);
96
claus
parents: 90
diff changeset
  2705
	    if (! points) goto fail;
claus
parents: 90
diff changeset
  2706
	} else
73
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2707
	    points = qPoints;
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2708
	for (i=0; i<num; i++) {
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  2709
	    point = __AT_(aPolygon COMMA_CON, __MKSMALLINT(i+1));
73
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2710
	    if (! __isPoint(point)) goto fail;
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2711
	    x = _point_X(point);
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2712
	    y = _point_Y(point);
97
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  2713
	    if (! __bothSmallInteger(x, y))
73
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2714
		goto fail;
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2715
	    points[i].x = _intVal(x);
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2716
	    points[i].y = _intVal(y);
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2717
	}
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2718
	XFillPolygon(myDpy, win, gc, points, num, Complex, CoordModeOrigin);
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2719
	if (num > 100)
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2720
	    free(points);
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2721
	RETURN ( self );
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2722
fail: ;
48194c26a46c Initial revision
claus
parents:
diff changeset
  2723
    }
73
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2724
%}.
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2725
    "badGC, badDrawable or coordinates not integer"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2726
    self primitiveFailed
48194c26a46c Initial revision
claus
parents:
diff changeset
  2727
!
48194c26a46c Initial revision
claus
parents:
diff changeset
  2728
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2729
fillRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2730
    "fill a rectangle. If any coordinate is not integer, an error is triggered."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2731
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2732
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2733
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2734
    int w, h;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2735
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2736
    if (__isExternalAddress(aGCId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2737
     && __isExternalAddress(aDrawableId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2738
     && __bothSmallInteger(x, y)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2739
     && __bothSmallInteger(width, height)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2740
	w = _intVal(width);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2741
	h = _intVal(height);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2742
	/*
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2743
	 * need this check here: some servers simply dump core with bad args
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2744
	 */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2745
	if ((w >= 0) && (h >= 0)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2746
	    XFillRectangle(myDpy,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2747
			   (Drawable)_WindowVal(aDrawableId), _GCVal(aGCId),
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2748
			   _intVal(x), _intVal(y), w, h);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2749
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2750
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2751
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2752
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2753
    "badGC, badDrawable or coordinates not integer"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2754
    self primitiveFailed
43
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
  2755
!
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
  2756
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
  2757
primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth 
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2758
			      width:imageWidth height:imageHeight 
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2759
				  x:srcx y:srcy
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2760
			       into:aDrawableId 
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2761
				  x:dstx y:dsty 
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2762
			      width:w height:h 
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2763
			       with:aGCId
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2764
132
claus
parents: 129
diff changeset
  2765
    "since XPutImage may allocate huge amount of stack space 
claus
parents: 129
diff changeset
  2766
     (some implementations use alloca), this must run with unlimited stack."
claus
parents: 129
diff changeset
  2767
12
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2768
%{  /* UNLIMITEDSTACK */
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2769
43
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
  2770
    /*
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
  2771
     * need unlimited stack, since some Xlibs do a huge alloca in
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
  2772
     * XPutImage
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
  2773
     */
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
  2774
    Display *dpy = myDpy;
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2775
    GC gc;
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2776
    Window win;
43
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
  2777
    XImage image;
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
  2778
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  2779
    if (__isExternalAddress(aGCId)
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  2780
     && __isExternalAddress(aDrawableId)
97
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  2781
     && __bothSmallInteger(srcx, srcy)
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  2782
     && __bothSmallInteger(dstx, dsty)
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  2783
     && __bothSmallInteger(w, h)
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  2784
     && __bothSmallInteger(imageWidth, imageHeight)
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  2785
     && __bothSmallInteger(imageDepth, bitsPerPixel)
43
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
  2786
     && __isByteArray(imageBits)) {
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2787
	gc = _GCVal(aGCId);
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2788
	win = _WindowVal(aDrawableId);
46
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  2789
#ifdef ARGDEBUG
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2790
	printf("args ok\n");
46
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  2791
#endif
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2792
	image.data = (char *)_ByteArrayInstPtr(imageBits)->ba_element;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2793
	image.width = _intVal(imageWidth);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2794
	image.height = _intVal(imageHeight);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2795
	image.xoffset = 0;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2796
	image.format = ZPixmap;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2797
	image.byte_order = MSBFirst;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2798
	image.bitmap_unit = 8;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2799
	image.bitmap_bit_order = MSBFirst;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2800
	image.bitmap_pad = 8;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2801
	image.depth = _intVal(imageDepth);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2802
	image.bits_per_pixel = _intVal(bitsPerPixel);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2803
	switch (image.bits_per_pixel) {
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2804
	    case 1:
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2805
		image.bytes_per_line = (_intVal(imageWidth) + 7) / 8;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2806
		break;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2807
	    case 2:
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2808
		image.bytes_per_line = (_intVal(imageWidth)*2 + 7) / 8;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2809
		break;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2810
	    case 4:
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2811
		image.bytes_per_line = (_intVal(imageWidth)*4 + 7) / 8;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2812
		break;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2813
	    case 8:
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2814
		image.bytes_per_line = _intVal(imageWidth);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2815
		break;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2816
	    case 16:
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2817
		image.bytes_per_line = _intVal(imageWidth)*2;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2818
		break;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2819
	    case 24:
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2820
		image.bytes_per_line = _intVal(imageWidth)*3;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2821
		break;
193
Claus Gittinger <cg@exept.de>
parents: 190
diff changeset
  2822
	    case 32:
Claus Gittinger <cg@exept.de>
parents: 190
diff changeset
  2823
		image.bytes_per_line = _intVal(imageWidth)*4;
Claus Gittinger <cg@exept.de>
parents: 190
diff changeset
  2824
		break;
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2825
	    default:
46
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  2826
#ifdef ARGDEBUG
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2827
		printf("bits_per_pixel=%d\n",image.bits_per_pixel);
46
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  2828
#endif
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2829
		goto fail;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2830
	}
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2831
	image.red_mask = 0xFFFF;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2832
	image.green_mask = 0xFFFF;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2833
	image.blue_mask = 0xFFFF;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2834
	XPutImage(dpy, win, gc, &image, _intVal(srcx), _intVal(srcy),
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2835
					_intVal(dstx), _intVal(dsty),
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2836
					_intVal(w), _intVal(h));
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2837
	RETURN ( true );
43
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
  2838
    }
46
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  2839
#ifdef ARGDEBUG
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  2840
    if (!! __isExternalAddress(aGCId)) printf("GC\n");
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  2841
    if (!! __isExternalAddress(aDrawableId)) printf("aDrawableId\n");
193
Claus Gittinger <cg@exept.de>
parents: 190
diff changeset
  2842
    if (!! __isSmallInteger(srcx)) printf("srcx\n");
Claus Gittinger <cg@exept.de>
parents: 190
diff changeset
  2843
    if (!! __isSmallInteger(srcy)) printf("srcy\n");
Claus Gittinger <cg@exept.de>
parents: 190
diff changeset
  2844
    if (!! __isSmallInteger(dstx)) printf("dstx\n");
Claus Gittinger <cg@exept.de>
parents: 190
diff changeset
  2845
    if (!! __isSmallInteger(dsty)) printf("dsty\n");
Claus Gittinger <cg@exept.de>
parents: 190
diff changeset
  2846
    if (!! __isSmallInteger(w)) printf("w\n");
Claus Gittinger <cg@exept.de>
parents: 190
diff changeset
  2847
    if (!! __isSmallInteger(h)) printf("h\n");
Claus Gittinger <cg@exept.de>
parents: 190
diff changeset
  2848
    if (!! __isSmallInteger(imageWidth)) printf("imageWidth\n");
Claus Gittinger <cg@exept.de>
parents: 190
diff changeset
  2849
    if (!! __isSmallInteger(imageHeight)) printf("imageHeight\n");
Claus Gittinger <cg@exept.de>
parents: 190
diff changeset
  2850
    if (!! __isSmallInteger(imageDepth)) printf("imageDepth\n");
Claus Gittinger <cg@exept.de>
parents: 190
diff changeset
  2851
    if (!! __isSmallInteger(bitsPerPixel)) printf("bitsPerPixel\n");
Claus Gittinger <cg@exept.de>
parents: 190
diff changeset
  2852
    if (!! __isByteArray(imageBits)) printf("imageBits\n");
46
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  2853
#endif
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  2854
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2855
fail: ;
48194c26a46c Initial revision
claus
parents:
diff changeset
  2856
%}
48194c26a46c Initial revision
claus
parents:
diff changeset
  2857
.
12
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2858
    ^ false
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2859
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
  2860
86
032006651226 *** empty log message ***
claus
parents: 83
diff changeset
  2861
!XWorkstation methodsFor:'event handling'!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2862
48194c26a46c Initial revision
claus
parents:
diff changeset
  2863
dispatchEventFor:aViewIdOrNil withMask:eventMask
48194c26a46c Initial revision
claus
parents:
diff changeset
  2864
    "central event handling method:
54
29a6b2f8e042 *** empty log message ***
claus
parents: 46
diff changeset
  2865
     get next event and send appropriate message to the sensor or view.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2866
     If the argument aViewIdOrNil is nil, events for any view are processed,
12
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2867
     otherwise only events for the view with given id are processed.
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2868
     If the argument aMask is nonNil, only events for this eventMask are
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2869
     handled."
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2870
54
29a6b2f8e042 *** empty log message ***
claus
parents: 46
diff changeset
  2871
    (self getEventFor:aViewIdOrNil withMask:eventMask) ifTrue:[
83
597bdb33e832 *** empty log message ***
claus
parents: 82
diff changeset
  2872
	Object abortSignal catch:[
597bdb33e832 *** empty log message ***
claus
parents: 82
diff changeset
  2873
	    self dispatchLastEvent.
597bdb33e832 *** empty log message ***
claus
parents: 82
diff changeset
  2874
	]
54
29a6b2f8e042 *** empty log message ***
claus
parents: 46
diff changeset
  2875
    ].
12
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2876
!
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2877
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2878
dispatchExposeEventFor:aViewIdOrNil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2879
    "get next expose event and send appropriate message to the sensor or view.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2880
     If the argument aViewIdOrNil is nil, events for any view are processed,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2881
     otherwise only events for the view with given id are processed."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2882
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2883
    self dispatchEventFor:aViewIdOrNil withMask:(self eventMaskFor:#expose)
12
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2884
!
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2885
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2886
dispatchLastEvent
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  2887
    |theView symS arg butt sibling windowID siblingID propertyID selectionID targetID requestorID
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  2888
     eventType|
12
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2889
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2890
%{  /* STACK: 8000 */
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2891
#   define ANYBUTTON   (Button1MotionMask | Button2MotionMask | Button3MotionMask)
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2892
48194c26a46c Initial revision
claus
parents:
diff changeset
  2893
    Display *dpy = myDpy;
135
claus
parents: 133
diff changeset
  2894
    OBJ eB;
claus
parents: 133
diff changeset
  2895
    XEvent *ev;
claus
parents: 133
diff changeset
  2896
claus
parents: 133
diff changeset
  2897
#   define ae ((XAnyEvent *)ev)
claus
parents: 133
diff changeset
  2898
#   define ee ((XExposeEvent *)ev)
claus
parents: 133
diff changeset
  2899
#   define ke ((XKeyPressedEvent *)ev)
claus
parents: 133
diff changeset
  2900
#   define be ((XButtonPressedEvent *)ev)
claus
parents: 133
diff changeset
  2901
#   define ce ((XConfigureEvent *)ev)
claus
parents: 133
diff changeset
  2902
#   define me ((XMotionEvent *)ev)
claus
parents: 133
diff changeset
  2903
#   define ewe ((XEnterWindowEvent *)ev)
claus
parents: 133
diff changeset
  2904
#   define lwe ((XLeaveWindowEvent *)ev)
claus
parents: 133
diff changeset
  2905
#   define de ((XDestroyWindowEvent *)ev)
claus
parents: 133
diff changeset
  2906
#   define ve ((XVisibilityEvent *)ev)
288
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  2907
#   define mape ((XMappingEvent *)ev)
135
claus
parents: 133
diff changeset
  2908
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2909
    KeySym keySym;
48194c26a46c Initial revision
claus
parents:
diff changeset
  2910
    unsigned char buffer[10];
48194c26a46c Initial revision
claus
parents:
diff changeset
  2911
    int i, nchars;
48194c26a46c Initial revision
claus
parents:
diff changeset
  2912
    char *keySymString;
48194c26a46c Initial revision
claus
parents:
diff changeset
  2913
    char keySymStringBuffer[32];
48194c26a46c Initial revision
claus
parents:
diff changeset
  2914
    static unsigned multiClickTime = 0;
48194c26a46c Initial revision
claus
parents:
diff changeset
  2915
    unsigned nextMultiClickTime;
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  2916
    OBJ upDown;
115
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  2917
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  2918
    struct inlineCache *ipS;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2919
    static struct inlineCache vid = _ILC1;
12
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2920
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2921
    static struct inlineCache expS = _ILC5;
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2922
    static struct inlineCache gexpS = _ILC5;
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2923
    static struct inlineCache nexpS = _ILC1;
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2924
    static struct inlineCache motS = _ILC4;
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2925
    static struct inlineCache bpS = _ILC4;
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2926
    static struct inlineCache bmpS = _ILC4;
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2927
    static struct inlineCache bspS = _ILC4;
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2928
    static struct inlineCache brS = _ILC4;
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2929
    static struct inlineCache focInS = _ILC1;
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2930
    static struct inlineCache focOutS = _ILC1;
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2931
    static struct inlineCache peS = _ILC4;
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2932
    static struct inlineCache plS = _ILC2;
54
29a6b2f8e042 *** empty log message ***
claus
parents: 46
diff changeset
  2933
    static struct inlineCache termS = _ILC1;
29a6b2f8e042 *** empty log message ***
claus
parents: 46
diff changeset
  2934
    static struct inlineCache savtermS = _ILC1;
29a6b2f8e042 *** empty log message ***
claus
parents: 46
diff changeset
  2935
    static struct inlineCache destrS = _ILC1;
29a6b2f8e042 *** empty log message ***
claus
parents: 46
diff changeset
  2936
    static struct inlineCache unmapS = _ILC1;
29a6b2f8e042 *** empty log message ***
claus
parents: 46
diff changeset
  2937
    static struct inlineCache mapS = _ILC1;
29a6b2f8e042 *** empty log message ***
claus
parents: 46
diff changeset
  2938
    static struct inlineCache confS = _ILC5;
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2939
    static struct inlineCache coveredS = _ILC2;
12
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2940
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2941
    static struct inlineCache keymap = _ILC0;
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2942
    static struct inlineCache created = _ILC0;
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2943
    static struct inlineCache mapReq = _ILC0;
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2944
    static struct inlineCache repar = _ILC0;
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2945
    static struct inlineCache confReq = _ILC0;
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2946
    static struct inlineCache resReq = _ILC0;
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2947
    static struct inlineCache prop = _ILC0;
129
752fbb07635a *** empty log message ***
claus
parents: 125
diff changeset
  2948
    static struct inlineCache selClear = _ILC1;
90
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
  2949
    static struct inlineCache selReq = _ILC4;
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
  2950
    static struct inlineCache selNotify = _ILC4;
12
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2951
    static struct inlineCache colormap = _ILC0;
288
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  2952
    static struct inlineCache mapping = _ILC2;
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2953
    static struct inlineCache vis = _ILC1;
12
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2954
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2955
    static struct inlineCache skpS = _ILC4;
63
b9d17e2b6c92 keyRelease and more event masks
claus
parents: 55
diff changeset
  2956
    static struct inlineCache skrS = _ILC4;
12
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2957
135
claus
parents: 133
diff changeset
  2958
    eB = _INST(eventBuffer);
claus
parents: 133
diff changeset
  2959
    if (__isByteArray(eB)) {
claus
parents: 133
diff changeset
  2960
	ev = (XEvent *)(_ByteArrayInstPtr(eB)->ba_element);
claus
parents: 133
diff changeset
  2961
    } else {
claus
parents: 133
diff changeset
  2962
	printf("DISPLAY: no eventBuffer\n");
claus
parents: 133
diff changeset
  2963
	RETURN (false);
claus
parents: 133
diff changeset
  2964
    }
claus
parents: 133
diff changeset
  2965
207
9124817bbb03 use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents: 206
diff changeset
  2966
    windowID = __MKOBJ(ae->window);
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  2967
    theView = (*vid.ilc_func)(self, @symbol(viewFromId:) COMMA_CON, nil, &vid, windowID);
12
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2968
288
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  2969
    if ((theView == nil) && (ev->type != MappingNotify)) {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2970
	RETURN (nil);
12
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2971
    }
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2972
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2973
    /*
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2974
     * key, button and pointer events are sent to the sensor,
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2975
     * or (if there is none) to the delegate.
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2976
     * or (if there is none) to the view.
26
ac9f66dc8f53 *** empty log message ***
claus
parents: 23
diff changeset
  2977
     *
ac9f66dc8f53 *** empty log message ***
claus
parents: 23
diff changeset
  2978
     * expose events are sent to the sensor,
ac9f66dc8f53 *** empty log message ***
claus
parents: 23
diff changeset
  2979
     * or (if there is none) to the view
ac9f66dc8f53 *** empty log message ***
claus
parents: 23
diff changeset
  2980
     *
12
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2981
     * sensor and delegate get view as additional argument
115
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  2982
     * all of this has been taken out of here to corresponding methods
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  2983
     * in DeviceWorkstation.
12
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2984
     */
90
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
  2985
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  2986
#ifdef DEBUG
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  2987
    eventType = __MKSMALLINT(ev->type);
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  2988
#endif
135
claus
parents: 133
diff changeset
  2989
    switch (ev->type) {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2990
	case KeyRelease:
115
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  2991
	    symS = @symbol(keyRelease:x:y:view:);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2992
	    ipS = &skrS;
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  2993
	    upDown = false;
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2994
	    goto keyPressAndRelease;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2995
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2996
	case KeyPress:
115
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  2997
	    symS = @symbol(keyPress:x:y:view:);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2998
	    ipS = &skpS;
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  2999
	    upDown = true;
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3000
	    /* FALL INTO */
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3001
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3002
	keyPressAndRelease:
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  3003
	    _INST(eventRootX) = __MKSMALLINT(ke->x_root);
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  3004
	    _INST(eventRootY) = __MKSMALLINT(ke->y_root);
240
bdbab643c0e7 allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  3005
#ifdef OLD
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3006
	    _INST(altDown) = (ke->state & Mod2Mask) ? true : false;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3007
	    _INST(metaDown) = (ke->state & Mod1Mask) ? true : false;
240
bdbab643c0e7 allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  3008
#else
bdbab643c0e7 allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  3009
	    _INST(altDown) = (ke->state & __intVal(_INST(altModifierMask))) ? true : false;
bdbab643c0e7 allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  3010
	    _INST(metaDown) = (ke->state & __intVal(_INST(metaModifierMask))) ? true : false;
bdbab643c0e7 allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  3011
#endif
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3012
	    _INST(shiftDown) = (ke->state & ShiftMask) ? true : false;
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3013
	    _INST(ctrlDown) = (ke->state & ControlMask) ? true : false;
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3014
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3015
	    arg = nil;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3016
	    nchars = XLookupString(ke, (char *)buffer, sizeof(buffer), &keySym, NULL);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3017
	    if (nchars 
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3018
	     && (((buffer[0] >= ' ') && (buffer[0] <= '~'))
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3019
		 || (buffer[0] >= 0x80))) {
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3020
		arg = _MKCHARACTER(buffer[0])/* *_CharacterTable[buffer[0]] */;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3021
		keySymString = NULL;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3022
	    } else {
250
eaa532ebcad7 modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
  3023
#ifdef OLD
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3024
		switch (keySym) {
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3025
		    case XK_Control_L:
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3026
		    case XK_Control_R:
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3027
			_INST(ctrlDown) = upDown;
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3028
			break;
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3029
		    case XK_Shift_L:
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3030
		    case XK_Shift_R:
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3031
			_INST(shiftDown) = upDown;
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3032
			break;
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3033
		    case XK_Meta_L:
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3034
		    case XK_Meta_R:
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3035
			_INST(metaDown) = upDown;
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3036
			break;
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3037
		    case XK_Alt_L:
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3038
		    case XK_Alt_R:
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3039
			_INST(altDown) = upDown;
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3040
			break;
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3041
		}
250
eaa532ebcad7 modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
  3042
#endif
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3043
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3044
		keySymString = XKeysymToString(keySym);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3045
		if (keySymString) {
250
eaa532ebcad7 modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
  3046
#ifdef OLD
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3047
		    if (keySymString[0] == 'D') {
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3048
			/*
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3049
			 * remove underscore, dont want it in symbols
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3050
			 */
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3051
			if (strcmp(keySymString, "Delete_line") == 0) {
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3052
			    keySymString = "DeleteLine";
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3053
			} else if (strcmp(keySymString, "Delete_word") == 0) {
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3054
			    keySymString = "DeleteWord";
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3055
			}
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3056
		    }
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3057
		    /*
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3058
		     * make names compatible
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3059
		     */
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3060
		    if (strcmp(keySymString, "Down") == 0) {
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3061
			keySymString = "CursorDown";
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3062
		    } else if (strcmp(keySymString, "Up") == 0) {
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3063
			keySymString = "CursorUp";
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3064
		    } else if (strcmp(keySymString, "Left") == 0) {
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3065
			keySymString = "CursorLeft";
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3066
		    } else if (strcmp(keySymString, "Right") == 0) {
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3067
			keySymString = "CursorRight";
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3068
		    }
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  3069
		    arg = __MKSYMBOL(keySymString, (OBJ *)0, __context);
250
eaa532ebcad7 modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
  3070
#else
350
ade060e42304 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 342
diff changeset
  3071
		    __PROTECT__(theView);
250
eaa532ebcad7 modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
  3072
		    arg = __MKSTRING(keySymString COMMA_CON);
350
ade060e42304 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 342
diff changeset
  3073
		    __UNPROTECT__(theView);
250
eaa532ebcad7 modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
  3074
#endif
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3075
		}
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3076
	    }
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3077
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3078
	    if (arg == nil) {
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3079
		/* happens sometimes (alt-graph on sun has no keysym) */
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3080
		break;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3081
	    }
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3082
115
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3083
	    (*(*ipS).ilc_func)(self, symS COMMA_CON, nil, ipS,
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3084
			       arg, 
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  3085
			       __MKSMALLINT(ke->x), 
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  3086
			       __MKSMALLINT(ke->y),
115
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3087
			       theView);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3088
	    break;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3089
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3090
	case ButtonPress:
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  3091
	    _INST(buttonsPressed) = __MKSMALLINT(_intVal(_INST(buttonsPressed)) | (1 << be->button));
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  3092
	    _INST(eventRootX) = __MKSMALLINT(be->x_root);
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  3093
	    _INST(eventRootY) = __MKSMALLINT(be->y_root);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3094
97
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  3095
	    if (__isSmallInteger(_INST(multiClickTimeDelta)))
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3096
		nextMultiClickTime = be->time + _intVal(_INST(multiClickTimeDelta));
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3097
	    else
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3098
		nextMultiClickTime = 0;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3099
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3100
	    if (multiClickTime) {
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3101
		if (be->time < multiClickTime) {
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3102
		    multiClickTime = nextMultiClickTime;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3103
		    ipS = &bmpS;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3104
		    symS = @symbol(buttonMultiPress:x:y:view:);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3105
		    goto sendButtonEvent;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3106
		    break;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3107
		}
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3108
	    }
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3109
	    multiClickTime = nextMultiClickTime;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3110
	    if (be->state & ShiftMask) {
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3111
		ipS = &bspS;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3112
		symS = @symbol(buttonShiftPress:x:y:view:);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3113
		goto sendButtonEvent;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3114
	    }
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3115
	    ipS = &bpS;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3116
	    symS = @symbol(buttonPress:x:y:view:);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3117
	    goto sendButtonEvent;
200
aa66f76133ab New Method: atomName:
Stefan Vogel <sv@exept.de>
parents: 193
diff changeset
  3118
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3119
	    /* NOT REACHED */
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3120
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3121
	case ButtonRelease:
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  3122
	    _INST(buttonsPressed) = __MKSMALLINT(_intVal(_INST(buttonsPressed)) & ~(1 << be->button));
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  3123
	    _INST(eventRootX) = __MKSMALLINT(be->x_root);
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  3124
	    _INST(eventRootY) = __MKSMALLINT(be->y_root);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3125
	    ipS = &brS;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3126
	    symS = @symbol(buttonRelease:x:y:view:);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3127
	    /* fall into */
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3128
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3129
	sendButtonEvent:
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  3130
	    butt = __MKSMALLINT(be->button);
12
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3131
#ifdef NOTDEF
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3132
	    /*
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3133
	     * this allows operation with single button mouses: meta-click is always Button 2
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3134
	     */
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3135
	    if (_INST(metaDown) == true)
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  3136
		butt = __MKSMALLINT(2);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3137
	    else 
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  3138
#endif
193
Claus Gittinger <cg@exept.de>
parents: 190
diff changeset
  3139
		butt = __AT_(_INST(buttonTranslation), butt);
200
aa66f76133ab New Method: atomName:
Stefan Vogel <sv@exept.de>
parents: 193
diff changeset
  3140
12
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3141
115
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3142
	    (*(*ipS).ilc_func)(self, 
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3143
			       symS
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3144
			       COMMA_CON, nil, ipS,
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3145
			       butt, 
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  3146
			       __MKSMALLINT(ke->x), 
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  3147
			       __MKSMALLINT(ke->y),
115
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3148
			       theView);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3149
	    break;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3150
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3151
	case MotionNotify:
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3152
	    if (_INST(motionEventCompression) != false) {
135
claus
parents: 133
diff changeset
  3153
		while (XCheckWindowEvent(dpy, me->window, ANYBUTTON, ev)) ;;
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3154
	    }
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3155
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  3156
	    _INST(eventRootX) = __MKSMALLINT(me->x_root);
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  3157
	    _INST(eventRootY) = __MKSMALLINT(me->y_root);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3158
240
bdbab643c0e7 allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  3159
#ifdef OLD
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3160
	    _INST(altDown) = (me->state & Mod2Mask) ? true : false;
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3161
	    _INST(metaDown) = (me->state & Mod1Mask) ? true : false;
240
bdbab643c0e7 allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  3162
#else
bdbab643c0e7 allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  3163
	    _INST(altDown) = (ke->state & __intVal(_INST(altModifierMask))) ? true : false;
bdbab643c0e7 allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  3164
	    _INST(metaDown) = (ke->state & __intVal(_INST(metaModifierMask))) ? true : false;
bdbab643c0e7 allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  3165
#endif
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3166
	    _INST(shiftDown) = (me->state & ShiftMask) ? true : false;
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3167
	    _INST(ctrlDown) = (me->state & ControlMask) ? true : false;
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3168
115
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3169
	    (*motS.ilc_func)(self, 
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3170
			     @symbol(buttonMotion:x:y:view:)
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3171
			     COMMA_CON, nil, &motS,
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  3172
			     __MKSMALLINT(me->state),
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  3173
			     __MKSMALLINT(me->x),
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  3174
			     __MKSMALLINT(me->y),
115
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3175
			     theView);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3176
	    break;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3177
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3178
	case FocusIn:
115
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3179
	    (*focInS.ilc_func)(self, 
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3180
			       @symbol(focusInView:)
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3181
			       COMMA_CON, nil, &focInS, 
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3182
			       theView);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3183
	    break;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3184
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3185
	case FocusOut:
115
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3186
	    (*focOutS.ilc_func)(self, 
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3187
				@symbol(focusOutView:)
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3188
				COMMA_CON, nil, &focOutS, 
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3189
				theView);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3190
	    break;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3191
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3192
	case EnterNotify:
240
bdbab643c0e7 allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  3193
#ifdef OLD
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3194
	    _INST(altDown) = (ewe->state & Mod2Mask) ? true : false;
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3195
	    _INST(metaDown) = (ewe->state & Mod1Mask) ? true : false;
240
bdbab643c0e7 allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  3196
#else
bdbab643c0e7 allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  3197
	    _INST(altDown) = (ke->state & __intVal(_INST(altModifierMask))) ? true : false;
bdbab643c0e7 allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  3198
	    _INST(metaDown) = (ke->state & __intVal(_INST(metaModifierMask))) ? true : false;
bdbab643c0e7 allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  3199
#endif
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3200
	    _INST(shiftDown) = (ewe->state & ShiftMask) ? true : false;
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3201
	    _INST(ctrlDown) = (ewe->state & ControlMask) ? true : false;
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3202
115
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3203
	    (*peS.ilc_func)(self, 
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3204
			    @symbol(pointerEnter:x:y:view:)
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3205
			    COMMA_CON, nil, &peS,
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  3206
			    __MKSMALLINT(ewe->state),
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  3207
			    __MKSMALLINT(ewe->x), 
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  3208
			    __MKSMALLINT(ewe->y),
115
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3209
			    theView);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3210
	    break;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3211
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3212
	case LeaveNotify:
115
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3213
	    (*plS.ilc_func)(self, 
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3214
			    @symbol(pointerLeave:view:)
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3215
			    COMMA_CON, nil, &plS,
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  3216
			    __MKSMALLINT(lwe->state), 
115
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3217
			    theView);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3218
	    break;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3219
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3220
	case GraphicsExpose:
115
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3221
	    (*gexpS.ilc_func)(self, 
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3222
			      @symbol(graphicExposeX:y:width:height:view:)
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3223
			      COMMA_CON, nil, &gexpS,
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  3224
			      __MKSMALLINT(ee->x),
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  3225
			      __MKSMALLINT(ee->y),
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  3226
			      __MKSMALLINT(ee->width),
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  3227
			      __MKSMALLINT(ee->height),
115
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3228
			      theView);
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3229
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3230
	    if (ee->count != 0) {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3231
		break;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3232
	    }
115
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3233
	    /* fall into */
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3234
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3235
	case NoExpose:
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3236
	    (*nexpS.ilc_func)(self, 
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3237
			      @symbol(noExposeView:)
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3238
			      COMMA_CON, nil, &nexpS, 
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3239
			      theView);
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3240
	    break;
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3241
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3242
	case Expose:
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3243
	    (*expS.ilc_func)(self, 
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3244
			     @symbol(exposeX:y:width:height:view:)
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3245
			     COMMA_CON, nil, &expS,
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  3246
			     __MKSMALLINT(ee->x),
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  3247
			     __MKSMALLINT(ee->y),
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  3248
			     __MKSMALLINT(ee->width),
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  3249
			     __MKSMALLINT(ee->height),
115
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3250
			     theView);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3251
	    break;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3252
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3253
	case ConfigureNotify:
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3254
	    if (ce->above != None) {
207
9124817bbb03 use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents: 206
diff changeset
  3255
		siblingID = __MKOBJ(ce->above);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3256
		sibling = (*vid.ilc_func)(self, @symbol(viewFromId:) 
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  3257
					  COMMA_CON, nil, &vid, siblingID);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3258
	    }
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3259
115
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3260
	    (*confS.ilc_func)(self, 
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3261
			     @symbol(configureX:y:width:height:view:)
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3262
			     COMMA_CON, nil, &confS,
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  3263
			     __MKSMALLINT(ce->x),
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  3264
			     __MKSMALLINT(ce->y),
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  3265
			     __MKSMALLINT(ce->width),
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  3266
			     __MKSMALLINT(ce->height),
115
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3267
			     theView);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3268
	    if (sibling != nil) {
115
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3269
		(*coveredS.ilc_func)(self,
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3270
				    @symbol(coveredBy:view:)
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3271
				    COMMA_CON, nil, &coveredS,
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3272
				    theView,
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3273
				    sibling);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3274
	    }
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3275
	    break;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3276
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3277
	case ClientMessage:
135
claus
parents: 133
diff changeset
  3278
	    if (ev->xclient.message_type == (int) _AtomVal(_INST(protocolsAtom))) {
claus
parents: 133
diff changeset
  3279
		if ((ev->xclient.data.l[0] == (int) _AtomVal(_INST(quitAppAtom)))
claus
parents: 133
diff changeset
  3280
		 || (ev->xclient.data.l[0] == (int) _AtomVal(_INST(deleteWindowAtom)))) {
115
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3281
		    (*termS.ilc_func)(self, 
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3282
				      @symbol(terminateView:)
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3283
				      COMMA_CON, nil, &termS, theView);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3284
		    break;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3285
		}
135
claus
parents: 133
diff changeset
  3286
		if (ev->xclient.data.l[0] == (int) _AtomVal(_INST(saveYourselfAtom))) {
115
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3287
		    (*savtermS.ilc_func)(self, 
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3288
					 @symbol(saveAndTerminateView:)
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3289
					 COMMA_CON, nil, &savtermS, theView);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3290
		    break;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3291
		}
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3292
	    }
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3293
	    break;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3294
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3295
	case DestroyNotify:
115
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3296
	    (*destrS.ilc_func)(self, @symbol(destroyedView:)
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3297
			       COMMA_CON, nil, &destrS, theView);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3298
	    break;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3299
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3300
	case UnmapNotify:
115
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3301
	    (*unmapS.ilc_func)(self, @symbol(unmappedView:) 
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3302
			       COMMA_CON, nil, &unmapS, theView);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3303
	    break;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3304
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3305
	case MapNotify:
115
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3306
	    (*mapS.ilc_func)(self, 
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3307
			     @symbol(mappedView:) 
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3308
			     COMMA_CON, nil, &mapS, theView);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3309
	    break;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3310
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3311
	case KeymapNotify:
115
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3312
	    (*keymap.ilc_func)(theView, 
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3313
			       @symbol(keyMapChange) 
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3314
			       COMMA_CON, nil, &keymap);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3315
	    break;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3316
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3317
	case VisibilityNotify:
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3318
	    switch (ve->state) {
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3319
		case VisibilityUnobscured:
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3320
		    arg = @symbol(unobscured);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3321
		    break;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3322
		case VisibilityPartiallyObscured:
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3323
		    arg = @symbol(partiallyObscured);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3324
		    break;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3325
		case VisibilityFullyObscured:
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3326
		    arg = @symbol(fullyObscured);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3327
		    break;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3328
	    }
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3329
	    (*vis.ilc_func)(theView, @symbol(visibilityChange:) COMMA_CON, nil, &vis, arg);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3330
	    break;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3331
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3332
	case CreateNotify:
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3333
	    (*created.ilc_func)(theView, @symbol(created) COMMA_CON, nil, &created);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3334
	    break;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3335
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3336
	case MapRequest:
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3337
	    (*mapReq.ilc_func)(theView, @symbol(mapRequest) COMMA_CON, nil, &mapReq);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3338
	    break;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3339
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3340
	case ReparentNotify:
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3341
	    (*repar.ilc_func)(theView, @symbol(reparented) COMMA_CON, nil, &repar);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3342
	    break;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3343
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3344
	case ConfigureRequest:
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3345
	    (*confReq.ilc_func)(theView, @symbol(configRequest) COMMA_CON, nil, &confReq);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3346
	    break;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3347
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3348
	case GravityNotify:
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3349
	case ResizeRequest:
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3350
	    (*resReq.ilc_func)(theView, @symbol(resizeRequest) COMMA_CON, nil, &resReq);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3351
	    break;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3352
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3353
	case CirculateNotify:
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3354
	case CirculateRequest:
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3355
	    break;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3356
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3357
	case PropertyNotify:
115
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3358
	    (*prop.ilc_func)(theView, 
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3359
			     @symbol(propertyChange) 
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3360
			     COMMA_CON, nil, &prop);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3361
	    break;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3362
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3363
	case SelectionClear:
207
9124817bbb03 use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents: 206
diff changeset
  3364
	    selectionID = __MKATOMOBJ(ev->xselectionclear.selection);
115
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3365
	    (*selClear.ilc_func)(theView, 
129
752fbb07635a *** empty log message ***
claus
parents: 125
diff changeset
  3366
				 @symbol(selectionClear:) 
752fbb07635a *** empty log message ***
claus
parents: 125
diff changeset
  3367
				 COMMA_CON, nil, &selClear,
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  3368
				 selectionID);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3369
	    break;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3370
90
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
  3371
	case SelectionNotify:
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
  3372
	    /*
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
  3373
	     * returned selection value (answer from SelectionRequest)
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
  3374
	     */
129
752fbb07635a *** empty log message ***
claus
parents: 125
diff changeset
  3375
	    DPRINTF(("SelectionNotify prop=%x target=%x selection= %x requestor=%x\n", 
135
claus
parents: 133
diff changeset
  3376
			ev->xselection.property, ev->xselection.target,
claus
parents: 133
diff changeset
  3377
			ev->xselection.selection, ev->xselection.requestor));
129
752fbb07635a *** empty log message ***
claus
parents: 125
diff changeset
  3378
207
9124817bbb03 use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents: 206
diff changeset
  3379
	    propertyID = __MKATOMOBJ(ev->xselection.property);
9124817bbb03 use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents: 206
diff changeset
  3380
	    targetID = __MKATOMOBJ(ev->xselection.target);
9124817bbb03 use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents: 206
diff changeset
  3381
	    selectionID = __MKATOMOBJ(ev->xselection.selection);
9124817bbb03 use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents: 206
diff changeset
  3382
	    requestorID = __MKOBJ(ev->xselection.requestor);
115
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3383
	    (*selNotify.ilc_func)(theView, 
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3384
				  @symbol(selectionNotify:target:selection:from:) 
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3385
				  COMMA_CON, nil, &selNotify,
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  3386
				  propertyID, targetID, selectionID, requestorID);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3387
	    break;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3388
90
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
  3389
	case SelectionRequest:
129
752fbb07635a *** empty log message ***
claus
parents: 125
diff changeset
  3390
	    /*
752fbb07635a *** empty log message ***
claus
parents: 125
diff changeset
  3391
	     * someone wants the selection
752fbb07635a *** empty log message ***
claus
parents: 125
diff changeset
  3392
	     */
752fbb07635a *** empty log message ***
claus
parents: 125
diff changeset
  3393
	    DPRINTF(("SelectionRequest prop=%x target=%x selection=%x requestor=%x\n", 
135
claus
parents: 133
diff changeset
  3394
			ev->xselectionrequest.property,
claus
parents: 133
diff changeset
  3395
			ev->xselectionrequest.target,
claus
parents: 133
diff changeset
  3396
			ev->xselectionrequest.selection,
claus
parents: 133
diff changeset
  3397
			ev->xselectionrequest.requestor));
129
752fbb07635a *** empty log message ***
claus
parents: 125
diff changeset
  3398
207
9124817bbb03 use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents: 206
diff changeset
  3399
	    propertyID = __MKATOMOBJ(ev->xselectionrequest.property);
9124817bbb03 use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents: 206
diff changeset
  3400
	    targetID = __MKATOMOBJ(ev->xselectionrequest.target);
9124817bbb03 use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents: 206
diff changeset
  3401
	    selectionID = __MKATOMOBJ(ev->xselectionrequest.selection);
9124817bbb03 use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents: 206
diff changeset
  3402
	    requestorID = __MKOBJ(ev->xselectionrequest.requestor);
115
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3403
	    (*selReq.ilc_func)(theView, 
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3404
			       @symbol(selectionRequest:target:selection:from:) 
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3405
			       COMMA_CON, nil, &selReq,
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  3406
			       propertyID, targetID, selectionID, requestorID);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3407
	    break;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3408
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3409
	case ColormapNotify:
115
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3410
	    (*colormap.ilc_func)(theView, 
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3411
				 @symbol(colorMapChange) 
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3412
				 COMMA_CON, nil, &colormap);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3413
	    break;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3414
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3415
	case MappingNotify:
288
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  3416
	    switch(mape->request) {
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  3417
		case MappingModifier:
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  3418
		    arg = @symbol(mappingModifier);
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  3419
		    break;
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  3420
		case MappingKeyboard:
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  3421
		    arg = @symbol(mappingKeyboard);
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  3422
		    break;
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  3423
		case MappingPointer:
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  3424
		    arg = @symbol(mappingPointer);
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  3425
		    break;
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  3426
		default:
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  3427
		    arg = nil;
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  3428
		    break;
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  3429
	    }
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  3430
	    (*mapping.ilc_func)(self, 
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  3431
				@symbol(mappingChanged:event:) 
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  3432
				COMMA_CON, nil, &mapping, arg, eB);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3433
	    break;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  3434
    }
135
claus
parents: 133
diff changeset
  3435
#undef ae
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  3436
#undef ee
48194c26a46c Initial revision
claus
parents:
diff changeset
  3437
#undef ke
48194c26a46c Initial revision
claus
parents:
diff changeset
  3438
#undef be
48194c26a46c Initial revision
claus
parents:
diff changeset
  3439
#undef ce
48194c26a46c Initial revision
claus
parents:
diff changeset
  3440
#undef me
48194c26a46c Initial revision
claus
parents:
diff changeset
  3441
#undef ewe
48194c26a46c Initial revision
claus
parents:
diff changeset
  3442
#undef lwe
48194c26a46c Initial revision
claus
parents:
diff changeset
  3443
#undef de
288
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  3444
#undef mape
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  3445
%}
48194c26a46c Initial revision
claus
parents:
diff changeset
  3446
.
48194c26a46c Initial revision
claus
parents:
diff changeset
  3447
    ^ true
48194c26a46c Initial revision
claus
parents:
diff changeset
  3448
!
48194c26a46c Initial revision
claus
parents:
diff changeset
  3449
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3450
dispatchPendingEvents
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3451
    "central event handling method:
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3452
     this code is somewhat special, since X has a concept of graphic
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3453
     expose events (which are sent after a bitblt). After such a bitblt,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3454
     we only handle exposes until the graphicsExpose arrives.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3455
     Other systems may not need such a kludge"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3456
320
b7b8dc88fe9f interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
  3457
    "interested in exposes only ?"
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3458
    dispatchingExpose notNil ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3459
	[self exposeEventPendingFor:dispatchingExpose] whileTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3460
	    self dispatchExposeEventFor:dispatchingExpose
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3461
	].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3462
	^ self
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3463
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3464
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3465
    "no, general dispatch"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3466
    [self eventPendingWithoutSync] whileTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3467
	self dispatchEventFor:nil withMask:nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3468
    ]
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3469
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3470
81
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
  3471
disposeEventsWithMask:aMask for:aWindowIdOrNil
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
  3472
    "dispose (throw away) specific events. If aWindowId is nil,
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
  3473
     events matching the mask are thrown away regardless of which
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
  3474
     view they are for. Otherwise, only matching events for that 
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
  3475
     view are flushed."
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  3476
48194c26a46c Initial revision
claus
parents:
diff changeset
  3477
%{  /* NOCONTEXT */
48194c26a46c Initial revision
claus
parents:
diff changeset
  3478
48194c26a46c Initial revision
claus
parents:
diff changeset
  3479
    Display *dpy = myDpy;
48194c26a46c Initial revision
claus
parents:
diff changeset
  3480
    XEvent ev;
48194c26a46c Initial revision
claus
parents:
diff changeset
  3481
    Window win;
48194c26a46c Initial revision
claus
parents:
diff changeset
  3482
97
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  3483
    if (__isSmallInteger(aMask)) {
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  3484
	if (__isExternalAddress(aWindowIdOrNil)) {
81
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
  3485
	    win = _WindowVal(aWindowIdOrNil);
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
  3486
	    while (XCheckWindowEvent(dpy, win, _intVal(aMask), &ev)) ;;
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
  3487
	} else {
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
  3488
	    while (XCheckMaskEvent(dpy, _intVal(aMask), &ev)) ;;
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
  3489
	}
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3490
	RETURN ( self );
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  3491
    }
48194c26a46c Initial revision
claus
parents:
diff changeset
  3492
%}
48194c26a46c Initial revision
claus
parents:
diff changeset
  3493
.
48194c26a46c Initial revision
claus
parents:
diff changeset
  3494
    self primitiveFailed
48194c26a46c Initial revision
claus
parents:
diff changeset
  3495
!
48194c26a46c Initial revision
claus
parents:
diff changeset
  3496
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3497
eventMaskFor:anEventSymbol
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3498
    "return the eventMask bit-constant corresponding to an event symbol"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3499
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3500
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3501
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3502
    int m = 0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3503
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3504
    if (anEventSymbol == @symbol(keyPress)) m = KeyPressMask;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3505
    else if (anEventSymbol == @symbol(keyRelease)) m = KeyReleaseMask;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3506
    else if (anEventSymbol == @symbol(buttonPress)) m = ButtonPressMask;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3507
    else if (anEventSymbol == @symbol(buttonRelease)) m = ButtonReleaseMask;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3508
    else if (anEventSymbol == @symbol(buttonMotion)) m = ButtonMotionMask;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3509
    else if (anEventSymbol == @symbol(pointerMotion)) m = PointerMotionMask;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3510
    else if (anEventSymbol == @symbol(expose)) m = ExposureMask;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3511
    else if (anEventSymbol == @symbol(focusChange)) m = FocusChangeMask;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3512
    else if (anEventSymbol == @symbol(enter)) m = EnterWindowMask;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3513
    else if (anEventSymbol == @symbol(leave)) m = LeaveWindowMask;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3514
    else if (anEventSymbol == @symbol(keymapState)) m = KeymapStateMask;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3515
    else if (anEventSymbol == @symbol(visibilityChange)) m = VisibilityChangeMask;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3516
    else if (anEventSymbol == @symbol(structureNotify)) m = StructureNotifyMask;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3517
    else if (anEventSymbol == @symbol(resizeRedirect)) m = ResizeRedirectMask;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3518
    else if (anEventSymbol == @symbol(propertyChange)) m = PropertyChangeMask;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3519
    else if (anEventSymbol == @symbol(colormapChange)) m = ColormapChangeMask;
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  3520
    RETURN (__MKSMALLINT(m));
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3521
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3522
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3523
12
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3524
eventPending
310
6ed27eebc243 stefans event queue changes
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
  3525
    "return true, if any event is pending. 
6ed27eebc243 stefans event queue changes
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
  3526
     This looks for both the internal queue and the display connection."
12
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3527
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3528
    dispatchingExpose notNil ifTrue:[
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3529
	^ self exposeEventPendingFor:dispatchingExpose
12
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3530
    ].
54
29a6b2f8e042 *** empty log message ***
claus
parents: 46
diff changeset
  3531
"/    ^ self eventPendingWithSync
29a6b2f8e042 *** empty log message ***
claus
parents: 46
diff changeset
  3532
    ^ self eventPendingWithoutSync
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  3533
!
48194c26a46c Initial revision
claus
parents:
diff changeset
  3534
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3535
eventPending:anEventSymbol for:aWindowIdOrNil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3536
    "return true, if a specific event is pending"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3537
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3538
    ^ self eventsPending:(self eventMaskFor:anEventSymbol) for:aWindowIdOrNil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3539
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3540
12
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3541
eventPendingWithSync
7
9b4a00211ca5 last version before dispatch change
claus
parents: 6
diff changeset
  3542
    "return true, if any event is pending. 
310
6ed27eebc243 stefans event queue changes
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
  3543
     Do a sync output buffer (i.e. send all to the display and wait until its processed)
6ed27eebc243 stefans event queue changes
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
  3544
     before checking."
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  3545
12
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3546
%{  /* UNLIMITEDSTACK */
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  3547
48194c26a46c Initial revision
claus
parents:
diff changeset
  3548
    Display *dpy = myDpy;
48194c26a46c Initial revision
claus
parents:
diff changeset
  3549
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3550
    if (ISCONNECTED) {
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3551
	XSync(dpy, 0);      /* make certain everything is flushed */
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3552
	if (XPending(dpy)) {
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3553
	    RETURN (true);
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3554
	}
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3555
    }
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3556
    RETURN ( false );
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  3557
%}
48194c26a46c Initial revision
claus
parents:
diff changeset
  3558
!
48194c26a46c Initial revision
claus
parents:
diff changeset
  3559
48194c26a46c Initial revision
claus
parents:
diff changeset
  3560
eventPendingWithoutSync
23
4a7e02de7b72 *** empty log message ***
claus
parents: 21
diff changeset
  3561
    "return true, if any event is pending."
12
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3562
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3563
%{  /* UNLIMITEDSTACK */
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  3564
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3565
    if (ISCONNECTED) {
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3566
	if (XPending(myDpy)) {
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3567
	    RETURN (true);
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3568
	}
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3569
    }
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3570
    RETURN ( false );
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  3571
%}
48194c26a46c Initial revision
claus
parents:
diff changeset
  3572
!
48194c26a46c Initial revision
claus
parents:
diff changeset
  3573
341
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3574
eventQueued
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3575
    "return true, if any event is queued"
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3576
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3577
    dispatchingExpose notNil ifTrue:[
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3578
	^ self exposeEventPendingFor:dispatchingExpose
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3579
    ].
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3580
    ^ self eventQueuedAlready
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3581
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3582
    "Created: 12.12.1995 / 21:43:00 / stefan"
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3583
!
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3584
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3585
eventQueuedAlready
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3586
    "return true, if any event is queued internally.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3587
     (i.e. in X's internal event queue, which is both filled by explicit
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3588
      nextEvent calls AND whenever drawing is done and events are pending on
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3589
      the display connection)."
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3590
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3591
%{  /* UNLIMITEDSTACK */
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3592
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3593
    if (ISCONNECTED) {
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3594
	if (XEventsQueued(myDpy, QueuedAlready)) {
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3595
	    RETURN (true);
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3596
	}
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3597
    }
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3598
    RETURN ( false );
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3599
%}
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3600
!
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3601
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3602
eventsPending:anEventMask for:aWindowIdOrNil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3603
    "return true, if any of the masked events is pending"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3604
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3605
%{  /* UNLIMITEDSTACK */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3606
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3607
    Display *dpy = myDpy;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3608
    XEvent ev;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3609
    Window win;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3610
    int thereIsOne;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3611
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3612
    if (ISCONNECTED && __isSmallInteger(anEventMask)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3613
	XSync(dpy, 0);      /* make certain everything is flushed */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3614
	if (__isExternalAddress(aWindowIdOrNil)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3615
	    win = _WindowVal(aWindowIdOrNil);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3616
	    thereIsOne = XCheckWindowEvent(dpy, win, _intVal(anEventMask), &ev);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3617
	} else {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3618
	    thereIsOne = XCheckMaskEvent(dpy, _intVal(anEventMask), &ev);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3619
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3620
	if (thereIsOne) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3621
	    XPutBackEvent(dpy, &ev);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3622
	    RETURN ( true );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3623
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3624
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3625
    RETURN ( false );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3626
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3627
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3628
81
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
  3629
exposeEventPendingFor:aWindowIdOrNil
310
6ed27eebc243 stefans event queue changes
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
  3630
    "return true, if any expose event is pending for a specific view,
6ed27eebc243 stefans event queue changes
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
  3631
     or any view (if the arg is nil).
6ed27eebc243 stefans event queue changes
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
  3632
     This is an X specific, only required after a scroll operation."
7
9b4a00211ca5 last version before dispatch change
claus
parents: 6
diff changeset
  3633
12
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3634
%{  /* UNLIMITEDSTACK */
7
9b4a00211ca5 last version before dispatch change
claus
parents: 6
diff changeset
  3635
9b4a00211ca5 last version before dispatch change
claus
parents: 6
diff changeset
  3636
    Display *dpy = myDpy;
9b4a00211ca5 last version before dispatch change
claus
parents: 6
diff changeset
  3637
    XEvent ev;
9b4a00211ca5 last version before dispatch change
claus
parents: 6
diff changeset
  3638
    Window win;
81
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
  3639
    int thereIsOne;
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
  3640
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3641
    if (ISCONNECTED) {
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3642
	XSync(dpy, 0);      /* make certain everything is flushed */
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  3643
	if (__isExternalAddress(aWindowIdOrNil)) {
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3644
	    win = _WindowVal(aWindowIdOrNil);
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3645
	    thereIsOne = XCheckWindowEvent(dpy, win, ExposureMask, &ev);
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3646
	} else {
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3647
	    thereIsOne = XCheckMaskEvent(dpy, ExposureMask, &ev);
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3648
	}
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3649
	if (thereIsOne) {
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3650
	    XPutBackEvent(dpy, &ev);
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3651
	    RETURN ( true );
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3652
	}
81
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
  3653
    }
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
  3654
    RETURN ( false );
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
  3655
%}
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
  3656
!
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
  3657
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3658
getEventFor:aViewIdOrNil withMask:eventMask
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3659
    "read next event - put into local eventBuffer. 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3660
     If aViewIdOrNil is nil, events for any view are fetched; 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3661
     otherwise only events for that specific view will be fetched.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3662
     Returns true, if there was an event, false otherwise.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3663
     This method may block - so you better check for pending events
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3664
     before calling for it.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3665
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3666
     Sorry I had to split dispatch into this fetch method and an extra
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3667
     handle method to allow unlimitedstack here.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3668
     (some Xlibs do a big alloca there ...) which cannot be done in 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3669
     dispatchLastEvent, since it dispatches out into ST-methods.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3670
     BUG: uses a static buffer - has to be rewritten, to support multiple
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3671
     display connections.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3672
    "
81
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
  3673
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
  3674
%{  /* UNLIMITEDSTACK */
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
  3675
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
  3676
    Display *dpy = myDpy;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3677
    Window win, wWanted;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3678
    int evMask;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3679
    OBJ eB;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3680
    XEvent *ev;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3681
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3682
    if (! ISCONNECTED) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3683
	RETURN (false);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3684
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3685
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3686
    eB = _INST(eventBuffer);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3687
    if (__isByteArray(eB)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3688
	ev = (XEvent *)(_ByteArrayInstPtr(eB)->ba_element);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3689
    } else {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3690
	printf("DISPLAY: no eventBuffer\n");
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3691
	RETURN (false);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3692
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3693
    ev->type = 0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3694
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3695
    if (__isSmallInteger(eventMask)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3696
	evMask = _intVal(eventMask);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3697
    } else {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3698
	evMask = ~0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3699
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3700
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3701
    if (__isExternalAddress(aViewIdOrNil)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3702
	wWanted = _WindowVal(aViewIdOrNil);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3703
	if (XCheckWindowEvent(dpy, wWanted, evMask, ev)) {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3704
	    RETURN ( true );
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3705
	}
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3706
    } else {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3707
	if (evMask == ~0) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3708
	    XNextEvent(dpy, ev);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3709
	    RETURN (true);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3710
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3711
	if (XCheckMaskEvent(dpy, evMask, ev)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3712
	   RETURN (true);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3713
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3714
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3715
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3716
    ^ false
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3717
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3718
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3719
handleAllEvents
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3720
    "from now on, handle any kind of event"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3721
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3722
    dispatchingExpose := nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3723
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3724
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3725
handleExposeOnlyFor:aView
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3726
    "from now on, handle expose events only"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3727
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3728
    dispatchingExpose := aView id
288
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  3729
!
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  3730
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  3731
mappingChanged:what event:eB
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  3732
    "One of Keyboard-, Modifier- or PointerMap has change, probably by xmodmap.
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  3733
     Tell xlib about the fact."
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  3734
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  3735
    (what == #mappingKeyboard or:[what == #mappingModifier]) ifTrue:[
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  3736
	self refreshKeyboardMapping:eB.
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  3737
	"Maybe some of our modifiers have been changed"
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  3738
	self initializeModifierMappings.
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  3739
    ].
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  3740
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  3741
    "Created: 1.12.1995 / 16:28:23 / stefan"
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3742
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3743
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3744
setEventMask:aMask in:aWindowId
320
b7b8dc88fe9f interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
  3745
    "tell X that we are only interested in events from aMask, which
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3746
     is the bitwise or of the eventMask bits (see 'eventMaskFor:')"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3747
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3748
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3749
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3750
    int mask;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3751
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3752
    if (__isExternalAddress(aWindowId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3753
     && __isSmallInteger(aMask)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3754
	mask = _intVal(aMask);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3755
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3756
#ifdef OLD
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3757
	/* these may not be disabled */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3758
	mask |= ExposureMask | StructureNotifyMask |
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3759
		KeyPressMask | KeyReleaseMask |
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3760
		EnterWindowMask | LeaveWindowMask |
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3761
		ButtonPressMask | ButtonMotionMask | ButtonReleaseMask;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3762
#endif
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3763
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3764
	XSelectInput(myDpy, _WindowVal(aWindowId), mask);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3765
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3766
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3767
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3768
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3769
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3770
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3771
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3772
startDispatch
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3773
    "redefined to clear dispatchingExpose, which is a special X feature"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3774
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3775
    dispatching ifTrue:[^ self].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3776
    dispatchingExpose := nil.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3777
    super startDispatch
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  3778
! !
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3779
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3780
!XWorkstation methodsFor:'font stuff'!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3781
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3782
ascentOf:aFontId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3783
    "the normal ascent"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3784
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3785
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3786
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3787
    XFontStruct *f;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3788
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3789
    if (__isExternalAddress(aFontId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3790
	f = _FontVal(aFontId);
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  3791
	RETURN ( __MKSMALLINT(f->ascent) );
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3792
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3793
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3794
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3795
    self primitiveFailed.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3796
    ^ nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3797
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3798
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3799
createFontFor:aFontName
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3800
    "a basic method for X-font allocation; this method allows
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3801
     any font to be aquired (even those not conforming to
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3802
     standard naming conventions, such as cursor, fixed or k14)"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3803
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3804
%{  /* UNLIMITEDSTACK */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3805
    /* UNLIMITEDSTACK STACK:100000 xxNOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3806
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3807
    XFontStruct *newFont;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3808
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3809
    if (ISCONNECTED) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3810
	if (__isString(aFontName) || __isSymbol(aFontName)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3811
	    BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3812
	    newFont = XLoadQueryFont(myDpy, (char *)__stringVal(aFontName));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3813
	    END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3814
	    RETURN ( newFont ? __MKOBJ(newFont) : nil );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3815
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3816
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3817
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3818
    ^ nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3819
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3820
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3821
decomposeXFontName:aString into:aBlock
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3822
    "extract family, face, style and size from an
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3823
     X-font name 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3824
     (-brand-family-face-style-moreStyle--height-size-res-res-?-??-coding); 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3825
     evaluate aBlock with these"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3826
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3827
    |origin family face style moreStyle skip fheight size
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3828
     resX resY x1 x2 coding start end |
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3829
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3830
    aString isNil ifTrue:[^ false].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3831
    (aString startsWith:'-') ifFalse:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3832
	"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3833
	 take care for ill-named fonts (i.e. pre Rel4 fonts)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3834
	"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3835
	('*-*-[0-9]*' match:aString) ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3836
	    end := aString indexOf:$- startingAt:1.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3837
	    family := aString copyFrom:1 to:(end - 1).
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3838
	    start := end + 1.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3839
	    end := aString indexOf:$- startingAt:start.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3840
	    style := aString copyFrom:start to:(end - 1).
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3841
	    start := end + 1.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3842
	    size := aString copyFrom:start.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3843
	    size := (Number readFromString:size onError:[^false]).
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3844
	    aBlock value:family value:nil value:style value:size value:nil.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3845
	    ^ true.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3846
	].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3847
	('*-[0-9]*' match:aString) ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3848
	    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3849
	     something like lucidasans-24
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3850
	    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3851
	    end := aString indexOf:$- startingAt:1.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3852
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3853
	    family := aString copyFrom:1 to:(end - 1).
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3854
	    start := end + 1.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3855
	    size := aString copyFrom:start.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3856
	    size := (Number readFromString:size onError:[^false]).
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3857
	    aBlock value:family value:nil value:nil value:size value:nil.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3858
	    ^ true.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3859
	].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3860
	aBlock value:aString value:nil value:nil value:nil value:nil.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3861
	^ true.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3862
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3863
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3864
    end := aString indexOf:$- startingAt:2.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3865
    (end == 0) ifTrue:[^ false].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3866
    origin := aString copyFrom:2 to:(end - 1).
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3867
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3868
    start := end + 1.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3869
    end := aString indexOf:$- startingAt:start.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3870
    (end == 0) ifTrue:[^ false].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3871
    family := aString copyFrom:start to:(end - 1).
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3872
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3873
    start := end + 1.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3874
    end := aString indexOf:$- startingAt:start.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3875
    (end == 0) ifTrue:[^ false].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3876
    face := aString copyFrom:start to:(end - 1).
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3877
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3878
    start := end + 1.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3879
    end := aString indexOf:$- startingAt:start.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3880
    (end == 0) ifTrue:[^ false].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3881
    style := aString copyFrom:start to:(end - 1).
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3882
    (style = 'o') ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3883
	style := 'oblique'
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3884
    ] ifFalse:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3885
	(style = 'i') ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3886
	    style := 'italic'
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3887
	] ifFalse:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3888
	    (style = 'r') ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3889
		style := 'roman'
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3890
	    ]
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3891
	]
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3892
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3893
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3894
    start := end + 1.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3895
    end := aString indexOf:$- startingAt:start.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3896
    (end == 0) ifTrue:[^ false].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3897
    moreStyle := aString copyFrom:start to:(end - 1).
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3898
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3899
    start := end + 1.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3900
    end := aString indexOf:$- startingAt:start.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3901
    (end == 0) ifTrue:[^ false].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3902
    skip := aString copyFrom:start to:(end - 1).
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3903
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3904
    start := end + 1.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3905
    end := aString indexOf:$- startingAt:start.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3906
    (end == 0) ifTrue:[^ false].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3907
    fheight := aString copyFrom:start to:(end - 1).
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3908
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3909
    start := end + 1.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3910
    end := aString indexOf:$- startingAt:start.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3911
    (end == 0) ifTrue:[^ false].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3912
    size := aString copyFrom:start to:(end - 1).
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3913
    size := (Number readFromString:size) / 10.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3914
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3915
    start := end + 1.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3916
    end := aString indexOf:$- startingAt:start.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3917
    (end == 0) ifTrue:[^ false].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3918
    resX := aString copyFrom:start to:(end - 1).
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3919
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3920
    start := end + 1.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3921
    end := aString indexOf:$- startingAt:start.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3922
    (end == 0) ifTrue:[^ false].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3923
    resY := aString copyFrom:start to:(end - 1).
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3924
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3925
    start := end + 1.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3926
    end := aString indexOf:$- startingAt:start.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3927
    (end == 0) ifTrue:[^ false].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3928
    x1 := aString copyFrom:start to:(end - 1).
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3929
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3930
    start := end + 1.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3931
    end := aString indexOf:$- startingAt:start.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3932
    (end == 0) ifTrue:[^ false].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3933
    x2 := aString copyFrom:start to:(end - 1).
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3934
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3935
    start := end + 1.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3936
    end := aString indexOf:$- startingAt:start.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3937
    (end == 0) ifTrue:[^ false].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3938
    coding := aString copyFrom:start to:(end - 1).
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3939
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3940
    aBlock value:family value:face value:style value:size value:coding.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3941
    ^ true
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3942
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3943
    "Modified: 27.9.1995 / 10:46:52 / stefan"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3944
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3945
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3946
descentOf:aFontId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3947
    "the normal descent"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3948
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3949
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3950
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3951
    XFontStruct *f;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3952
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3953
    if (__isExternalAddress(aFontId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3954
	f = _FontVal(aFontId);
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  3955
	RETURN ( __MKSMALLINT(f->descent) );
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3956
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3957
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3958
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3959
    self primitiveFailed.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3960
    ^ nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3961
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3962
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3963
getAvailableFontsMatching:pattern
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3964
    "return an Array filled with font names matching aPattern"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3965
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3966
%{  /* UNLIMITEDSTACK */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3967
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3968
    int nnames = 1500;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3969
    int available = nnames + 1;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3970
    char **fonts;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3971
    OBJ arr, str;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3972
    int i;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3973
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3974
    if (ISCONNECTED) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3975
	if (__isString(pattern)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3976
	    for (;;) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3977
		fonts = XListFonts(myDpy, __stringVal(pattern), nnames, &available);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3978
		if ((fonts == NULL) || (available < nnames)) break;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3979
		XFreeFontNames(fonts);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3980
		nnames = available * 2;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3981
	    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3982
	    if (fonts == NULL) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3983
		RETURN ( nil );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3984
	    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3985
	    /*
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3986
	     * now, that we know the number of font names,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3987
	     * create the array ...
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3988
	     */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3989
	    arr = __ARRAY_NEW_INT(available);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3990
	    if (! arr) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3991
		RETURN (nil);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3992
	    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3993
	    /*
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3994
	     * ... and fill it
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3995
	     */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3996
	    for (i=0; i<available; i++) {
350
ade060e42304 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 342
diff changeset
  3997
		__PROTECT__(arr);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3998
		str = __MKSTRING(fonts[i] COMMA_CON);
350
ade060e42304 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 342
diff changeset
  3999
		__UNPROTECT__(arr);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4000
		__ArrayInstPtr(arr)->a_element[i] = str; __STORE(arr, str);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4001
	    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4002
	    RETURN (arr);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4003
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4004
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4005
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4006
    ^ nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4007
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4008
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4009
getDefaultFont
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4010
    "return a default font id - used when class Font cannot
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4011
     find anything usable"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4012
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4013
     ^ self createFontFor:'fixed'
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4014
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4015
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4016
getFontWithFamily:familyString face:faceString
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4017
	    style:styleString size:sizeArg encoding:encodingSym
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4018
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4019
    "try to get the specified font, if not available, try next smaller
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4020
     font. Access to X-fonts by name is possible, by passing the X font name
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4021
     as family and the other parameters as nil. For example, the cursor font
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4022
     can be aquired that way."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4023
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4024
    |theSize theName theId xlatedStyle enc|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4025
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4026
    "special: if face is nil, allow access to X-fonts"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4027
    faceString isNil ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4028
	sizeArg notNil ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4029
	    theName := familyString , '-' , sizeArg printString
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4030
	] ifFalse:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4031
	    theName := familyString
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4032
	].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4033
	theName isNil ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4034
	    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4035
	     mhmh - fall back to the default font
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4036
	    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4037
	    theName := 'fixed'
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4038
	].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4039
	theId := self createFontFor:theName.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4040
	theId isNil ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4041
	    theId := self getDefaultFont
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4042
	].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4043
	^ theId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4044
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4045
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4046
"/ new:
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4047
    xlatedStyle := styleString.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4048
    xlatedStyle notNil ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4049
	xlatedStyle := xlatedStyle first asString
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4050
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4051
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4052
    ^ self 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4053
	getFontWithFoundry:'*'
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4054
	family:familyString asLowercase
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4055
	weight:faceString
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4056
	slant:xlatedStyle
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4057
	spacing:'normal'
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4058
	pixelSize:nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4059
	size:sizeArg 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4060
	registry:'*'
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4061
	encoding:encodingSym.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4062
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4063
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4064
"/ old:
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4065
"/    xlatedStyle := styleString.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4066
"/    "oblique is named italic in times font"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4067
"/    ((familyString = 'Times') or:[familyString = 'times']) ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4068
"/        ((styleString = 'Oblique') or:[styleString = 'oblique']) ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4069
"/            xlatedStyle := 'italic'
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4070
"/        ]
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4071
"/    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4072
"/    (xlatedStyle = 'italic') ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4073
"/        xlatedStyle := 'i'
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4074
"/    ] ifFalse:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4075
"/        (xlatedStyle = 'roman') ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4076
"/            xlatedStyle := 'r'
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4077
"/        ] ifFalse:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4078
"/            (xlatedStyle = 'oblique') ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4079
"/                xlatedStyle := 'o'
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4080
"/            ]
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4081
"/        ]
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4082
"/    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4083
"/
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4084
"/    theId := nil.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4085
"/    theSize := sizeArg.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4086
"/    [theId isNil] whileTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4087
"/        "this works only on Release >= 3 - X-servers"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4088
"/        enc := encodingSym.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4089
"/        enc isNil ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4090
"/            enc := '*'
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4091
"/        ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4092
"/        theName := ('-*-' , familyString ,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4093
"/                     '-' , faceString ,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4094
"/                     '-' , xlatedStyle , '-*-*-*-'
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4095
"/                     , theSize printString , '0-*-*-*-*-'
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4096
"/                     , enc , '-*').
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4097
"/"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4098
"/Transcript showCr:theName; endEntry.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4099
"/"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4100
"/        theId := self createFontFor:theName.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4101
"/        theId isNil ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4102
"/            "could not get the font - try next smaller one"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4103
"/            theSize := theSize - 1.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4104
"/            (theSize < (sizeArg // 2)) ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4105
"/                "thats too much - give up"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4106
"/                ^ self getDefaultFont
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4107
"/                "^ nil"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4108
"/            ]
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4109
"/        ]
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4110
"/    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4111
"/    (theSize ~~ sizeArg) ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4112
"/        Transcript show:'next smaller font: '.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4113
"/        Transcript showCr:theName
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4114
"/    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4115
"/    ^ theId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4116
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4117
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4118
getFontWithFoundry:foundry family:family weight:weight
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4119
	      slant:slant spacing:spc pixelSize:pSize size:size 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4120
	      registry:registry encoding:encoding
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4121
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4122
    "get the specified font, if not available, return nil.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4123
     This is the new font creation method - all others will be changed to
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4124
     use this entry.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4125
     Individual attributes can be left empty (i.e. '') or nil to match any.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4126
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4127
     foundry: 'adobe', 'misc', 'dec', 'schumacher' ... usually '*'
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4128
     family:  'helvetica' 'courier' 'times' ...
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4129
     weight:  'bold' 'medium' 'demi' ...
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4130
     slant:   'r(oman)' 'i(talic)' 'o(blique)'
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4131
     spacing: 'narrow' 'normal' semicondensed' ... usually '*'
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4132
     pixelSize: 16,18 ... usually left empty
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4133
     size:      size in point (1/72th of an inch)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4134
     registry:  iso8859, sgi ... '*'
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4135
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4136
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4137
    |theName sMatch|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4138
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4139
    "this works only on 'Release >= 3' - X-servers"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4140
    "name is:
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4141
	-foundry-family    -weight -slant-
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4142
	 sony    helvetica bold     r
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4143
	 adobe   courier   medium   i
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4144
	 msic    fixed              o
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4145
	 ...     ...
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4146
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4147
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4148
    size isNil ifTrue:[sMatch := '*'] ifFalse:[sMatch := size printString , '0'].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4149
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4150
    theName := ('-' , (foundry isNil ifTrue:['*'] ifFalse:[foundry]),
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4151
		'-' , (family isNil ifTrue:['*'] ifFalse:[family]),
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4152
		'-' , (weight isNil ifTrue:['*'] ifFalse:[weight]) ,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4153
		'-' , (slant isNil ifTrue:['*'] ifFalse:[slant]) , 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4154
		'-' , (spc isNil ifTrue:['*'] ifFalse:[spc]) ,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4155
		'-*' ,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4156
		'-' , (pSize isNil ifTrue:['*'] ifFalse:[pSize printString]),
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4157
		'-' , sMatch ,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4158
		'-*-*-*-*' ,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4159
		'-' , (registry isNil ifTrue:['*'] ifFalse:[registry]) ,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4160
		'-' , (encoding isNil ifTrue:['*'] ifFalse:[encoding])).
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4161
"/  Transcript showCr:theName; endEntry.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4162
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4163
    ^ self createFontFor:theName.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4164
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4165
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4166
     Display getFontWithFoundry:'*'
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4167
			 family:'courier'
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4168
			 weight:'medium'
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4169
			  slant:'r'
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4170
			spacing:nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4171
		      pixelSize:nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4172
			   size:13
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4173
		       registry:'iso8859'
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4174
		       encoding:'*'
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4175
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4176
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4177
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4178
listOfAvailableFonts
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4179
    "return a list with all available fonts on this display.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4180
     Since this takes a long time, keep the result of the query for the
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4181
     next time. The elements of the returned collection are instances of
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4182
     FontDescription."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4183
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4184
    |stream names aName fntDescr|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4185
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4186
    listOfXFonts isNil ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4187
"/
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4188
"/ old code; using a pipe to xlsfonts
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4189
"/
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4190
"/      stream := PipeStream readingFrom:'xlsfonts ''*'''.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4191
"/      stream isNil ifTrue:[^ nil].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4192
"/      listOfXFonts := OrderedCollection new.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4193
"/      [stream atEnd] whileFalse:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4194
"/          aName := stream nextLine.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4195
"/          aName notNil ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4196
"/          self decomposeXFontName:aName into:
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4197
"/                  [:family :face :style :size :coding |
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4198
"/                      family notNil ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4199
"/                          fntDescr := FontDescription
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4200
"/                                          family:family
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4201
"/                                          face:face
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4202
"/                                          style:style
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4203
"/                                          size:size
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4204
"/                                          encoding:coding.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4205
"/                          listOfXFonts add:fntDescr
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4206
"/                      ]
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4207
"/                  ]
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4208
"/          ]
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4209
"/      ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4210
"/      stream close.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4211
"/      "if xlsfont is broken ... (hey sco)"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4212
"/      (listOfXFonts size == 0) ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4213
"/          listOfXFonts := nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4214
"/      ] ifFalse:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4215
"/          listOfXFonts sort:[:a :b | a family < b family].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4216
"/      ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4217
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4218
	"/
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4219
	"/ new code:
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4220
	"/ use new primitive to get font names;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4221
	"/ this is much faster, and also works on systems where
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4222
	"/      a) xlsfonts is broken (sco)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4223
	"/      b) xlsfonts is not available (aix)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4224
	"/
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4225
	names := self getAvailableFontsMatching:'*'.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4226
	names isNil ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4227
	    "no names returned ..."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4228
	    ^ nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4229
	].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4230
	listOfXFonts := names collect:[:aName |
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4231
				    |fntDescr|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4232
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4233
				    (self decomposeXFontName:aName into:
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4234
					[:family :face :style :size :coding |
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4235
					   family notNil ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4236
					       fntDescr := FontDescription
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4237
							       family:family
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4238
							       face:face
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4239
							       style:style
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4240
							       size:size
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4241
							       encoding:coding.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4242
					   ] ifFalse:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4243
					       fntDescr := FontDescription
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4244
							       name:aName
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4245
					   ]
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4246
					]
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4247
				    ) ifFalse:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4248
					fntDescr := FontDescription name:aName.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4249
				    ].  
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4250
				    fntDescr
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4251
			    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4252
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4253
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4254
    ^ listOfXFonts
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4255
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4256
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4257
     Display listOfAvailableFonts
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4258
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4259
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4260
    "Modified: 27.9.1995 / 10:54:47 / stefan"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4261
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4262
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4263
maxAscentOf:aFontId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4264
    "the max ascent"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4265
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4266
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4267
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4268
    XFontStruct *f;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4269
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4270
    if (__isExternalAddress(aFontId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4271
	f = _FontVal(aFontId);
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  4272
	RETURN ( __MKSMALLINT(f->max_bounds.ascent) );
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4273
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4274
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4275
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4276
    self primitiveFailed.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4277
    ^ nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4278
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4279
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4280
maxDescentOf:aFontId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4281
    "the max descent"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4282
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4283
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4284
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4285
    XFontStruct *f;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4286
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4287
    if (__isExternalAddress(aFontId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4288
	f = _FontVal(aFontId);
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  4289
	RETURN ( __MKSMALLINT(f->max_bounds.descent) );
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4290
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4291
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4292
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4293
    self primitiveFailed.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4294
    ^ nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4295
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4296
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4297
maxWidthOfFont:aFontId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4298
    "the width of the widest character"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4299
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4300
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4301
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4302
    XFontStruct *f;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4303
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4304
    if (__isExternalAddress(aFontId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4305
	f = _FontVal(aFontId);
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  4306
	RETURN ( __MKSMALLINT(f->max_bounds.width) );
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4307
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4308
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4309
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4310
    self primitiveFailed.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4311
    ^ nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4312
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4313
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4314
minWidthOfFont:aFontId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4315
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4316
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4317
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4318
    XFontStruct *f;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4319
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4320
    if (__isExternalAddress(aFontId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4321
	f = _FontVal(aFontId);
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  4322
	RETURN ( __MKSMALLINT(f->min_bounds.width) );
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4323
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4324
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4325
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4326
    self primitiveFailed.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4327
    ^ nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4328
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4329
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4330
releaseFont:aFontId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4331
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4332
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4333
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4334
    XFontStruct *f;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4335
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4336
    if (ISCONNECTED) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4337
	if (__isExternalAddress(aFontId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4338
	    f = _FontVal(aFontId);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4339
	    BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4340
	    XFreeFont(myDpy, f);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4341
	    END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4342
	    RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4343
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4344
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4345
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4346
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4347
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4348
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4349
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4350
sizesInFamily:aFamilyName face:aFaceName style:aStyleName
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4351
    "return a set of all available font sizes in aFamily/aFace/aStyle
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4352
     on this display.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4353
     Redefined to handle X's special case of 0-size (which stands for any)"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4354
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4355
    |sizes|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4356
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4357
    sizes := super sizesInFamily:aFamilyName face:aFaceName style:aStyleName.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4358
    (sizes notNil and:[sizes includes:0]) ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4359
	"special: in X11R5 and above, size 0 means:
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4360
	 there are scaled versions in all sizes available"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4361
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4362
	^ #(4 5 6 7 8 9 10 11 12 14 16 18 20 22 24 28 32 48 64)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4363
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4364
    ^ sizes
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4365
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4366
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4367
     Display sizesInFamily:'courier' face:'bold' style:'roman'
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4368
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4369
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4370
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4371
widthOf:aString from:index1 to:index2 inFont:aFontId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4372
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4373
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4374
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4375
    XFontStruct *f;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4376
    char *cp;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4377
    int len, n, i1, i2;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4378
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4379
    if (__bothSmallInteger(index1, index2)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4380
     && __isExternalAddress(aFontId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4381
	f = _FontVal(aFontId);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4382
	i1 = _intVal(index1) - 1;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4383
	i2 = _intVal(index2) - 1;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4384
	if (__isString(aString) || __isSymbol(aString)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4385
	    cp = (char *) _stringVal(aString);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4386
	    n = _stringSize(aString);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4387
	    if ((i1 >= 0) && (i2 >= i1) && (i2 < n)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4388
		cp += i1;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4389
		BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4390
		len = XTextWidth(f, cp, i2 - i1 + 1);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4391
		END_INTERRUPTSBLOCKED
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  4392
		RETURN ( __MKSMALLINT(len) );
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4393
	    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4394
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4395
#ifdef TWOBYTESTRINGS
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4396
	if (__Class(aString) == @global(TwoByteString)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4397
	    cp = (char *) _stringVal(aString);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4398
	    n = _byteArraySize(aString) / 2;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4399
	    if ((i1 >= 0) && (i2 >= i1) && (i2 < n)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4400
		cp += (i1 * 2);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4401
		BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4402
		len = XTextWidth16(f, (XChar2b *)cp, i2 - i1 + 1);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4403
		END_INTERRUPTSBLOCKED
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  4404
		RETURN ( __MKSMALLINT(len) );
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4405
	    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4406
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4407
#endif
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4408
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4409
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4410
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4411
    self primitiveFailed.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4412
    ^ nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4413
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4414
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4415
widthOf:aString inFont:aFontId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4416
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4417
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4418
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4419
    XFontStruct *f;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4420
    char *cp;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4421
    int len, n;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4422
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4423
    if (__isExternalAddress(aFontId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4424
	f = _FontVal(aFontId);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4425
	if (__isString(aString) || __isSymbol(aString)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4426
	    n = _stringSize(aString);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4427
	    cp = (char *)_stringVal(aString);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4428
	    BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4429
	    len = XTextWidth(f, cp, n);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4430
	    END_INTERRUPTSBLOCKED
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  4431
	    RETURN ( __MKSMALLINT(len) );
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4432
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4433
#ifdef TWOBYTESTRINGS
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4434
	if (__Class(aString) == @global(TwoByteString)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4435
	    n = _byteArraySize(aString) / 2;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4436
	    cp = (char *) _stringVal(aString);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4437
	    BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4438
	    len = XTextWidth16(f, (XChar2b *)cp, n);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4439
	    END_INTERRUPTSBLOCKED
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  4440
	    RETURN ( __MKSMALLINT(len) );
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4441
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4442
#endif
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4443
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4444
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4445
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4446
    self primitiveFailed.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4447
    ^ nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4448
! !
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4449
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4450
!XWorkstation methodsFor:'grabbing '!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4451
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4452
allowEvents:mode
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4453
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4454
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4455
    int _mode, ok = 1;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4456
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4457
    if (mode == @symbol(asyncPointer))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4458
	_mode = AsyncPointer;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4459
    else if (mode == @symbol(syncPointer))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4460
	_mode = SyncPointer;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4461
    else if (mode == @symbol(asyncKeyboard))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4462
	_mode = AsyncKeyboard;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4463
    else if (mode == @symbol(syncKeyboard))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4464
	_mode = SyncKeyboard;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4465
    else if (mode == @symbol(syncBoth))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4466
	_mode = SyncBoth;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4467
    else if (mode == @symbol(asyncBoth))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4468
	_mode = AsyncBoth;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4469
    else if (mode == @symbol(replayPointer))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4470
	_mode = ReplayPointer;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4471
    else if (mode == @symbol(replayKeyboard))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4472
	_mode = ReplayKeyboard;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4473
    else
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4474
	ok = 0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4475
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4476
    if (ok) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4477
	BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4478
	XAllowEvents(myDpy, _mode, CurrentTime);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4479
	END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4480
	RETURN (self);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4481
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4482
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4483
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4484
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4485
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4486
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4487
grabKeyboardIn:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4488
    "grab the keyboard"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4489
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4490
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4491
    int result, ok;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4492
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4493
    if (__isExternalAddress(aWindowId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4494
	BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4495
	result = XGrabKeyboard(myDpy,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4496
			       _WindowVal(aWindowId),
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4497
			       True /* False */,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4498
			       GrabModeAsync,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4499
			       GrabModeAsync,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4500
			       CurrentTime);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4501
	END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4502
	ok = 0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4503
	switch(result) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4504
	    case AlreadyGrabbed: 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4505
		printf("XWORKSTAT: grab keyboard: AlreadyGrabbed\n");
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4506
		break;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4507
	    case GrabNotViewable: 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4508
		printf("XWORKSTAT: grab keyboard: GrabNotViewable\n");
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4509
		break;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4510
	    case GrabInvalidTime: 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4511
		printf("XWORKSTAT: grab keyboard: InvalidTime\n");
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4512
		break;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4513
	    case GrabFrozen: 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4514
		printf("XWORKSTAT: grab keyboard: Frozen\n");
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4515
		break;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4516
	    default:
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4517
		ok = 1;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4518
		break;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4519
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4520
	if (! ok) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4521
	    XUngrabKeyboard(myDpy, CurrentTime);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4522
	    RETURN (false);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4523
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4524
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4525
	RETURN ( true );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4526
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4527
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4528
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4529
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4530
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4531
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4532
grabPointerIn:aWindowId withCursor:aCursorId pointerMode:pMode keyboardMode:kMode confineTo:confineId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4533
    "grap the pointer - return true if ok"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4534
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4535
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4536
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4537
    int result, ok;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4538
    Window confineWin;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4539
    Cursor curs;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4540
    int pointer_mode, keyboard_mode;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4541
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4542
    if (__isExternalAddress(aWindowId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4543
	if (__isExternalAddress(confineId)) 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4544
	    confineWin = _WindowVal(confineId);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4545
	else
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4546
	    confineWin = (Window) None;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4547
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4548
	if (__isExternalAddress(aCursorId)) 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4549
	    curs = _CursorVal(aCursorId);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4550
	else
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4551
	    curs = (Cursor) None;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4552
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4553
	if (pMode == @symbol(sync))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4554
	    pointer_mode = GrabModeSync;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4555
	else
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4556
	    pointer_mode = GrabModeAsync;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4557
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4558
	if (kMode == @symbol(sync))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4559
	    keyboard_mode = GrabModeSync;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4560
	else
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4561
	    keyboard_mode = GrabModeAsync;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4562
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4563
	BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4564
	result = XGrabPointer(myDpy,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4565
			      _WindowVal(aWindowId), 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4566
			      False, 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4567
			      ButtonPressMask | ButtonMotionMask | ButtonReleaseMask,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4568
			      pointer_mode, keyboard_mode,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4569
			      confineWin,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4570
			      curs,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4571
			      CurrentTime);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4572
	END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4573
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4574
	ok = 0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4575
	switch (result) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4576
	    case AlreadyGrabbed: 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4577
		printf("XWORKSTAT: grab pointer: AlreadyGrabbed\n");
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4578
		break;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4579
	    case GrabNotViewable: 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4580
		printf("XWORKSTAT: grab pointer: GrabNotViewable\n");
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4581
		break;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4582
	    case GrabInvalidTime: 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4583
		printf("XWORKSTAT: grab pointer: InvalidTime\n");
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4584
		break;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4585
	    case GrabFrozen: 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4586
		printf("XWORKSTAT: grab pointer: Frozen\n");
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4587
		break;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4588
	    default:
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4589
		ok = 1;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4590
		break;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4591
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4592
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4593
	if (! ok) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4594
	    XUngrabPointer(myDpy, CurrentTime);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4595
	    RETURN (false);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4596
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4597
	RETURN ( true );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4598
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4599
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4600
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4601
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4602
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4603
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4604
ungrabKeyboard
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4605
    "release the keyboard"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4606
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4607
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4608
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4609
    if (ISCONNECTED) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4610
	BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4611
	XUngrabKeyboard(myDpy, CurrentTime);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4612
	XSync(myDpy, 0);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4613
	END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4614
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4615
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4616
    activeKeyboardGrab := nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4617
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4618
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4619
ungrabPointer
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4620
    "release the pointer"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4621
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4622
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4623
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4624
    if (ISCONNECTED) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4625
	BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4626
	XUngrabPointer(myDpy, CurrentTime);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4627
	XSync(myDpy, 0);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4628
	END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4629
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4630
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4631
    activePointerGrab := nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4632
! !
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4633
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4634
!XWorkstation methodsFor:'graphic context stuff'!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4635
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4636
noClipIn:aGCId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4637
    "disable clipping rectangle"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4638
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4639
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4640
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4641
    XGCValues gcv;
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  4642
    GC gc;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4643
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4644
    if (__isExternalAddress(aGCId)) {
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  4645
	gc = _GCVal(aGCId);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4646
	gcv.clip_mask = None;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4647
	XChangeGC(myDpy, gc, GCClipMask, &gcv);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4648
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4649
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4650
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4651
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4652
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4653
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4654
setBackground:bgColorIndex in:aGCId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4655
    "set background color to be drawn with"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4656
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4657
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4658
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4659
    if (__isExternalAddress(aGCId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4660
     && __isSmallInteger(bgColorIndex)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4661
	XSetBackground(myDpy, _GCVal(aGCId), _intVal(bgColorIndex));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4662
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4663
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4664
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4665
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4666
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4667
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4668
setBitmapMask:aBitmapId in:aGCId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4669
    "set or clear the drawing mask - a bitmap mask using current fg/bg"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4670
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4671
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4672
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4673
    Display *dpy = myDpy;
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  4674
    GC gc;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4675
    Pixmap bitmap;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4676
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4677
    if (__isExternalAddress(aGCId)) {
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  4678
	gc = _GCVal(aGCId);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4679
	if (__isExternalAddress(aBitmapId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4680
	    bitmap = _PixmapVal(aBitmapId);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4681
	    XSetStipple(dpy, gc, bitmap);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4682
	    XSetFillStyle(dpy, gc, FillOpaqueStippled);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4683
	    RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4684
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4685
	if (aBitmapId == nil) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4686
	    XSetFillStyle(dpy, gc, FillSolid);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4687
	    RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4688
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4689
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4690
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4691
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4692
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4693
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4694
setClipByChildren:aBool in:aGCId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4695
    "enable/disable drawing into child views"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4696
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4697
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4698
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4699
    XGCValues gcv;
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  4700
    GC gc;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4701
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4702
    if (__isExternalAddress(aGCId)) {
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  4703
	gc = _GCVal(aGCId);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4704
	if (aBool == true)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4705
	    gcv.subwindow_mode = ClipByChildren;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4706
	else
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4707
	    gcv.subwindow_mode = IncludeInferiors;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4708
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4709
	XChangeGC(myDpy, gc, GCSubwindowMode, &gcv);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4710
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4711
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4712
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4713
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4714
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4715
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4716
setClipX:clipX y:clipY width:clipWidth height:clipHeight in:aGCId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4717
    "clip to a rectangle"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4718
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4719
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4720
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4721
    XRectangle r;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4722
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4723
    if (__isExternalAddress(aGCId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4724
     && __bothSmallInteger(clipX, clipY)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4725
     && __bothSmallInteger(clipWidth, clipHeight)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4726
	r.x = _intVal(clipX);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4727
	r.y = _intVal(clipY);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4728
	r.width = _intVal(clipWidth);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4729
	r.height = _intVal(clipHeight);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4730
	XSetClipRectangles(myDpy, _GCVal(aGCId), 0, 0, &r, 1, Unsorted);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4731
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4732
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4733
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4734
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4735
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4736
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4737
setFont:aFontId in:aGCId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4738
    "set font to be drawn in"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4739
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4740
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4741
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4742
    XFontStruct *f;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4743
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4744
    if (__isExternalAddress(aFontId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4745
     && __isExternalAddress(aGCId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4746
	f = (XFontStruct *) _FontVal(aFontId);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4747
	XSetFont(myDpy, _GCVal(aGCId), f->fid);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4748
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4749
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4750
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4751
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4752
     aGCId and/or aFontId are invalid
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4753
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4754
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4755
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4756
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4757
setForeground:fgColorIndex background:bgColorIndex in:aGCId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4758
    "set foreground and background colors to be drawn with"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4759
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4760
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4761
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4762
    Display *dpy = myDpy;
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  4763
    GC gc;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4764
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4765
    if (__bothSmallInteger(fgColorIndex, bgColorIndex)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4766
     && __isExternalAddress(aGCId)) {
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  4767
	gc = _GCVal(aGCId);
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  4768
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4769
	XSetForeground(dpy, gc, _intVal(fgColorIndex));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4770
	XSetBackground(dpy, gc, _intVal(bgColorIndex));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4771
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4772
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4773
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4774
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4775
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4776
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4777
setForeground:fgColor background:bgColor mask:aBitmapId in:aGCId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4778
    "set foreground and background colors to be drawn with using mask or
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4779
     solid (if aBitmapId is nil)"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4780
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4781
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4782
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4783
    Display *dpy = myDpy;
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  4784
    GC gc;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4785
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4786
    if (__isExternalAddress(aGCId)) {
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  4787
	gc = _GCVal(aGCId);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4788
	if (__isSmallInteger(fgColor))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4789
	    XSetForeground(dpy, gc, _intVal(fgColor));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4790
	if (__isSmallInteger(bgColor))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4791
	    XSetBackground(dpy, gc, _intVal(bgColor));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4792
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4793
	if (__isExternalAddress(aBitmapId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4794
	    XSetStipple(dpy, gc, _PixmapVal(aBitmapId));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4795
	    XSetFillStyle(dpy, gc, FillOpaqueStippled);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4796
	    RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4797
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4798
	if (aBitmapId == nil) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4799
	    XSetFillStyle(dpy, gc, FillSolid);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4800
	    RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4801
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4802
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4803
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4804
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4805
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4806
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4807
setForeground:fgColor background:bgColor mask:aBitmapId lineWidth:lw in:aGCId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4808
    "set foreground and background colors to be drawn with using mask or
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4809
     solid (if aBitmapId is nil); also set lineWidth"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4810
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4811
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4812
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4813
    Display *dpy = myDpy;
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  4814
    GC gc;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4815
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4816
    if (__isExternalAddress(aGCId)) {
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  4817
	gc = _GCVal(aGCId);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4818
	if (__isSmallInteger(lw)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4819
	    XSetLineAttributes(dpy, gc, _intVal(lw),
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4820
				    LineSolid, CapNotLast, JoinMiter);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4821
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4822
	if (__isSmallInteger(fgColor))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4823
	    XSetForeground(dpy, gc, _intVal(fgColor));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4824
	if (__isSmallInteger(bgColor))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4825
	    XSetBackground(dpy, gc, _intVal(bgColor));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4826
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4827
	if (__isExternalAddress(aBitmapId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4828
	    XSetStipple(dpy, gc, _PixmapVal(aBitmapId));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4829
	    XSetFillStyle(dpy, gc, FillOpaqueStippled);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4830
	    RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4831
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4832
	if (aBitmapId == nil) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4833
	    XSetFillStyle(dpy, gc, FillSolid);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4834
	    RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4835
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4836
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4837
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4838
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4839
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4840
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4841
setForeground:fgColorIndex in:aGCId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4842
    "set foreground color to be drawn with"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4843
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4844
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4845
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4846
    if (__isExternalAddress(aGCId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4847
     && __isSmallInteger(fgColorIndex)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4848
	XSetForeground(myDpy, _GCVal(aGCId), _intVal(fgColorIndex));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4849
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4850
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4851
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4852
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4853
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4854
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4855
setFunction:aFunctionSymbol in:aGCId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4856
    "set alu function to be drawn with"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4857
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4858
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4859
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  4860
    GC gc;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4861
    int fun = -1;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4862
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4863
    if (__isExternalAddress(aGCId)) {
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  4864
	gc = _GCVal(aGCId);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4865
	if (aFunctionSymbol == @symbol(copy)) fun = GXcopy;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4866
	else if (aFunctionSymbol == @symbol(copyInverted)) fun = GXcopyInverted;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4867
	else if (aFunctionSymbol == @symbol(xor)) fun = GXxor;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4868
	else if (aFunctionSymbol == @symbol(and)) fun = GXand;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4869
	else if (aFunctionSymbol == @symbol(andReverse)) fun = GXandReverse;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4870
	else if (aFunctionSymbol == @symbol(andInverted)) fun = GXandInverted;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4871
	else if (aFunctionSymbol == @symbol(or)) fun = GXor;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4872
	else if (aFunctionSymbol == @symbol(orReverse)) fun = GXorReverse;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4873
	else if (aFunctionSymbol == @symbol(orInverted)) fun = GXorInverted;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4874
	if (fun != -1) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4875
	    XSetFunction(myDpy, gc, fun);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4876
	    RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4877
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4878
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4879
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4880
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4881
     either aGCId is not an integer, or an invalid symbol
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4882
     was passed ... valid functions are #copy, #copyInverted, #xor, #and, #andReverse,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4883
     #andInverted, #or, #orReverse, #orInverted. See Xlib documentation for more details.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4884
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4885
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4886
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4887
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4888
setGraphicsExposures:aBoolean in:aGCId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4889
    "set or clear the graphics exposures flag"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4890
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4891
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4892
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4893
    if (__isExternalAddress(aGCId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4894
	XSetGraphicsExposures(myDpy, _GCVal(aGCId), (aBoolean==true)?1:0);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4895
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4896
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4897
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4898
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4899
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4900
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4901
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4902
setLineWidth:aNumber style:lineStyle cap:capStyle join:joinStyle in:aGCId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4903
    "set line attributes"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4904
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4905
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4906
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4907
    int x_style, x_cap, x_join;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4908
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4909
    if (__isExternalAddress(aGCId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4910
     && __isSmallInteger(aNumber)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4911
	if (lineStyle == @symbol(solid)) x_style = LineSolid;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4912
	else if (lineStyle == @symbol(dashed)) x_style = LineOnOffDash;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4913
	else if (lineStyle == @symbol(doubleDashed)) x_style = LineDoubleDash;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4914
	else  goto bad;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4915
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4916
	if (capStyle == @symbol(notLast)) x_cap = CapNotLast;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4917
	else if (capStyle == @symbol(butt)) x_cap = CapButt;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4918
	else if (capStyle == @symbol(round)) x_cap  = CapRound;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4919
	else if (capStyle == @symbol(projecting)) x_cap  = CapProjecting;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4920
	else  goto bad;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4921
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4922
	if (joinStyle == @symbol(miter)) x_join = JoinMiter;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4923
	else if (joinStyle == @symbol(bevel)) x_join = JoinBevel;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4924
	else if (joinStyle == @symbol(round)) x_join  = JoinRound;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4925
	else  goto bad;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4926
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4927
	XSetLineAttributes(myDpy,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4928
			   _GCVal(aGCId), _intVal(aNumber),
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4929
			   x_style, x_cap, x_join);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4930
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4931
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4932
bad: ;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4933
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4934
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4935
     either aGCId is invalid,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4936
     and/or lineStyle is none of #solid, #dashed, #doubleDashed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4937
     and/or capStyle is none of #notLast, #butt, #round, #projecting
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4938
     and/or joinStyle is none of #miter, #bevel, #round
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4939
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4940
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4941
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4942
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4943
setMaskOriginX:orgX y:orgY in:aGCid
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4944
    "set the mask origin"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4945
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4946
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4947
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4948
    if (__bothSmallInteger(orgX, orgY) && __isExternalAddress(aGCid)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4949
	XSetTSOrigin(myDpy, _GCVal(aGCid), _intVal(orgX), _intVal(orgY));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4950
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4951
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4952
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4953
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4954
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4955
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4956
setPixmapMask:aPixmapId in:aGCId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4957
    "set or clear the drawing mask - a pixmap mask providing full color"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4958
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4959
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4960
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4961
    Display *dpy = myDpy;
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  4962
    GC gc;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4963
    Pixmap pixmap;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4964
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4965
    if (__isExternalAddress(aGCId)) {
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  4966
	gc = _GCVal(aGCId);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4967
	if (__isExternalAddress(aPixmapId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4968
	    pixmap = _PixmapVal(aPixmapId);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4969
	    XSetTile(dpy, gc, pixmap);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4970
	    XSetFillStyle(dpy, gc, FillTiled);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4971
	    RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4972
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4973
	if (aPixmapId == nil) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4974
	    XSetFillStyle(dpy, gc, FillSolid);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4975
	    RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4976
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4977
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4978
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4979
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4980
! !
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4981
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4982
!XWorkstation methodsFor:'initialize / release'!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4983
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4984
close
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4985
    "close down the connection to the X-server"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4986
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4987
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4988
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4989
    if (ISCONNECTED) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4990
	BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4991
	XCloseDisplay(myDpy);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4992
	_INST(displayId) = nil;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4993
	END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4994
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4995
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4996
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4997
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4998
initializeDefaultValues
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4999
    buttonTranslation := ButtonTranslation.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5000
    multiClickTimeDelta := MultiClickTimeDelta.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5001
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5002
    self initializeModifierMappings
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5003
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5004
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5005
initializeEventBuffer
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5006
    |sz|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5007
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5008
%{
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  5009
    sz = __MKSMALLINT(sizeof(XEvent) + 100);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5010
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5011
    eventBuffer isNil ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5012
	eventBuffer := ByteArray new:sz.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5013
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5014
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5015
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5016
initializeFor:aDisplayName
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5017
    "initialize the receiver for a connection to an X-Server;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5018
     the argument, aDisplayName may be nil (for the default server from
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5019
     DISPLAY-variable or command line argument) or the name of the server 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5020
     as hostname:number"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5021
334
8c851e8a0b05 access comandline args via access method
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  5022
    |dpyName index arguments|
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5023
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5024
    dpyName := aDisplayName.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5025
    dpyName isNil ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5026
	"look for a '-display xxx' argument"
334
8c851e8a0b05 access comandline args via access method
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  5027
	(arguments := Smalltalk commandLineArguments) notNil ifTrue:[
8c851e8a0b05 access comandline args via access method
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  5028
	    index := arguments indexOf:'-display'.
8c851e8a0b05 access comandline args via access method
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  5029
	    (index between:1 and:(arguments size - 1)) ifTrue:[
8c851e8a0b05 access comandline args via access method
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  5030
		dpyName := arguments at:index+1
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5031
	    ]
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5032
	]
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5033
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5034
%{
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5035
    int scr;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5036
    Display *dpy;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5037
    Visual *visual;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5038
    XVisualInfo viproto;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5039
    XVisualInfo *vip;                   /* retured info */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5040
    int maxRGBDepth;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5041
    int rgbRedMask, rgbGreenMask, rgbBlueMask;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5042
    int rgbVisualID;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5043
    int nvi, i;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5044
    int shapeEventBase, shapeErrorBase;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5045
    int shmEventBase, shmErrorBase;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5046
    int faxEventBase, faxErrorBase;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5047
    char *type, *nm;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5048
    int dummy;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5049
    OBJ dpyID;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5050
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5051
    if (_INST(displayId) != nil) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5052
	/*
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5053
	 * already connected - you bad guy try to
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5054
	 * trick me manually ?
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5055
	 */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5056
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5057
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5058
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5059
    BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5060
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5061
    if (__isString(dpyName))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5062
	nm = (char *)_stringVal(dpyName);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5063
    else {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5064
	dpyName = __MKSTRING((char *)getenv("DISPLAY") COMMA_CON);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5065
	nm = NULL;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5066
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5067
    dpy = XOpenDisplay(nm);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5068
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5069
    if (dpy) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5070
	_INST(displayId) = dpyID = __MKOBJ(dpy); __STORE(self, dpyID);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5071
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5072
#ifdef SUPERDEBUG
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5073
	XSynchronize(dpy, 1);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5074
#endif
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5075
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5076
	XSetErrorHandler(__XErrorHandler__);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5077
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5078
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5079
    END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5080
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5081
    displayId isNil ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5082
	'XWORKSTATION: cannot connect to Display.' errorPrintNL.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5083
	^ nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5084
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5085
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5086
    dispatching := false.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5087
    dispatchingExpose := false.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5088
    isSlow := false.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5089
    shiftDown := false.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5090
    ctrlDown := false.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5091
    metaDown := false.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5092
    altDown := false.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5093
    motionEventCompression := true.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5094
    buttonsPressed := 0.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5095
    displayName := dpyName.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5096
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5097
    protocolsAtom := nil.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5098
    deleteWindowAtom := nil.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5099
    saveYourselfAtom := nil.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5100
    quitAppAtom := nil.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5101
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5102
    self initializeScreenProperties.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5103
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5104
    self initializeDefaultValues.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5105
    self initializeEventBuffer.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5106
    self initializeSpecialFlags.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5107
    self initializeKeyboardMap.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5108
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5109
    ObjectMemory registerErrorInterruptHandler:self class forID:#DisplayError.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5110
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5111
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5112
initializeModifierMappings
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5113
    |map mod|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5114
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5115
"/    altModifiers := #(Alt_L Alt_R).
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5116
"/    metaModifiers := #(Meta_L Meta_R).
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5117
"/    ctrlModifiers := #(Control_L Control_R).
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5118
"/    shiftModifiers := #(Shift_L Shift_R).
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5119
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5120
    shiftModifiers := ctrlModifiers := altModifiers := metaModifiers := nil.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5121
    altModifierMask := metaModifierMask := nil.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5122
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5123
    map := self modifierMapping.
342
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5124
    map isNil ifTrue:[
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5125
	"/
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5126
	"/ mhmh - a crippled Xlib which does not provide modifier mappings
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5127
	"/ setup some reasonable default. If that is not sufficient,
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5128
	"/ you have to change things from your display.rc file.
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5129
	"/
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5130
	altModifierMask := self modifier1Mask.
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5131
	metaModifierMask := self modifier2Mask.
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5132
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5133
	shiftModifiers := #(Shift_L Shift_R Shift).
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5134
	ctrlModifiers := #(Control_L Control_R Control).
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5135
	metaModifiers := #(Alt_L Meta_L Meta_R Meta).
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5136
	altModifiers := #(Alt_R Alt).
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5137
    ] ifFalse:[
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5138
	altModifierMask := 0.
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5139
        metaModifierMask := 0.
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5140
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5141
        mod := map at:1.
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5142
        mod notNil ifTrue:[
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5143
	    shiftModifiers := mod collect:[ :key | self stringFromKeycode:key ].
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5144
        ].
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5145
        mod := map at:3.
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5146
        mod notNil ifTrue:[
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5147
	    ctrlModifiers  := mod collect:[ :key | self stringFromKeycode:key ].
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5148
        ].
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5149
        mod := map at:4.
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5150
        mod notNil ifTrue:[
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5151
	    metaModifiers  := mod collect:[ :key | self stringFromKeycode:key ].    
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5152
	    metaModifierMask := 1 bitShift:(4-1).
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5153
        ].
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5154
        mod := map at:5.
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5155
        mod notNil ifTrue:[
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5156
	    altModifiers   := mod collect:[ :key | self stringFromKeycode:key ].    
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5157
	    altModifierMask := 1 bitShift:(5-1).
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5158
	]
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5159
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5160
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5161
    "Modified: 1.12.1995 / 23:44:40 / stefan"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5162
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5163
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5164
initializeScreenProperties
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5165
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5166
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5167
    Display *dpy = myDpy;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5168
    int scr;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5169
    Visual *visual;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5170
    XVisualInfo viproto;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5171
    XVisualInfo *vip;                   /* retured info */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5172
    int maxRGBDepth;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5173
    int rgbRedMask, rgbGreenMask, rgbBlueMask;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5174
    int rgbVisualID;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5175
    int nvi, i;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5176
    int shapeEventBase, shapeErrorBase;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5177
    int shmEventBase, shmErrorBase;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5178
    int faxEventBase, faxErrorBase;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5179
    char *type, *nm;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5180
    int dummy;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5181
    int mask, shift, nBits;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5182
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5183
    if (ISCONNECTED) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5184
	_INST(altModifierMask) = __MKSMALLINT(Mod2Mask);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5185
	_INST(metaModifierMask) = __MKSMALLINT(Mod1Mask);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5186
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5187
	BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5188
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  5189
	_INST(screen) = __MKSMALLINT(scr = DefaultScreen(dpy));
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  5190
	_INST(depth) = __MKSMALLINT(DisplayPlanes(dpy, scr));
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  5191
	_INST(ncells) = __MKSMALLINT(DisplayCells(dpy, scr));
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  5192
	_INST(width) = __MKSMALLINT(DisplayWidth(dpy, scr));
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  5193
	_INST(height) = __MKSMALLINT(DisplayHeight(dpy, scr));
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  5194
	_INST(widthMM) = __MKSMALLINT(DisplayWidthMM(dpy, scr));
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  5195
	_INST(heightMM) = __MKSMALLINT(DisplayHeightMM(dpy, scr));
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  5196
	_INST(blackpixel) = __MKSMALLINT(BlackPixel(dpy, scr));
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  5197
	_INST(whitepixel) = __MKSMALLINT(WhitePixel(dpy, scr));
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5198
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5199
#ifdef SHAPE
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5200
	if (XShapeQueryExtension(dpy, &shapeEventBase, &shapeErrorBase))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5201
	    _INST(hasShapeExtension) = true;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5202
	else
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5203
#endif
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5204
	  _INST(hasShapeExtension) = false;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5205
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5206
#ifdef SHM
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5207
	if (XShmQueryExtension(dpy, &shmEventBase, &shmErrorBase))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5208
	    _INST(hasShmExtension) = true;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5209
	else
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5210
#endif
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5211
	  _INST(hasShmExtension) = false;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5212
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5213
#ifdef FAX
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5214
	if (XFAXImageQueryExtension(dpy, &faxEventBase, &faxErrorBase))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5215
	    _INST(hasFaxExtension) = true;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5216
	else
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5217
#endif
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5218
	  _INST(hasFaxExtension) = false;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5219
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5220
#ifdef DPS
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5221
	if (XQueryExtension(dpy, "DPSExtension", &dummy, &dummy, &dummy))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5222
	    _INST(hasDPSExtension) = true;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5223
	else
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5224
#endif
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5225
	  _INST(hasDPSExtension) = false;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5226
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5227
#ifdef XVIDEO
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5228
	if (XQueryExtension(dpy, "XVideo", &dummy, &dummy, &dummy))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5229
	    _INST(hasXVideoExtension) = true;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5230
	else
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5231
#endif
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5232
	  _INST(hasXVideoExtension) = false;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5233
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5234
#ifdef MBUF
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5235
	if (XQueryExtension(dpy, "Multi-Buffering", &dummy, &dummy, &dummy))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5236
	    _INST(hasMbufExtension) = true;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5237
	else
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5238
#endif
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5239
	  _INST(hasMbufExtension) = false;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5240
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5241
#ifdef PEX5
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5242
	if (XQueryExtension(dpy, PEX_NAME_STRING, &dummy, &dummy, &dummy))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5243
	    _INST(hasPEXExtension) = true;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5244
	else
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5245
#endif
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5246
	  _INST(hasPEXExtension) = false;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5247
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5248
#ifdef XIE
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5249
	if (XQueryExtension(dpy, xieExtName, &dummy, &dummy, &dummy))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5250
	    _INST(hasImageExtension) = true;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5251
	else
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5252
#endif
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5253
	  _INST(hasImageExtension) = false;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5254
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5255
#ifdef XI
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5256
	if (XQueryExtension(dpy, "XInputExtension", &dummy, &dummy, &dummy))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5257
	    _INST(hasInputExtension) = true;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5258
	else
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5259
#endif
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5260
	  _INST(hasInputExtension) = false;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5261
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5262
	/*
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5263
	 * look for RGB visual
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5264
	 */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5265
	nvi = 0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5266
	viproto.screen = scr;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5267
	vip = XGetVisualInfo (dpy, VisualScreenMask, &viproto, &nvi);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5268
	maxRGBDepth = 0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5269
	for (i = 0; i < nvi; i++) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5270
	    switch (vip[i].class) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5271
		case TrueColor:
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5272
		    if (vip[i].depth > maxRGBDepth) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5273
			maxRGBDepth = vip[i].depth;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5274
			rgbRedMask = vip[i].red_mask;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5275
			rgbGreenMask = vip[i].green_mask;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5276
			rgbBlueMask = vip[i].blue_mask;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5277
			rgbVisualID = vip[i].visualid;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5278
		    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5279
		    break;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5280
	    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5281
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5282
	if (vip) XFree ((char *) vip);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5283
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5284
	if (maxRGBDepth) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5285
	    _INST(rgbVisual) = __MKOBJ(rgbVisualID); __STORESELF(rgbVisual);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5286
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5287
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5288
	visual = DefaultVisualOfScreen(DefaultScreenOfDisplay(dpy));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5289
	_INST(monitorType) = @symbol(unknown);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5290
	_INST(hasColors) = true;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5291
	_INST(hasGreyscales) = true;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5292
	switch (visual->class) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5293
	    case StaticGray:
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5294
		_INST(visualType) = @symbol(StaticGray);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5295
		_INST(hasColors) = false;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5296
		_INST(monitorType) = @symbol(monochrome);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5297
		break;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5298
	    case GrayScale:
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5299
		_INST(visualType) = @symbol(GrayScale);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5300
		_INST(hasColors) = false;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5301
		_INST(monitorType) = @symbol(monochrome);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5302
		break;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5303
	    case StaticColor:
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5304
		_INST(visualType) = @symbol(StaticColor);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5305
		break;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5306
	    case PseudoColor:
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5307
		_INST(visualType) = @symbol(PseudoColor);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5308
		break;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5309
	    case TrueColor:
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5310
		_INST(visualType) = @symbol(TrueColor);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5311
		break;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5312
	    case DirectColor:
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5313
		_INST(visualType) = @symbol(DirectColor);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5314
		break;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5315
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5316
	if (DisplayCells(dpy, scr) == 2) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5317
	    _INST(hasColors) = false;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5318
	    _INST(hasGreyscales) = false;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5319
	    _INST(monitorType) = @symbol(monochrome);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5320
	}
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  5321
	_INST(bitsPerRGB) = __MKSMALLINT(visual->bits_per_rgb);
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  5322
	_INST(redMask)   = __MKSMALLINT(visual->red_mask);
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  5323
	_INST(greenMask) = __MKSMALLINT(visual->green_mask);
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  5324
	_INST(blueMask)  = __MKSMALLINT(visual->blue_mask);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5325
	switch (visual->class) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5326
	    case TrueColor:
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5327
		/* extract number of bits and shift counts */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5328
		mask = visual->red_mask;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5329
		shift = 0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5330
		while (mask && ((mask & 1) == 0)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5331
		    mask >>= 1;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5332
		    shift++;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5333
		}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5334
		_INST(redShift) = __MKSMALLINT(shift);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5335
		nBits = 0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5336
		while (mask) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5337
		    mask >>= 1;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5338
		    nBits++;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5339
		}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5340
		_INST(bitsRed) = __MKSMALLINT(nBits);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5341
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5342
		mask = visual->green_mask;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5343
		shift = 0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5344
		while (mask && ((mask & 1) == 0)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5345
		    mask >>= 1;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5346
		    shift++;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5347
		}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5348
		_INST(greenShift) = __MKSMALLINT(shift);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5349
		nBits = 0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5350
		while (mask) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5351
		    mask >>= 1;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5352
		    nBits++;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5353
		}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5354
		_INST(bitsGreen) = __MKSMALLINT(nBits);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5355
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5356
		mask = visual->blue_mask;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5357
		shift = 0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5358
		while (mask && ((mask & 1) == 0)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5359
		    mask >>= 1;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5360
		    shift++;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5361
		}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5362
		_INST(blueShift) = __MKSMALLINT(shift);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5363
		nBits = 0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5364
		while (mask) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5365
		    mask >>= 1;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5366
		    nBits++;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5367
		}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5368
		_INST(bitsBlue) = __MKSMALLINT(nBits);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5369
		break;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5370
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5371
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5372
#ifndef XA_PRIMARY
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5373
	_INST(primaryAtom) = __MKATOMOBJ( XInternAtom(dpy, "PRIMARY", True) );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5374
#else
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5375
	_INST(primaryAtom) = __MKATOMOBJ( XA_PRIMARY );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5376
#endif
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5377
#ifndef XA_SECONDARY
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5378
	_INST(secondaryAtom) = __MKATOMOBJ( XInternAtom(dpy, "SECONDARY", True) );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5379
#else
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5380
	_INST(secondaryAtom) = __MKATOMOBJ( XA_SECONDARY );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5381
#endif
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5382
#ifndef XA_CUT_BUFFER0
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5383
	_INST(cutBuffer0Atom) = __MKATOMOBJ( XInternAtom(dpy, "CUT_BUFFER0", True) );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5384
#else
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5385
	_INST(cutBuffer0Atom) = __MKATOMOBJ( XA_CUT_BUFFER0 );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5386
#endif
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5387
#ifndef XA_STRING
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5388
	_INST(stringAtom) = __MKATOMOBJ( XInternAtom(dpy, "STRING", True) );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5389
#else
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5390
	_INST(stringAtom) = __MKATOMOBJ( XA_STRING );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5391
#endif
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5392
#ifndef XA_LENGTH
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5393
	_INST(lengthAtom) = __MKATOMOBJ( XInternAtom(dpy, "LENGTH", True) );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5394
#else
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5395
	_INST(lengthAtom) = __MKATOMOBJ( XA_LENGTH );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5396
#endif
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5397
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5398
	END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5399
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5400
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5401
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5402
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5403
initializeSpecialFlags
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5404
    "perform additional special server implementation flags"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5405
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5406
    "/
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5407
    "/ assume we have it ... (should check)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5408
    "/
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5409
    hasSaveUnder := true.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5410
    ignoreBackingStore := false.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5411
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5412
    (self serverVendor = 'X11/NeWS') ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5413
	"/
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5414
	"/ this is a kludge around a bug in the X11/NeWS server,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5415
	"/ which does not correctly handle saveUnder
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5416
	"/
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5417
	hasSaveUnder := false.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5418
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5419
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5420
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5421
reinitialize
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5422
    virtualRootId := rootId := nil.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5423
    super reinitialize.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5424
    dispatchingExpose := nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5425
! !
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5426
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5427
!XWorkstation methodsFor:'keyboard mapping'!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5428
341
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5429
altModifierMask:aSmallInteger
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5430
    "define which key takes the role of an alt-key.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5431
     By default, this is X's modifier1, which is the ALT key on
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5432
     most keyboards. However, there may be exceptions to this,
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5433
     and the setting can be changed with:
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5434
	Display altModifierMask:(Display modifier2Mask)
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5435
     Setting the mask to 0 disables the ALT key (in ST/X) altogether.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5436
    "
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5437
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5438
    altModifierMask := aSmallInteger
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5439
!
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5440
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5441
metaModifierMask:aSmallInteger
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5442
    "define which key takes the role of a meta key.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5443
     By default, this is X's modifier2, which is the 2nd ALT key on
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5444
     most keyboards (if present at all).
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5445
     However, there may be exceptions to this, and the setting can
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5446
     be changed with:
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5447
	Display metaModifierMask:(Display modifier1Mask)
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5448
     Setting the mask to 0 disables the META key (in ST/X) altogether.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5449
     As reported, some Xservers place the Meta-key onto NumLock,
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5450
     and having NumLock enabled makes ST/X think, that meta is pressed
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5451
     all the time. On those, you should disable the meta key by setting
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5452
     the mask to 0.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5453
    "
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5454
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5455
    metaModifierMask := aSmallInteger
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5456
!
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5457
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5458
modifier1Mask
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5459
    "return the Xlib mask bit for the 1st modifier key.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5460
     See comment in altModifierMask: / metaModifierMask: for what
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5461
     this could be used."
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5462
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5463
%{  /* NOCONTEXT */
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5464
    RETURN (__MKSMALLINT(Mod1Mask));
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5465
%}
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5466
!
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5467
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5468
modifier2Mask
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5469
    "return the Xlib mask bit for the 2nd modifier key.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5470
     See comment in altModifierMask: / metaModifierMask: for what
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5471
     this could be used."
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5472
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5473
%{  /* NOCONTEXT */
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5474
    RETURN (__MKSMALLINT(Mod2Mask));
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5475
%}
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5476
!
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5477
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5478
modifierMapping
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5479
    "Get the Modifier Mapping.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5480
     We return an array of arrays of keycodes"
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5481
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5482
    |modifierKeyMap maxKeyPerMod ret nextKey|
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5483
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5484
%{
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5485
    Display *dpy = myDpy;
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5486
    XModifierKeymap *modmap;
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5487
    OBJ __BYTEARRAY_UNINITIALIZED_NEW_INT();
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5488
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5489
    if (ISCONNECTED) {
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5490
	if ((modmap = XGetModifierMapping(myDpy)) != 0) {
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5491
	   maxKeyPerMod = __MKSMALLINT(modmap->max_keypermod);
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5492
	   modifierKeyMap = __BYTEARRAY_UNINITIALIZED_NEW_INT(modmap->max_keypermod * 8);
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5493
	   if (modifierKeyMap != nil) {
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5494
		maxKeyPerMod = __MKSMALLINT(modmap->max_keypermod);
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5495
		memcpy((char *)__ByteArrayInstPtr(modifierKeyMap)->ba_element, 
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5496
		       (char *)modmap->modifiermap, modmap->max_keypermod * 8);
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5497
	   }
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5498
	   XFreeModifiermap(modmap);
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5499
	}
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5500
    }
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5501
%}.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5502
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5503
    modifierKeyMap isNil ifTrue:[^ nil].
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5504
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5505
    ret := Array new:8.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5506
    nextKey := 1.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5507
    1 to:8 do:[ :i |
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5508
	(modifierKeyMap at:nextKey) ~= 0 ifTrue:[
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5509
	    |mod|
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5510
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5511
	    mod := OrderedCollection new:maxKeyPerMod.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5512
	    modifierKeyMap from:nextKey to:(nextKey+maxKeyPerMod-1) do:[ :key |
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5513
		key ~= 0 ifTrue:[
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5514
		    mod add:key
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5515
		].
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5516
	    ].
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5517
	    ret at:i put:mod.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5518
	].
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5519
	nextKey := nextKey+maxKeyPerMod.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5520
    ].
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5521
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5522
    ^ ret
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5523
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5524
    "
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5525
	Display modifierMapping
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5526
    "
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5527
!
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5528
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5529
stringFromKeycode:code
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5530
    "Get a KeySymbol (a smalltalk symbol) from the keycode."
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5531
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5532
    |str|
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5533
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5534
%{
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5535
    Display *dpy = myDpy;
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5536
    KeySym keysym;
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5537
    char *keystring;
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5538
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5539
    if (ISCONNECTED && __isSmallInteger(code)) {
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5540
	if ((keysym = XKeycodeToKeysym(myDpy, __intVal(code), 0)) != NoSymbol &&
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5541
	    (keystring = XKeysymToString(keysym)) != 0) 
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5542
	    str = __MKSTRING(keystring);
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5543
    }
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5544
%}.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5545
    ^ str
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5546
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5547
    "
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5548
	Display stringFromKeycode:28
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5549
    "
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5550
!
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5551
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5552
translateKey:untranslatedKey
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5553
    "Return the key translated via the translation table.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5554
     Here, we preTranslate the key into a common ST/X symbolic name, 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5555
     which gets further processed in the superclasses translation method."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5556
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5557
    |key|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5558
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5559
    (key := untranslatedKey) isString ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5560
	key := RawKeysymTranslation at:key ifAbsent:key.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5561
	key := key asSymbol.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5562
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5563
    ^ super translateKey:key 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5564
! !
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5565
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5566
!XWorkstation methodsFor:'misc'!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5567
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5568
beep
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5569
    "output an audible beep or bell"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5570
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5571
    self beep:50
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5572
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5573
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5574
beep:volumeInPercent
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5575
    "output an audible beep"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5576
%{
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5577
    int volume;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5578
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5579
    if (__isSmallInteger(volumeInPercent) && ISCONNECTED) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5580
	/* stupid: X wants -100 .. 100 and calls this percent */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5581
	volume = _intVal(volumeInPercent) * 2 - 100;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5582
	if (volume < -100) volume = -100;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5583
	else if (volume > 100) volume = 100;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5584
	BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5585
	XBell(myDpy, volume);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5586
	END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5587
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5588
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5589
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5590
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5591
buffered
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5592
    "buffer drawing - do not send it immediately to the display.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5593
     This is the default anyway."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5594
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5595
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5596
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5597
    if (ISCONNECTED) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5598
	BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5599
	XSynchronize(myDpy, 0);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5600
	END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5601
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5602
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5603
    "Display buffered"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5604
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5605
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5606
flush
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5607
    "send all buffered drawing to the display.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5608
     This may be required to make certain, that all previous operations
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5609
     are really sent to the display before continuing. For example,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5610
     after a cursor-change with a followup long computation.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5611
     (otherwise, the cursor change request may still be in the output
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5612
      buffer)"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5613
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5614
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5615
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5616
    if (ISCONNECTED) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5617
	BEGIN_INTERRUPTSBLOCKED
310
6ed27eebc243 stefans event queue changes
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
  5618
	XFlush(myDpy);
6ed27eebc243 stefans event queue changes
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
  5619
	END_INTERRUPTSBLOCKED
6ed27eebc243 stefans event queue changes
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
  5620
    }
6ed27eebc243 stefans event queue changes
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
  5621
%}
6ed27eebc243 stefans event queue changes
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
  5622
!
6ed27eebc243 stefans event queue changes
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
  5623
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5624
flushDpsContext:aDPSContext
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5625
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5626
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5627
#ifdef DPS
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5628
    if (__isExternalAddress(aDPSContext)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5629
	BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5630
	DPSFlushContext(MKDPSCONTEXT(aDPSContext));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5631
	END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5632
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5633
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5634
#endif
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5635
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5636
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5637
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5638
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5639
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5640
refreshKeyboardMapping:eB
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5641
%{
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5642
    XMappingEvent *ev;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5643
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5644
    if (__isByteArray(eB)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5645
	ev = (XMappingEvent *)(_ByteArrayInstPtr(eB)->ba_element);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5646
	XRefreshKeyboardMapping(ev);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5647
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5648
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5649
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5650
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5651
setInputFocusTo:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5652
"/    self setInputFocusTo:aWindowId revertTo:#parent
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5653
    self setInputFocusTo:aWindowId revertTo:#root
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5654
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5655
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5656
setInputFocusTo:aWindowId revertTo:revertSymbol
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5657
    "set the focus to the view as defined by aWindowId.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5658
     Passing nil set the focus to no window and lets the display discard all
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5659
     input until a new focus is set.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5660
     RevertSymbol specifies what should happen if the view becomes invisible;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5661
     passing one of #parent, #root or nil specifies that the focus should be
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5662
     given to the parent view, the root view or no view."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5663
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5664
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5665
    int arg;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5666
    Window focusWindow;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5667
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5668
    if (ISCONNECTED) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5669
	if (__isExternalAddress(aWindowId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5670
	    focusWindow = _WindowVal(aWindowId);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5671
	} else {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5672
	    focusWindow = None;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5673
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5674
	if (revertSymbol == @symbol(parent))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5675
	    arg = RevertToParent;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5676
	else if (revertSymbol == @symbol(root))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5677
	    arg = RevertToPointerRoot;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5678
	else 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5679
	    arg = RevertToNone;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5680
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5681
	BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5682
	XSetInputFocus(myDpy, focusWindow, arg, CurrentTime);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5683
	END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5684
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5685
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5686
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5687
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5688
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5689
341
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5690
sync
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5691
    "send all buffered drawing to the display AND wait until the display
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5692
     has finished drawing it.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5693
     This is almost never needed, except if you are about to read previously
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5694
     drawn pixels back from the display svreen."
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5695
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5696
%{  /* NOCONTEXT */
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5697
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5698
    if (ISCONNECTED) {
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5699
	BEGIN_INTERRUPTSBLOCKED
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5700
	XSync(myDpy, 0);
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5701
	END_INTERRUPTSBLOCKED
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5702
    }
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5703
%}
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5704
!
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  5705
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5706
unBuffered
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5707
    "make all drawing be sent immediately to the display"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5708
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5709
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5710
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5711
    if (ISCONNECTED) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5712
	BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5713
	XSynchronize(myDpy, 1);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5714
	END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5715
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5716
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5717
    "Display unbuffered"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5718
! !
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5719
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5720
!XWorkstation methodsFor:'pointer queries '!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5721
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5722
buttonStates
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5723
    "return an integer representing the state of the pointer buttons;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5724
     a one-bit in positions 0.. represent a pressed button"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5725
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5726
%{  /* NOCONTEXT*/
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5727
    Display *dpy = myDpy;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5728
    Window w;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5729
    int screen = _intVal(_INST(screen));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5730
    Window rootRet, childRet;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5731
    int rootX, rootY, winX, winY;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5732
    unsigned int mask;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5733
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5734
    BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5735
#ifdef VIRTUAL_ROOT
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5736
    w = getRootWindow(myDpy, screen);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5737
#else
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5738
    w = RootWindow(dpy, screen);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5739
#endif
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5740
    XQueryPointer(dpy, w, &rootRet, &childRet,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5741
			  &rootX, &rootY,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5742
			  &winX, &winY,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5743
			  &mask);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5744
    END_INTERRUPTSBLOCKED
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  5745
    RETURN (__MKSMALLINT(mask));
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5746
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5747
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5748
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5749
leftButtonStateMask
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5750
    "return an integer for masking out the left button from a
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5751
     buttonStates value"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5752
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5753
    ^ 256
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5754
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5755
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5756
middleButtonStateMask
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5757
    "return an integer for masking out the middle button from a
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5758
     buttonStates value"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5759
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5760
    ^ 512
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5761
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5762
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5763
pointerPosition
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5764
    "return the current pointer position in root-window coordinates"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5765
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5766
    |xpos ypos|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5767
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5768
%{
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5769
    Display *dpy = myDpy;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5770
    Window w;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5771
    int screen = _intVal(_INST(screen));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5772
    Window rootRet, childRet;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5773
    int rootX, rootY, winX, winY;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5774
    unsigned int mask;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5775
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5776
    BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5777
#ifdef VIRTUAL_ROOT
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5778
    w = getRootWindow(myDpy, screen);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5779
#else
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5780
    w = RootWindow(dpy, screen);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5781
#endif
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5782
    XQueryPointer(dpy, w, &rootRet, &childRet,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5783
			  &rootX, &rootY,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5784
			  &winX, &winY,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5785
			  &mask);
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  5786
    xpos = __MKSMALLINT(rootX);
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  5787
    ypos = __MKSMALLINT(rootY);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5788
    END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5789
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5790
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5791
    ^ xpos @ ypos
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5792
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5793
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5794
rightButtonStateMask
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5795
    "return an integer for masking out the right button from a
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5796
     buttonStates value"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5797
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5798
    ^ 1024
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5799
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5800
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5801
rootPositionOfLastEvent
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5802
    "return the position in root-window coordinates
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5803
     of the last button, key or pointer event"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5804
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5805
    ^ eventRootX @ eventRootY
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5806
! !
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5807
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5808
!XWorkstation methodsFor:'resources'!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5809
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5810
getResource:name class:cls
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5811
%{
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5812
    char *rslt;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5813
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5814
    if ((__isString(name) || __isSymbol(name))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5815
     && (__isString(cls) || __isSymbol(cls))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5816
     && ISCONNECTED) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5817
	BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5818
	rslt = XGetDefault(myDpy, (char *)_stringVal(cls),
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5819
				  (char *)_stringVal(name));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5820
	END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5821
	RETURN (rslt ? __MKSTRING(rslt COMMA_CON) : nil );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5822
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5823
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5824
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5825
    self primitiveFailed.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5826
    ^ nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5827
! !
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5828
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5829
!XWorkstation methodsFor:'retrieving pixels'!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5830
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5831
getBitsFrom:aDrawableId x:srcx y:srcy width:w height:h into:imageBits
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5832
    "get bits from a drawable into the imageBits. The storage for the bits
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5833
     must be big enough for the data to fit. If ok, returns an array with some
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5834
     info and the bits in imageBits. The info contains the depth, bitOrder and
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5835
     number of bytes per scanline. The number of bytes per scanline is not known
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5836
     in advance, since the X-server is free to return whatever it thinks is a good padding."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5837
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5838
    |info|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5839
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5840
    ((w <= 0) or:[h <= 0]) ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5841
	self primitiveFailed.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5842
	^ nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5843
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5844
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5845
    info := Array with:nil "depth"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5846
		  with:nil "bit order"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5847
		  with:nil "bytes_per_line"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5848
		  with:nil "byte_order".
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5849
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5850
    "/ had to extract the getPixel call into a separate method, to specify
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5851
    "/ unlimitedStack (some implementations use alloca and require huge amounts
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5852
    "/ of temporary stack space
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5853
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5854
    (self primGetBitsFrom:aDrawableId x:srcx y:srcy width:w height:h into:imageBits infoInfo:info) ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5855
	^ info
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5856
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5857
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5858
     some error occured - either args are not smallintegers, imageBits is not a ByteArray
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5859
     or is too small to hold the bits
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5860
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5861
    ^ self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5862
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5863
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5864
getPixelX:x y:y from:aDrawableId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5865
    "return the pixel value at x/y; coordinates start at 0/0 for the upper left."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5866
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5867
%{  /* UNLIMITEDSTACK NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5868
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  5869
    Window win;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5870
    XImage *img;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5871
    int ret;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5872
    int xpos, ypos;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5873
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5874
    if (__isExternalAddress(aDrawableId) && __bothSmallInteger(x, y)) {
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  5875
	win = _WindowVal(aDrawableId);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5876
	xpos = _intVal(x);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5877
	ypos = _intVal(y);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5878
	if ((xpos < 0) || (ypos < 0)) {
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  5879
	    RETURN ( __MKSMALLINT(0) );
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5880
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5881
	img = XGetImage(myDpy, win, xpos, ypos, 1, 1, (unsigned)~0, ZPixmap);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5882
	ret = XGetPixel(img, 0, 0);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5883
	XDestroyImage(img);
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  5884
	RETURN (  __MKSMALLINT(ret) );
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5885
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5886
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5887
    ^ nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5888
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5889
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5890
primGetBitsFrom:aDrawableId x:srcx y:srcy width:w height:h into:imageBits infoInfo:info
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5891
    "since XGetImage may allocate huge amount of stack space 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5892
     (some implementations use alloca), this must run with unlimited stack."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5893
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5894
%{  /* UNLIMITEDSTACK */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5895
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5896
    Display *dpy = myDpy;
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  5897
    Window win;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5898
    XImage *image = (XImage *)0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5899
    int pad, bytes_per_line, numBytes;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5900
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5901
    if (__isExternalAddress(aDrawableId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5902
     && __bothSmallInteger(srcx, srcy)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5903
     && __bothSmallInteger(w, h)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5904
     && __isArray(info)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5905
     && __isByteArray(imageBits)) {
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  5906
	win = _WindowVal(aDrawableId);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5907
	image = XGetImage(dpy, win, _intVal(srcx), _intVal(srcy),
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5908
				    _intVal(w), _intVal(h),
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5909
				    (unsigned)AllPlanes, ZPixmap);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5910
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5911
	pad = image->bitmap_pad;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5912
#ifdef SUPERDEBUG
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5913
	printf("pad:%d depth:%d\n", image->bitmap_pad, image->depth);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5914
#endif
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5915
	switch (image->depth) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5916
	    case 1:
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5917
	    case 2:
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5918
	    case 4:
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5919
	    case 8:
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5920
	    case 16:
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5921
	    case 24:
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5922
	    case 32:
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5923
		numBytes = image->bytes_per_line * image->height;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5924
		break;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5925
	    default:
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5926
		/* unsupported depth */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5927
		printf("unsupported depth:%d in primGetBits\n", image->depth);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5928
		goto fail;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5929
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5930
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5931
#ifdef SUPERDEBUG
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5932
	printf("bytes need:%d bytes given:%d\n", numBytes, _byteArraySize(imageBits));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5933
#endif
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5934
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5935
	if (numBytes > _byteArraySize(imageBits)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5936
	    /* imageBits too small */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5937
	    goto fail;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5938
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5939
	if (image->bitmap_bit_order == MSBFirst)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5940
	    _ArrayInstPtr(info)->a_element[0] = @symbol(msbFirst);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5941
	else
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5942
	    _ArrayInstPtr(info)->a_element[0] = @symbol(lsbFirst);
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  5943
	_ArrayInstPtr(info)->a_element[1] = __MKSMALLINT(image->depth);
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  5944
	_ArrayInstPtr(info)->a_element[2] = __MKSMALLINT(image->bytes_per_line);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5945
	if (image->byte_order == MSBFirst)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5946
	    _ArrayInstPtr(info)->a_element[3] = @symbol(msbFirst);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5947
	else
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5948
	    _ArrayInstPtr(info)->a_element[3] = @symbol(lsbFirst);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5949
	bcopy(image->data, _ByteArrayInstPtr(imageBits)->ba_element, numBytes);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5950
	XDestroyImage(image);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5951
	RETURN ( true );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5952
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5953
fail: 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5954
    if (image) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5955
	XDestroyImage(image);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5956
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5957
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5958
    ^ false
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5959
! !
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5960
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5961
!XWorkstation methodsFor:'selections'!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5962
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5963
atomIDOf:aStringOrSymbol
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5964
    "return an Atoms ID; dont create if not already present"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5965
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5966
    ^ self atomIDOf:aStringOrSymbol create:false
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5967
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5968
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5969
atomIDOf:aStringOrSymbol create:create
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5970
    "return an Atoms ID; if create is true, create it if not already present"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5971
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5972
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5973
    Atom prop;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5974
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5975
    if (ISCONNECTED) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5976
	if (__isString(aStringOrSymbol)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5977
	 || __isSymbol(aStringOrSymbol)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5978
	    prop = XInternAtom(myDpy, _stringVal(aStringOrSymbol), 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5979
				      (create == true) ? False : True);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5980
	    if (prop == None) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5981
		RETURN (nil);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5982
	    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5983
	    RETURN ( __MKATOMOBJ(prop) );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5984
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5985
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5986
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5987
    self primitiveFailed.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5988
    ^ nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5989
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5990
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5991
     Display atomIDOf:'VT_SELECTION' create:false
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5992
     Display atomIDOf:'CUT_BUFFER0' create:false
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5993
     Display atomIDOf:'STRING' create:false
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5994
     Display atomIDOf:'PRIMARY' create:false
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5995
     Display atomIDOfPRIMARY
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5996
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5997
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5998
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5999
atomIDOfCUTBUFFER0
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6000
    ^ cutBuffer0Atom
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6001
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6002
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6003
atomIDOfLENGTH
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6004
    ^ lengthAtom
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6005
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6006
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6007
atomIDOfPRIMARY
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6008
    ^ primaryAtom
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6009
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6010
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6011
atomIDOfSECONDARY
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6012
    ^ secondaryAtom
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6013
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6014
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6015
atomIDOfSTRING
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6016
    ^ stringAtom
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6017
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6018
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6019
atomName:anAtomID
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6020
%{  /* NOCONTEXT */ 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6021
    OBJ str;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6022
    char *name;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6023
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6024
    if (ISCONNECTED) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6025
	if (__isAtomID(anAtomID)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6026
	    name = XGetAtomName(myDpy, _AtomVal(anAtomID));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6027
	    if (name == 0) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6028
		RETURN (nil);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6029
	    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6030
	    str = __MKSTRING(name COMMA_CON);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6031
	    XFree(name);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6032
	    RETURN ( str );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6033
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6034
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6035
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6036
    self primitiveFailed.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6037
    ^ nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6038
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6039
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6040
     Display atomName:1
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6041
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6042
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6043
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6044
getObjectProperty:propertyID from:aWindowID
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6045
    "get an object property; return object or nil"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6046
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6047
    self getProperty:propertyID from:aWindowID into:[:type :value |
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6048
	type == stringAtom ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6049
	    ^ value
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6050
	].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6051
	(value isMemberOf:ByteArray) ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6052
	    ^ (Object readBinaryFrom:(ReadStream on:value) onError:[nil])
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6053
	]
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6054
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6055
    ^ nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6056
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6057
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6058
getProperty:propertyID from:aWindowID into:aTwoArgBlock
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6059
    "get a property, evaluate aTwoArgBlock with typeID and value"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6060
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6061
    |val typeID cls|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6062
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6063
    cls := ByteArray.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6064
%{
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6065
    Display *dpy = myDpy;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6066
    Window window;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6067
    Atom property;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6068
    char *cp, *cp2;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6069
    Atom actual_type;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6070
    int actual_format,i;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6071
    unsigned long nitems, bytes_after, nread;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6072
    unsigned char *data;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6073
    int ok = 1;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6074
    OBJ __new(), __MKSTRING_L();
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6075
#   define PROP_SIZE    2048
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6076
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6077
    if (__isAtomID(propertyID)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6078
	property = _AtomVal(propertyID);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6079
	if (__isExternalAddress(aWindowID)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6080
	    window = _WindowVal(aWindowID);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6081
	} else {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6082
	    window = DefaultRootWindow(dpy);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6083
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6084
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6085
	nread = 0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6086
	cp = 0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6087
/*
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6088
	fprintf(stderr, "getProperty: ");
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6089
 */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6090
	do {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6091
	    if (XGetWindowProperty(dpy,window,property,nread/4,PROP_SIZE,False,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6092
				   AnyPropertyType,&actual_type,&actual_format,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6093
				   &nitems,&bytes_after,(unsigned char **)&data)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6094
		!= Success) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6095
		    ok = 0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6096
		    break;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6097
	    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6098
	    typeID = __MKATOMOBJ(actual_type);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6099
	    if (! cp) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6100
		cp = cp2 = (char *)malloc(nitems+1);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6101
	    } else {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6102
		cp = (char *)realloc(cp, nread + nitems + 1);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6103
		cp2 = cp + nread;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6104
	    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6105
	    if (! cp) goto fail;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6106
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6107
	    nread += nitems;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6108
	    bcopy(data, cp2, nitems);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6109
	    XFree(data);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6110
/*
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6111
	    fprintf(stderr, "<nitems:%d bytes_after:%d>", nitems, bytes_after);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6112
 */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6113
	} while (bytes_after > 0);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6114
/*
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6115
	fprintf(stderr, "\n");
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6116
 */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6117
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6118
	if (ok) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6119
	    if (actual_type == XA_STRING) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6120
		cp[nread] = '\0';
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6121
		val = __MKSTRING_L(cp, nread COMMA_CON);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6122
	    } else {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6123
		val = __new(nread + OHDR_SIZE);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6124
		val->o_class = cls;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6125
		bcopy(cp, _ByteArrayInstPtr(val)->ba_element, nread);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6126
	    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6127
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6128
	if (cp)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6129
	    free(cp);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6130
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6131
fail: ;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6132
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6133
    typeID isNil ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6134
	^ false
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6135
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6136
    aTwoArgBlock value:typeID value:val.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6137
    ^ true
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6138
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6139
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6140
getSelectionFor:drawableId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6141
    "get the object selection -  either immediate, or asynchronous.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6142
     Returns nil, if async request is on its way"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6143
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6144
    |selProp sel|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6145
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6146
    (self getSelectionOwnerOf:primaryAtom) isNil ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6147
	"no primary selection - use cut buffer"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6148
	sel := self getObjectProperty:cutBuffer0Atom from:nil.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6149
	^ sel
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6150
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6151
    selProp := self atomIDOf:'ST_SELECTION' create:true.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6152
    self requestObjectSelection:primaryAtom property:selProp for:drawableId.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6153
    ^ nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6154
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6155
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6156
getSelectionOwnerOf:selectionAtomID
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6157
    "get the owner of a selection"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6158
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6159
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6160
    Display *dpy = myDpy;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6161
    Atom selection;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6162
    Window window;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6163
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6164
    if (__isAtomID(selectionAtomID) && ISCONNECTED) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6165
	window = XGetSelectionOwner(dpy, _AtomVal(selectionAtomID));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6166
	RETURN ((window == None) ? nil : __MKOBJ(window));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6167
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6168
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6169
     self primitiveFailed.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6170
    ^ nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6171
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6172
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6173
getTextProperty:propertyID from:aWindowID
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6174
    "get a text property; return string or nil"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6175
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6176
    self getProperty:propertyID from:aWindowID into:[:type :value |
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6177
	type == stringAtom ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6178
	    ^ value
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6179
	]
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6180
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6181
    ^ nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6182
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6183
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6184
getTextSelectionFor:drawableId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6185
    "get the text selection -  either immediate, or asynchronous.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6186
     Returns nil, if async request is on its way"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6187
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6188
    |selProp sel|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6189
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6190
    (self getSelectionOwnerOf:primaryAtom) isNil ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6191
	"no primary selection - use cut buffer"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6192
	sel := self getTextProperty:cutBuffer0Atom from:nil.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6193
	^ sel
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6194
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6195
    selProp := self atomIDOf:'VT_SELECTION' create:true.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6196
    self requestTextSelection:primaryAtom property:selProp for:drawableId.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6197
    ^ nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6198
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6199
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6200
requestObjectSelection:selectionID property:propertyID for:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6201
    "ask the server to send us the selection - the view with ID aWindowID
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6202
     will later receive a SelectionNotify event for it."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6203
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6204
    ^ self requestSelection:selectionID 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6205
		   property:propertyID 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6206
		   type:(self atomIDOf:'ST_OBJECT' create:true) 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6207
		   for:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6208
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6209
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6210
requestSelection:selectionID property:propertyID type:typeID for:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6211
    "ask the server to send us the selection - the view with id aWindowID
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6212
     will later receive a SelectionNotify event for it (once the Xserver replies
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6213
     with the selections value)."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6214
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6215
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6216
    Display *dpy = myDpy;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6217
    Atom sel_prop;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6218
    char *cp;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6219
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6220
    if (__isExternalAddress(aWindowId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6221
     && ISCONNECTED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6222
     && __isSmallInteger(typeID)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6223
     && __isAtomID(selectionID)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6224
	if (XGetSelectionOwner(dpy, _AtomVal(selectionID)) == None) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6225
	    /*
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6226
	     * no owner of primary selection
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6227
	     */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6228
	    RETURN (false);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6229
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6230
	/*
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6231
	 * PRIMARY selection
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6232
	 */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6233
	XConvertSelection(dpy, _AtomVal(selectionID), _AtomVal(typeID), 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6234
			       _AtomVal(propertyID), _WindowVal(aWindowId), CurrentTime);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6235
	RETURN (true);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6236
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6237
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6238
    self primitiveFailed.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6239
    ^ false
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6240
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6241
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6242
     Display requestSelection:(Display atomIDOf:'PRIMARY')
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6243
		     property:(Display atomIDOf:'VT_SELECTION')
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6244
			  for:0
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6245
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6246
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6247
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6248
requestTextSelection:selectionID property:propertyID for:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6249
    "ask the server to send us the selection - the view with ID aWindowID
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6250
     will later receive a SelectionNotify event for it."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6251
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6252
    ^ self requestSelection:selectionID 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6253
		   property:propertyID 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6254
		       type:stringAtom 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6255
			for:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6256
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6257
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6258
sendSelection:something property:propertyID target:targetID from:windowID to:requestorID
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6259
    "send aString back from a SelectionRequest"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6260
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6261
    self 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6262
	sendSelection:something 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6263
	selection:primaryAtom
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6264
	property:propertyID 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6265
	target:targetID 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6266
	from:windowID 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6267
	to:requestorID
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6268
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6269
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6270
sendSelection:something selection:selectionID property:propertyID target:targetID from:windowID to:requestorID
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6271
    "send aString back from a SelectionRequest"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6272
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6273
    self 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6274
	setProperty:propertyID 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6275
	type:targetID 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6276
	value:something 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6277
	for:requestorID.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6278
    self 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6279
	sendSelectionNotifySelection:selectionID 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6280
	property:propertyID 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6281
	target:targetID 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6282
	from:requestorID 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6283
	to:requestorID.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6284
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6285
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6286
sendSelectionNotifySelection:selectionID property:propertyID target:targetID from:windowID to:requestorID
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6287
    "send a selectionNotify back from a SelectionRequest"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6288
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6289
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6290
    Display *dpy = myDpy;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6291
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6292
    if (__isAtomID(propertyID)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6293
     && __isExternalAddress(requestorID)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6294
     && ISCONNECTED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6295
     && __isAtomID(targetID)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6296
     && __isAtomID(selectionID)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6297
	XEvent ev;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6298
	Window requestor = _WindowVal(requestorID);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6299
	Atom property = _AtomVal(propertyID);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6300
	Atom target = _AtomVal(targetID);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6301
	Atom selection = _AtomVal(selectionID);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6302
	Status result;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6303
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6304
	ev.xselection.type = SelectionNotify;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6305
	ev.xselection.selection = selection;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6306
	ev.xselection.target = target;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6307
	if (__isExternalAddress(windowID))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6308
	    ev.xselection.requestor = _WindowVal(windowID);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6309
	else
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6310
	    ev.xselection.requestor = DefaultRootWindow(dpy);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6311
	ev.xselection.time = CurrentTime;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6312
	if (property == None)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6313
	    ev.xselection.property = target;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6314
	else
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6315
	    ev.xselection.property = property;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6316
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6317
	DPRINTF(("sending SelectionNotify sel=%x prop=%x target=%x requestor=%x to %x\n",
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6318
		ev.xselection.selection,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6319
		ev.xselection.property,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6320
		ev.xselection.target,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6321
		ev.xselection.requestor,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6322
		requestor));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6323
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6324
	result = XSendEvent(dpy, requestor, False, 0 , &ev);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6325
	if ((result == BadValue) || (result == BadWindow)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6326
	    DPRINTF(("bad status\n"));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6327
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6328
	RETURN (self )
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6329
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6330
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6331
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6332
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6333
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6334
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6335
setLengthProperty:propertyID value:aNumber for:aWindowID
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6336
    ^ self setProperty:propertyID type:(self atomIDOfLENGTH) value:aNumber for:aWindowID
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6337
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6338
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6339
setObjectProperty:propertyID value:anObject for:aWindowID
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6340
    |s|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6341
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6342
    (anObject isMemberOf:String) ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6343
	^ self setTextProperty:propertyID value:anObject for:aWindowID
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6344
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6345
    s := WriteStream on:(ByteArray new:200).
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6346
    anObject storeBinaryOn:s.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6347
    ^ self 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6348
	setProperty:propertyID 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6349
	type:(self atomIDOf:'ST_OBJECT' create:true) 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6350
	value:(s contents) 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6351
	for:aWindowID
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6352
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6353
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6354
setProperty:propertyID type:typeID value:anObject for:aWindowID
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6355
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6356
%{  /* UNLIMITEDSTACK */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6357
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6358
    Display *dpy = myDpy;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6359
    Atom prop, type;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6360
    Window window;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6361
    unsigned int value;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6362
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6363
    if (__isAtomID(propertyID)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6364
     && __isAtomID(typeID) 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6365
     && ISCONNECTED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6366
     && (__isString(anObject) 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6367
	 || __isSmallInteger(anObject) 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6368
	 || __isSymbol(anObject) 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6369
	 || __isByteArray(anObject))) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6370
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6371
	prop = _AtomVal(propertyID);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6372
	type = _AtomVal(typeID);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6373
	if (__isExternalAddress(aWindowID)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6374
	    window = _WindowVal(aWindowID);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6375
	} else {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6376
	    window = DefaultRootWindow(dpy);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6377
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6378
	if (__isSmallInteger(anObject)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6379
	    value = _intVal(anObject);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6380
	    XChangeProperty(dpy, window, prop, type, 32,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6381
			    PropModeReplace,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6382
			    (unsigned char *)(&value), sizeof(unsigned int));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6383
	} else {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6384
	    if (__isByteArray(anObject)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6385
		XChangeProperty(dpy, window, prop, type, 8,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6386
				PropModeReplace,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6387
				_ByteArrayInstPtr(anObject)->ba_element,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6388
				_byteArraySize(anObject));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6389
	    } else {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6390
		/* string or symbol */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6391
		XChangeProperty(dpy, window, prop, XA_STRING, 8,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6392
				PropModeReplace,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6393
				_stringVal(anObject),
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6394
				strlen(_stringVal(anObject)));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6395
	    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6396
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6397
	RETURN (true);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6398
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6399
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6400
    ^ false
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6401
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6402
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6403
setSelection:anObject owner:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6404
    "set the object selection, and make aWindowId be the owner.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6405
     This can be used by other Smalltalk(X) applications only."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6406
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6407
    (self setSelectionOwner:aWindowId of:primaryAtom) ifFalse:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6408
	^ false
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6409
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6410
"/    ^ self setObjectProperty:cutBuffer0Atom value:anObject for:nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6411
    ^ true
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6412
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6413
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6414
setSelectionOwner:aWindowId of:selectionID
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6415
    "set the owner of a selection; return false if failed"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6416
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6417
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6418
    Display *dpy = myDpy;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6419
    Window win;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6420
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6421
    if (__isExternalAddress(aWindowId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6422
     && __isAtomID(selectionID)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6423
     && ISCONNECTED) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6424
	win = _WindowVal(aWindowId);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6425
	XSetSelectionOwner(dpy, _AtomVal(selectionID), win, CurrentTime);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6426
	if (XGetSelectionOwner(dpy, _AtomVal(selectionID)) != win) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6427
	    RETURN (false);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6428
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6429
	RETURN (true);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6430
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6431
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6432
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6433
    self primitiveFailed.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6434
    ^ nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6435
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6436
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6437
setTextProperty:propertyID value:aString for:aWindowID
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6438
    ^ self setProperty:propertyID type:(self atomIDOfSTRING) value:aString for:aWindowID
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6439
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6440
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6441
setTextSelection:aString owner:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6442
    "set the text selection, and make aWindowId be the owner.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6443
     This can be used by any other X application."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6444
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6445
    (self setSelectionOwner:aWindowId of:primaryAtom) ifFalse:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6446
	'ownerchange failed' errorPrintNL.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6447
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6448
    ^ self setTextProperty:cutBuffer0Atom value:aString for:nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6449
! !
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6450
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6451
!XWorkstation methodsFor:'window stuff'!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6452
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6453
clearRectangleX:x y:y width:width height:height in:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6454
    "clear a rectangular area to viewbackground"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6455
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6456
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6457
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6458
    int w, h;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6459
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6460
    if (__isExternalAddress(aWindowId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6461
     && __bothSmallInteger(x, y)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6462
     && __bothSmallInteger(width, height)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6463
	w = _intVal(width);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6464
	h = _intVal(height);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6465
	if (w < 0) w = 0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6466
	if (h < 0) h = 0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6467
	XClearArea(myDpy, _WindowVal(aWindowId), _intVal(x), _intVal(y), w, h, 0);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6468
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6469
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6470
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6471
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6472
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6473
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6474
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6475
clearWindow:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6476
    "clear a window to viewbackground"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6477
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6478
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6479
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6480
    if (__isExternalAddress(aWindowId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6481
	XClearWindow(myDpy, _WindowVal(aWindowId));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6482
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6483
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6484
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6485
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6486
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6487
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6488
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6489
configureWindow:aWindowId sibling:siblingId stackMode:modeSymbol
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6490
    "configure stacking operation of aWindowId w.r.t siblingId"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6491
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6492
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6493
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6494
    XWindowChanges chg;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6495
    int mask = CWSibling | CWStackMode;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6496
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6497
    if (__isExternalAddress(aWindowId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6498
     && __isExternalAddress(siblingId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6499
	if (modeSymbol == @symbol(above)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6500
	    chg.stack_mode = Above;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6501
	} else if (modeSymbol == @symbol(below)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6502
	    chg.stack_mode = Below;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6503
	} else if (modeSymbol == @symbol(topIf)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6504
	    chg.stack_mode = TopIf;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6505
	} else if (modeSymbol == @symbol(bottomIf)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6506
	    chg.stack_mode = BottomIf;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6507
	} else if (modeSymbol == @symbol(opposite)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6508
	    chg.stack_mode = Opposite;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6509
	} else {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6510
	    mask = CWSibling;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6511
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6512
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6513
	chg.sibling = _WindowVal(siblingId);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6514
	XConfigureWindow(myDpy, _WindowVal(aWindowId),
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6515
				mask, &chg);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6516
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6517
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6518
bad: ;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6519
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6520
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6521
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6522
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6523
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6524
lowerWindow:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6525
    "bring a window to back"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6526
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6527
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6528
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6529
    if (__isExternalAddress(aWindowId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6530
	XLowerWindow(myDpy, _WindowVal(aWindowId));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6531
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6532
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6533
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6534
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6535
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6536
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6537
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6538
mapView:aView id:aWindowId iconified:aBoolean atX:xPos y:yPos width:w height:h
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6539
    "make a window visible - either as icon or as a real view - needed for restart"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6540
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6541
    |wicon wiconId wiconView wiconViewId wlabel|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6542
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6543
    aBoolean ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6544
	wicon := aView icon.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6545
	wicon notNil ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6546
	    wiconId := wicon id
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6547
	].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6548
	wiconView := aView iconView.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6549
	wiconView notNil ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6550
	    wiconViewId := wiconView id
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6551
	].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6552
	wlabel := aView label.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6553
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6554
%{  
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6555
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6556
    XWMHints wmhints;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6557
    XSizeHints szhints;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6558
    Display *dpy = myDpy;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6559
    Window win;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6560
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6561
    if (__isExternalAddress(aWindowId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6562
	win = _WindowVal(aWindowId);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6563
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6564
	szhints.flags = 0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6565
	if (__bothSmallInteger(xPos, yPos)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6566
	    szhints.x = _intVal(xPos);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6567
	    szhints.y = _intVal(yPos);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6568
	    szhints.flags |= USPosition;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6569
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6570
	if (__bothSmallInteger(w, h)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6571
	    szhints.width = _intVal(w);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6572
	    szhints.height = _intVal(h);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6573
	    szhints.flags |= USSize;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6574
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6575
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6576
	if (aBoolean == true) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6577
	    char *windowName;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6578
	    Pixmap iconBitmap = (Pixmap)0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6579
	    Window iconWindow;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6580
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6581
	    if (__isExternalAddress(wiconId))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6582
		iconBitmap = _PixmapVal(wiconId);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6583
	    else
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6584
		iconBitmap = (Pixmap)0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6585
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6586
	    if (__isExternalAddress(wiconViewId))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6587
		iconWindow = _WindowVal(wiconViewId);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6588
	    else
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6589
		iconWindow = (Window)0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6590
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6591
	    if (__isString(wlabel) || __isSymbol(wlabel))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6592
		windowName = (char *)_stringVal(wlabel);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6593
	    else
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6594
		windowName = "";
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6595
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6596
	    if (iconBitmap || windowName) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6597
		XSetStandardProperties(dpy, win,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6598
					windowName, windowName,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6599
					iconBitmap,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6600
					0, 0, &szhints);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6601
	    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6602
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6603
	    wmhints.flags = 0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6604
	    if (iconBitmap) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6605
		wmhints.flags |= IconPixmapHint;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6606
		wmhints.icon_pixmap = iconBitmap;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6607
	    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6608
	    if (iconWindow) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6609
		wmhints.flags |= IconWindowHint;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6610
		wmhints.icon_window = iconWindow;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6611
	    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6612
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6613
	    wmhints.initial_state = IconicState;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6614
	    wmhints.flags |= StateHint;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6615
	    XSetWMHints(dpy, win, &wmhints);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6616
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6617
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6618
	if (szhints.flags) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6619
	    XSetNormalHints(dpy, win, &szhints);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6620
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6621
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6622
	XMapWindow(dpy, win);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6623
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6624
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6625
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6626
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6627
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6628
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6629
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6630
mapWindow:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6631
    "make a window visible"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6632
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6633
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6634
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6635
    if (__isExternalAddress(aWindowId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6636
	XMapWindow(myDpy, _WindowVal(aWindowId));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6637
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6638
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6639
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6640
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6641
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6642
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6643
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6644
moveResizeWindow:aWindowId x:x y:y width:w height:h
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6645
    "move and resize a window"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6646
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6647
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6648
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6649
    int newWidth, newHeight;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6650
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6651
    if (__isExternalAddress(aWindowId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6652
     && __bothSmallInteger(w, h)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6653
     && __bothSmallInteger(x, y)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6654
	newWidth = _intVal(w);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6655
	newHeight = _intVal(h);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6656
	if (newWidth < 1) newWidth = 1;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6657
	if (newHeight < 1) newHeight = 1;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6658
	XMoveResizeWindow(myDpy, _WindowVal(aWindowId),
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6659
			      _intVal(x), _intVal(y),
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6660
			      newWidth, newHeight);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6661
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6662
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6663
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6664
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6665
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6666
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6667
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6668
moveWindow:aWindowId x:x y:y
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6669
    "move a window"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6670
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6671
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6672
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6673
    if (__isExternalAddress(aWindowId) && __bothSmallInteger(x, y)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6674
	XMoveWindow(myDpy, _WindowVal(aWindowId), _intVal(x), _intVal(y));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6675
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6676
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6677
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6678
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6679
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6680
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6681
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6682
raiseWindow:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6683
    "bring a window to front"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6684
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6685
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6686
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6687
    if (__isExternalAddress(aWindowId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6688
	XRaiseWindow(myDpy, _WindowVal(aWindowId));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6689
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6690
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6691
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6692
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6693
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6694
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6695
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6696
resizeWindow:aWindowId width:w height:h
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6697
    "resize a window"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6698
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6699
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6700
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6701
    int newWidth, newHeight;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6702
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6703
    if (__isExternalAddress(aWindowId) && __bothSmallInteger(w, h)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6704
	newWidth = _intVal(w);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6705
	newHeight = _intVal(h);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6706
	if (newWidth < 1) newWidth = 1;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6707
	if (newHeight < 1) newHeight = 1;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6708
	XResizeWindow(myDpy, _WindowVal(aWindowId), newWidth, newHeight);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6709
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6710
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6711
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6712
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6713
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6714
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6715
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6716
setBackingStore:how in:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6717
    "turn on/off backing-store for a window"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6718
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6719
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6720
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6721
    XSetWindowAttributes wa;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6722
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6723
    if (__isExternalAddress(aWindowId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6724
	if (_INST(ignoreBackingStore) != true) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6725
	    if (how == @symbol(always)) wa.backing_store = Always;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6726
	    else if (how == @symbol(whenMapped)) wa.backing_store = WhenMapped;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6727
	    else if (how == true) wa.backing_store = Always;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6728
	    else wa.backing_store = 0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6729
	    BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6730
	    XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWBackingStore, &wa);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6731
	    END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6732
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6733
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6734
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6735
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6736
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6737
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6738
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6739
setBitGravity:how in:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6740
    "set bit gravity for a window"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6741
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6742
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6743
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6744
    XSetWindowAttributes wa;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6745
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6746
    if (__isExternalAddress(aWindowId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6747
	if (how == @symbol(NorthWest)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6748
	    wa.bit_gravity = NorthWestGravity;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6749
	} else if (how == @symbol(NorthEast)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6750
	    wa.bit_gravity = NorthEastGravity;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6751
	} else if (how == @symbol(SouthWest)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6752
	    wa.bit_gravity = SouthWestGravity;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6753
	} else if (how == @symbol(SouthEast)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6754
	    wa.bit_gravity = SouthEastGravity;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6755
	} else if (how == @symbol(Center)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6756
	    wa.bit_gravity = CenterGravity;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6757
	} else if (how == @symbol(North)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6758
	    wa.bit_gravity = NorthGravity;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6759
	} else if (how == @symbol(South)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6760
	    wa.bit_gravity = SouthGravity;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6761
	} else if (how == @symbol(West)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6762
	    wa.bit_gravity = WestGravity;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6763
	} else if (how == @symbol(East)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6764
	    wa.bit_gravity = EastGravity;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6765
	} else {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6766
	    wa.bit_gravity = NorthWestGravity;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6767
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6768
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6769
	BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6770
	XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWBitGravity, &wa);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6771
	END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6772
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6773
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6774
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6775
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6776
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6777
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6778
setCursor:aCursorId in:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6779
    "define a windows cursor"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6780
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6781
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6782
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6783
    Display *dpy = myDpy;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6784
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6785
    if (__isExternalAddress(aWindowId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6786
     && __isExternalAddress(aCursorId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6787
	XDefineCursor(dpy, _WindowVal(aWindowId), _CursorVal(aCursorId));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6788
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6789
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6790
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6791
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6792
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6793
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6794
setIconName:aString in:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6795
    "define a windows iconname"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6796
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6797
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6798
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6799
    if (__isExternalAddress(aWindowId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6800
     && (__isString(aString) || __isSymbol(aString))) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6801
	XSetIconName(myDpy, _WindowVal(aWindowId), (char *)_stringVal(aString));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6802
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6803
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6804
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6805
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6806
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6807
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6808
setSaveUnder:yesOrNo in:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6809
    "turn on/off save-under for a window"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6810
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6811
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6812
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6813
    XSetWindowAttributes wa;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6814
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6815
    if (__isExternalAddress(aWindowId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6816
	if (_INST(hasSaveUnder) == true) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6817
	    wa.save_under = (yesOrNo == true) ? 1 : 0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6818
	    XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWSaveUnder, &wa);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6819
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6820
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6821
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6822
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6823
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6824
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6825
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6826
setTransient:aWindowId for:aMainWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6827
    "set aWindowId to be a transient of aMainWindow"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6828
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6829
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6830
353
5be3ae3c8838 sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
  6831
    if (__isExternalAddress(aWindowId)) {
5be3ae3c8838 sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
  6832
	Window w;
5be3ae3c8838 sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
  6833
5be3ae3c8838 sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
  6834
	if ((aMainWindowId == nil) || (aMainWindowId == __MKSMALLINT(0))) {
5be3ae3c8838 sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
  6835
	    w = (Window) 0;
5be3ae3c8838 sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
  6836
	} else {
5be3ae3c8838 sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
  6837
            if (__isExternalAddress(aMainWindowId)) {
5be3ae3c8838 sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
  6838
		w = _WindowVal(aMainWindowId);
5be3ae3c8838 sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
  6839
	    } else {
5be3ae3c8838 sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
  6840
		goto getOutOfHere;
5be3ae3c8838 sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
  6841
	    }
5be3ae3c8838 sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
  6842
	}
5be3ae3c8838 sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
  6843
	XSetTransientForHint(myDpy, _WindowVal(aWindowId), w);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6844
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6845
    }
353
5be3ae3c8838 sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
  6846
 getOutOfHere: ;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6847
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6848
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6849
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6850
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6851
setWindowBackground:aColorIndex in:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6852
    "set the windows background color. This is the color with which
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6853
     the view is filled whenever exposed. Do not confuse this with
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6854
     the background drawing color, which is used with opaque drawing."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6855
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6856
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6857
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6858
    if (__isExternalAddress(aWindowId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6859
     && __isSmallInteger(aColorIndex)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6860
	XSetWindowBackground(myDpy, _WindowVal(aWindowId), _intVal(aColorIndex));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6861
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6862
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6863
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6864
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6865
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6866
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6867
setWindowBackgroundPixmap:aPixmapId in:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6868
    "set the windows background pattern to be a form.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6869
     This is the pattern with which the view is filled whenever exposed. 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6870
     Do not confuse this with the background drawing color, which is used 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6871
     with opaque drawing."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6872
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6873
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6874
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6875
    if (__isExternalAddress(aWindowId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6876
     && __isExternalAddress(aPixmapId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6877
	XSetWindowBackgroundPixmap(myDpy, _WindowVal(aWindowId), _PixmapVal(aPixmapId));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6878
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6879
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6880
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6881
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6882
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6883
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6884
setWindowBorderColor:aColorIndex in:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6885
    "set the windows border color"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6886
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6887
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6888
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6889
    if (__isExternalAddress(aWindowId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6890
     && __isSmallInteger(aColorIndex)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6891
	XSetWindowBorder(myDpy, _WindowVal(aWindowId), _intVal(aColorIndex));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6892
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6893
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6894
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6895
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6896
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6897
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6898
setWindowBorderPixmap:aPixmapId in:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6899
    "set the windows border pattern"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6900
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6901
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6902
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6903
    if (__isExternalAddress(aWindowId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6904
     && __isExternalAddress(aPixmapId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6905
	XSetWindowBorderPixmap(myDpy, _WindowVal(aWindowId), _PixmapVal(aPixmapId));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6906
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6907
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6908
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6909
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6910
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6911
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6912
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6913
setWindowBorderShape:aPixmapId in:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6914
    "set the windows border shape"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6915
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6916
    hasShapeExtension ifFalse:[^ self].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6917
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6918
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6919
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6920
#ifdef SHAPE
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6921
    if (__isExternalAddress(aWindowId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6922
     && __isExternalAddress(aPixmapId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6923
	XShapeCombineMask(myDpy, _WindowVal(aWindowId), ShapeBounding,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6924
			  0, 0, _PixmapVal(aPixmapId), ShapeSet);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6925
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6926
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6927
#endif
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6928
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6929
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6930
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6931
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6932
setWindowBorderWidth:aNumber in:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6933
    "set the windows border width"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6934
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6935
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6936
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6937
    if (__isExternalAddress(aWindowId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6938
     && __isSmallInteger(aNumber)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6939
	XSetWindowBorderWidth(myDpy, _WindowVal(aWindowId), _intVal(aNumber));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6940
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6941
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6942
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6943
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6944
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6945
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6946
setWindowGravity:how in:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6947
    "set window gravity for a window"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6948
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6949
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6950
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6951
    XSetWindowAttributes wa;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6952
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6953
    if (__isExternalAddress(aWindowId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6954
	if (how == @symbol(NorthWest)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6955
	    wa.win_gravity = NorthWestGravity;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6956
	} else if (how == @symbol(NorthEast)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6957
	    wa.win_gravity = NorthEastGravity;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6958
	} else if (how == @symbol(SouthWest)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6959
	    wa.win_gravity = SouthWestGravity;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6960
	} else if (how == @symbol(SouthEast)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6961
	    wa.win_gravity = SouthEastGravity;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6962
	} else if (how == @symbol(Center)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6963
	    wa.win_gravity = CenterGravity;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6964
	} else if (how == @symbol(North)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6965
	    wa.win_gravity = NorthGravity;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6966
	} else if (how == @symbol(South)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6967
	    wa.win_gravity = SouthGravity;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6968
	} else if (how == @symbol(West)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6969
	    wa.win_gravity = WestGravity;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6970
	} else if (how == @symbol(East)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6971
	    wa.win_gravity = EastGravity;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6972
	} else {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6973
	    wa.win_gravity = NorthWestGravity;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6974
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6975
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6976
	BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6977
	XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWWinGravity, &wa);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6978
	END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6979
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6980
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6981
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6982
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6983
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6984
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6985
setWindowIcon:aForm in:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6986
    "define a bitmap to be used as icon"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6987
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6988
    |iconId|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6989
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6990
    aForm notNil ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6991
	iconId := aForm id
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6992
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6993
%{
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6994
    if (__isExternalAddress(iconId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6995
     && __isExternalAddress(aWindowId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6996
	XWMHints hints;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6997
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6998
	hints.icon_pixmap = _PixmapVal(iconId);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6999
	hints.flags = IconPixmapHint;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7000
	XSetWMHints(myDpy, _WindowVal(aWindowId), &hints);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7001
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7002
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7003
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7004
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7005
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7006
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7007
setWindowIconWindow:aView in:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7008
    "define a window to be used as icon"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7009
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7010
    |iconWindowId|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7011
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7012
    aView notNil ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7013
	iconWindowId := aView id
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7014
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7015
%{
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7016
    if (__isExternalAddress(iconWindowId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7017
     && __isExternalAddress(aWindowId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7018
	XWMHints wmhints;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7019
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7020
	wmhints.icon_window = _WindowVal(iconWindowId);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7021
	wmhints.flags = IconWindowHint;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7022
	XSetWMHints(myDpy, _WindowVal(aWindowId), &wmhints);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7023
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7024
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7025
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7026
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7027
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7028
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7029
setWindowName:aString in:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7030
    "define a windows name"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7031
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7032
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7033
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7034
    if (__isExternalAddress(aWindowId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7035
     && (__isString(aString) || __isSymbol(aString))) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7036
	XStoreName(myDpy, _WindowVal(aWindowId), (char *)_stringVal(aString));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7037
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7038
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7039
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7040
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7041
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7042
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7043
setWindowShape:aPixmapId in:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7044
    "set the windows shape"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7045
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7046
    hasShapeExtension ifFalse:[^ self].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7047
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7048
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7049
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7050
#ifdef SHAPE
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7051
    if (__isExternalAddress(aWindowId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7052
     && __isExternalAddress(aPixmapId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7053
	XShapeCombineMask(myDpy, _WindowVal(aWindowId), ShapeClip,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7054
			  0, 0,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7055
			  _PixmapVal(aPixmapId), ShapeSet);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7056
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7057
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7058
#endif
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7059
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7060
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7061
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7062
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7063
unmapWindow:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7064
    "make a window invisible"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7065
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7066
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7067
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7068
    if (__isExternalAddress(aWindowId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7069
	XUnmapWindow(myDpy, _WindowVal(aWindowId));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7070
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7071
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7072
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7073
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7074
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7075
! !
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7076
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7077
!XWorkstation class methodsFor:'documentation'!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7078
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7079
version
366
4783fabc35c0 validate GC before freeing
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
  7080
    ^ '$Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.98 1996-01-15 12:49:50 cg Exp $'
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7081
! !
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7082
XWorkstation initialize!