XWorkstation.st
author Claus Gittinger <cg@exept.de>
Wed, 11 Sep 1996 22:12:39 +0200
changeset 1049 59cc92776676
parent 1047 b1ab39266b10
child 1050 b2c03e24d56c
permissions -rw-r--r--
oops - free XGetAtomName string after use
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
1010
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
    14
	instanceVariableNames:'screen hasShapeExtension hasShmExtension hasDPSExtension
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
    15
		hasMbufExtension hasXVideoExtension hasSaveUnder hasPEXExtension
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
    16
		hasImageExtension hasInputExtension ignoreBackingStore blackpixel
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
    17
		whitepixel protocolsAtom deleteWindowAtom saveYourselfAtom
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
    18
		quitAppAtom primaryAtom secondaryAtom cutBuffer0Atom stringAtom
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
    19
		lengthAtom listOfXFonts buttonsPressed eventRootX eventRootY
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
    20
		displayName eventTrace dispatchingExpose rgbVisual virtualRootId
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
    21
		rootId eventBuffer altModifierMask metaModifierMask'
404
0db38d8283a4 removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents: 402
diff changeset
    22
	classVariableNames:'RawKeysymTranslation ConservativeSync'
341
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
    23
	poolDictionaries:''
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
    24
	category:'Interface-Graphics'
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
    25
!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    26
78
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
    27
!XWorkstation primitiveDefinitions!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    28
%{
923
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
    29
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
    30
#define COUNT_RESOURCES
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
    31
#ifdef COUNT_RESOURCES
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
    32
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
    33
static int __cnt_color = 0;
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
    34
static int __cnt_bitmap = 0;
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
    35
static int __cnt_view = 0;
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
    36
static int __cnt_gc = 0;
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
    37
static int __cnt_cursor = 0;
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
    38
static int __cnt_font = 0;
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
    39
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
    40
#endif
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
    41
46
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
    42
/*
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
    43
 * x does a typedef Time - I need Object Time ...
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
    44
 */
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    45
#define Time XTime
48194c26a46c Initial revision
claus
parents:
diff changeset
    46
391
d3cad7c15ae2 well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents: 386
diff changeset
    47
/*
d3cad7c15ae2 well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents: 386
diff changeset
    48
 * x does a #define True / False
d3cad7c15ae2 well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents: 386
diff changeset
    49
 * we are lucky - the ST/X True/False are not needed
d3cad7c15ae2 well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents: 386
diff changeset
    50
 */
d3cad7c15ae2 well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents: 386
diff changeset
    51
#undef True
d3cad7c15ae2 well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents: 386
diff changeset
    52
#undef False
d3cad7c15ae2 well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents: 386
diff changeset
    53
37
c2dc1832c0f1 *** empty log message ***
claus
parents: 36
diff changeset
    54
#ifdef memset
c2dc1832c0f1 *** empty log message ***
claus
parents: 36
diff changeset
    55
# undef memset
c2dc1832c0f1 *** empty log message ***
claus
parents: 36
diff changeset
    56
#endif
c2dc1832c0f1 *** empty log message ***
claus
parents: 36
diff changeset
    57
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    58
#include <stdio.h>
48194c26a46c Initial revision
claus
parents:
diff changeset
    59
#include <X11/Xlib.h>
48194c26a46c Initial revision
claus
parents:
diff changeset
    60
#include <X11/Xutil.h>
48194c26a46c Initial revision
claus
parents:
diff changeset
    61
#include <X11/Xatom.h>
48194c26a46c Initial revision
claus
parents:
diff changeset
    62
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
    63
#define XK_MISCELLANY
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
    64
#include <X11/keysymdef.h>
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
    65
277
eb67c44da084 testing new inline-expression feature of stc - no real change
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
    66
#include <X11/cursorfont.h>
eb67c44da084 testing new inline-expression feature of stc - no real change
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
    67
90
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
    68
/*
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
    69
 * this define adds support for two-byte-strings.
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
    70
 * leaving it undefined does not really save you much
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
    71
 * (the define will vanish)
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
    72
 */
36
b297468551c6 *** empty log message ***
claus
parents: 31
diff changeset
    73
#define TWOBYTESTRINGS
b297468551c6 *** empty log message ***
claus
parents: 31
diff changeset
    74
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    75
/*
847
f7c402bc5983 dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents: 846
diff changeset
    76
 * this define suppresses XAllocColor/XFreeColor on
f7c402bc5983 dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents: 846
diff changeset
    77
 * TrueColor systems - I am not certain, if this is
f7c402bc5983 dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents: 846
diff changeset
    78
 * always legal to do (it works with XFree servers).
f7c402bc5983 dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents: 846
diff changeset
    79
 */
f7c402bc5983 dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents: 846
diff changeset
    80
#define QUICK_TRUE_COLORS
f7c402bc5983 dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents: 846
diff changeset
    81
f7c402bc5983 dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents: 846
diff changeset
    82
/*
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    83
 * shape support works; enabled by -DSHAPE in makefile
48194c26a46c Initial revision
claus
parents:
diff changeset
    84
 * see RoundClock and RoundGlobe examples
48194c26a46c Initial revision
claus
parents:
diff changeset
    85
 */
48194c26a46c Initial revision
claus
parents:
diff changeset
    86
#ifdef SHAPE
48194c26a46c Initial revision
claus
parents:
diff changeset
    87
# include <X11/extensions/shape.h>
48194c26a46c Initial revision
claus
parents:
diff changeset
    88
#endif
48194c26a46c Initial revision
claus
parents:
diff changeset
    89
48194c26a46c Initial revision
claus
parents:
diff changeset
    90
/*
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
    91
 * shared memory extension access is currently not supported
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    92
 * (only query is implemented)
48194c26a46c Initial revision
claus
parents:
diff changeset
    93
 */
48194c26a46c Initial revision
claus
parents:
diff changeset
    94
#ifdef SHM
48194c26a46c Initial revision
claus
parents:
diff changeset
    95
# include <X11/extensions/XShm.h>
48194c26a46c Initial revision
claus
parents:
diff changeset
    96
#endif
48194c26a46c Initial revision
claus
parents:
diff changeset
    97
48194c26a46c Initial revision
claus
parents:
diff changeset
    98
/*
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
    99
 * multiBuffer extension access is currently not supported
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   100
 * (only query is implemented)
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   101
 */
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   102
#ifdef MBUF
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   103
# include <X11/extensions/multibuf.h>
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   104
#endif
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   105
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   106
/*
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   107
 * XVideo extension access is currently not supported
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   108
 * (only query is implemented)
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   109
 */
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   110
#ifdef XVIDEO
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   111
# include <X11/extensions/Xv.h>
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   112
#endif
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   113
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   114
/*
186
claus
parents: 180
diff changeset
   115
 * PEX extension - if available
claus
parents: 180
diff changeset
   116
 */
claus
parents: 180
diff changeset
   117
#ifdef PEX5
claus
parents: 180
diff changeset
   118
# include <PEX5/PEX.h>
claus
parents: 180
diff changeset
   119
#endif
claus
parents: 180
diff changeset
   120
claus
parents: 180
diff changeset
   121
/*
claus
parents: 180
diff changeset
   122
 * XImage extension - if available
claus
parents: 180
diff changeset
   123
 */
claus
parents: 180
diff changeset
   124
#ifdef XIE
claus
parents: 180
diff changeset
   125
# include <X11/extensions/XIE.h>
claus
parents: 180
diff changeset
   126
#endif
claus
parents: 180
diff changeset
   127
claus
parents: 180
diff changeset
   128
/*
90
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   129
 * when I have more time to check it out, I will support display-PS
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   130
 */
48194c26a46c Initial revision
claus
parents:
diff changeset
   131
#ifdef DPS
48194c26a46c Initial revision
claus
parents:
diff changeset
   132
# ifdef sgi
48194c26a46c Initial revision
claus
parents:
diff changeset
   133
#  include <X11/extensions/XDPS.h>
48194c26a46c Initial revision
claus
parents:
diff changeset
   134
#  include <X11/extensions/XDPSlib.h>
48194c26a46c Initial revision
claus
parents:
diff changeset
   135
#  include <X11/extensions/dpsXclient.h>
48194c26a46c Initial revision
claus
parents:
diff changeset
   136
# else
48194c26a46c Initial revision
claus
parents:
diff changeset
   137
#  include <DPS/XDPS.h>
48194c26a46c Initial revision
claus
parents:
diff changeset
   138
#  include <DPS/XDPSlib.h>
48194c26a46c Initial revision
claus
parents:
diff changeset
   139
#  include <DPS/dpsXclient.h>
48194c26a46c Initial revision
claus
parents:
diff changeset
   140
# endif
48194c26a46c Initial revision
claus
parents:
diff changeset
   141
#endif
48194c26a46c Initial revision
claus
parents:
diff changeset
   142
90
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   143
#if defined(IRIX5) || (XlibSpecificationRelease == 6)
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   144
  /*
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   145
   * accessing private data in Display ... sorry
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   146
   */
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   147
# define DISPLAYACCESS(d) ((_XPrivDisplay)d)
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   148
#else
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   149
# define DISPLAYACCESS(d) d
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   150
#endif
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   151
78
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   152
/*
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   153
 * some defines - tired of typing ...
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   154
 */
207
9124817bbb03 use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents: 206
diff changeset
   155
#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
   156
#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
   157
#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
   158
#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
   159
#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
   160
#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
   161
#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
   162
211
b5f925b56e8e Fix example.
Stefan Vogel <sv@exept.de>
parents: 208
diff changeset
   163
#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
   164
#define _AtomVal(o)          __intVal(o)
211
b5f925b56e8e Fix example.
Stefan Vogel <sv@exept.de>
parents: 208
diff changeset
   165
#define __isAtomID(o)        __isSmallInteger(o)
b5f925b56e8e Fix example.
Stefan Vogel <sv@exept.de>
parents: 208
diff changeset
   166
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   167
#define myDpy                _DisplayVal(__INST(displayId))
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   168
#define ISCONNECTED          (__INST(displayId) != nil)
78
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   169
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   170
#ifndef THISCONTEXT_IN_REGISTER
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   171
# define BEGIN_INTERRUPTSBLOCKED /* */
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   172
# define END_INTERRUPTSBLOCKED /* */
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   173
#else
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   174
# define BEGIN_INTERRUPTSBLOCKED        \
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   175
    {                                   \
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
   176
	int needUnblock = 0;            \
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
   177
	extern OBJ __thisContext__;     \
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
   178
					\
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
   179
	__thisContext__ = __thisContext;\
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
   180
	if (!__interruptsBlocked) {     \
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
   181
	    __BLOCKINTERRUPTS();        \
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
   182
	    needUnblock = 1;            \
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
   183
	}
78
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   184
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   185
# define END_INTERRUPTSBLOCKED          \
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
   186
	__thisContext = __thisContext;  \
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
   187
	__thisContext__ = 0;            \
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
   188
	if (needUnblock) {              \
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
   189
	    __UNBLOCKINTERRUPTS();      \
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
   190
	}                               \
78
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   191
    }
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   192
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   193
#endif
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   194
%}
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   195
! !
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   196
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   197
!XWorkstation primitiveVariables!
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   198
%{
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   199
/*
146
claus
parents: 145
diff changeset
   200
 * remembered info from private error handler
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   201
 */
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   202
static char lastErrorMsg[80] = "";
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   203
static unsigned lastRequestCode = 0;
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   204
static unsigned lastMinorCode = 0;
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   205
static unsigned lastResource = 0;
129
752fbb07635a *** empty log message ***
claus
parents: 125
diff changeset
   206
752fbb07635a *** empty log message ***
claus
parents: 125
diff changeset
   207
static int __debug__ = 0;
752fbb07635a *** empty log message ***
claus
parents: 125
diff changeset
   208
#define DPRINTF(x)      if (__debug__) { printf x; }
78
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   209
%}
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   210
! !
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   211
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   212
!XWorkstation primitiveFunctions!
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   213
%{
18
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   214
/*
144
claus
parents: 143
diff changeset
   215
 * catch X-errors and forward as errorInterrupt:#DisplayError,
claus
parents: 143
diff changeset
   216
 * (which itself invokes my handler and optionally raises an exceptionSignal)
90
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   217
 * the implementation below is somewhat wrong: it will
78
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   218
 * report all errors for Display, even though there could be
162
claus
parents: 160
diff changeset
   219
 * more than one display connection. (being fixed, new errorInterrupt mechanism
claus
parents: 160
diff changeset
   220
 * allows passing an additional argument, which is the displayID ...)
18
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   221
 */
963
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
   222
12
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
   223
__XErrorHandler__(dpy, event)
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   224
    Display *dpy;
48194c26a46c Initial revision
claus
parents:
diff changeset
   225
    XErrorEvent *event;
48194c26a46c Initial revision
claus
parents:
diff changeset
   226
{
48194c26a46c Initial revision
claus
parents:
diff changeset
   227
    XGetErrorText(dpy, event->error_code, lastErrorMsg, 80);
48194c26a46c Initial revision
claus
parents:
diff changeset
   228
    if (lastErrorMsg[0] == '\0') {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
   229
	sprintf(lastErrorMsg, "code: %d", event->error_code);
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   230
    }
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   231
    lastRequestCode = event->request_code;
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   232
    lastMinorCode = event->minor_code;
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   233
    lastResource = event->resourceid;
911
c934a49174e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 898
diff changeset
   234
    if ((event->error_code == BadWindow) && (lastRequestCode == 4) && (lastMinorCode == 0)) {
c934a49174e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 898
diff changeset
   235
	/* 
c934a49174e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 898
diff changeset
   236
	 * this is a BadWindow error for X_DestroyWindow.
c934a49174e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 898
diff changeset
   237
	 * ignore it here, since it results from the GC freeing windows
c934a49174e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 898
diff changeset
   238
	 * in non bottom-up window order.
c934a49174e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 898
diff changeset
   239
	 */
c934a49174e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 898
diff changeset
   240
	return 0;
c934a49174e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 898
diff changeset
   241
    }
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   242
254
d6f12ecd7767 ErrorPrinting variable now correctly detected by stc
Claus Gittinger <cg@exept.de>
parents: 250
diff changeset
   243
    if (@global(ErrorPrinting) == true) {
219
9ff0660f447f uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   244
	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
   245
			event->request_code, event->request_code, 
9ff0660f447f uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   246
			event->minor_code, event->minor_code, event->resourceid);
963
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
   247
	fprintf(stderr, "XWORKSTAT: x-error message is [%d] '%s'\n", event->error_code, lastErrorMsg);
218
10072d9beba5 can now turn off Xlib error messages from the errorHandler
Claus Gittinger <cg@exept.de>
parents: 217
diff changeset
   248
    }
43
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
   249
207
9124817bbb03 use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents: 206
diff changeset
   250
    __errorInterruptWithIDAndParameter__(@symbol(DisplayError), __MKOBJ(dpy));
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   251
    return 0;
48194c26a46c Initial revision
claus
parents:
diff changeset
   252
}
48194c26a46c Initial revision
claus
parents:
diff changeset
   253
90
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   254
#ifdef VIRTUAL_ROOT
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   255
/*
18
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   256
 * added since RootWindow-macro is not suficient
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   257
 * when virtual root-windows are involved (i.e. tvtwm)
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   258
 */
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   259
static Window
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   260
getRootWindow(dpy, screen)
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   261
    Display *dpy;
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   262
{
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   263
    Window root;
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   264
    Atom vRootAtom = None;
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   265
    int i;
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   266
    Window rootReturn, parentReturn;
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   267
    Window* children;
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   268
    unsigned int numChildren;
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   269
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   270
    root = RootWindow(dpy, screen);
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   271
    /*
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   272
     * on IRIS, this creates a badwindow error - why ?
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   273
     * children contains a funny window (000034)
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   274
     */
90
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   275
# if !defined(IRIS) || defined(IRIX5)
18
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   276
    if (XQueryTree(dpy, root, &rootReturn, &parentReturn, &children, &numChildren)) {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
   277
	vRootAtom = XInternAtom(dpy, "__SWM_VROOT", True );
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
   278
	if (vRootAtom != None) {
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
   279
	    for (i=0; i < numChildren; i++) {
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
   280
		Atom actual_type;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
   281
		int actual_format;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
   282
		unsigned long nitems, bytesafter;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
   283
		Window* newRoot = (Window*) 0;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
   284
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
   285
		if (children[i]) {
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
   286
		    if (XGetWindowProperty(dpy, children[i], vRootAtom,
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
   287
					   0L, 1L, False, XA_WINDOW,
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
   288
					   &actual_type, &actual_format, &nitems, &bytesafter,
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
   289
					   (unsigned char**) &newRoot) == Success && newRoot) {
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
   290
			root = *newRoot;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
   291
			break;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
   292
		    }
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
   293
		}
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
   294
	    }
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
   295
	    if (children) XFree( children );
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
   296
	}
18
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   297
    }
90
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   298
# endif
18
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   299
    return root;
9ffa3bf0ee58 *** empty log message ***
claus
parents: 12
diff changeset
   300
}
90
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   301
#endif
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   302
%}
78
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   303
! !
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   304
898
677e010d0cf8 exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents: 892
diff changeset
   305
!XWorkstation  class methodsFor:'documentation'!
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   306
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   307
copyright
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   308
"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   309
COPYRIGHT (c) 1989 by Claus Gittinger
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   310
	      All Rights Reserved
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
 This software is furnished under a license and may be used
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   313
 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
   314
 inclusion of the above copyright notice.   This software may not
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   315
 be provided or otherwise made available to, or used by, any
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   316
 other person.  No title to or ownership of the software is
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   317
 hereby transferred.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   318
"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   319
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   320
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   321
documentation
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   322
"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   323
    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
   324
    from DeviceWorkstation. Notice, that in Smalltalk/X you are not technically
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   325
    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
   326
    simultanously. However, the default setup is for one display only.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   327
    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
   328
    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
   329
    different protocol. However, 'normal' applications do not have to care for
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   330
    all of this ...
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   331
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   332
    See more documentation in my superclass, DeviceWorkstation.
613
c12586985dcd documentation
Claus Gittinger <cg@exept.de>
parents: 568
diff changeset
   333
c12586985dcd documentation
Claus Gittinger <cg@exept.de>
parents: 568
diff changeset
   334
    [author:]
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
   335
	Claus Gittinger
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   336
"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   337
! !
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   338
898
677e010d0cf8 exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents: 892
diff changeset
   339
!XWorkstation  class methodsFor:'initialization'!
250
eaa532ebcad7 modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
   340
eaa532ebcad7 modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
   341
initialize
eaa532ebcad7 modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
   342
    |d|
eaa532ebcad7 modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
   343
eaa532ebcad7 modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
   344
    super initialize.
eaa532ebcad7 modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
   345
386
f9a80cac659e only init once
Claus Gittinger <cg@exept.de>
parents: 382
diff changeset
   346
    RawKeysymTranslation isNil ifTrue:[
f9a80cac659e only init once
Claus Gittinger <cg@exept.de>
parents: 382
diff changeset
   347
	"/ the following table maps X-keyevents to ST/X
f9a80cac659e only init once
Claus Gittinger <cg@exept.de>
parents: 382
diff changeset
   348
	"/ device independed events. 
f9a80cac659e only init once
Claus Gittinger <cg@exept.de>
parents: 382
diff changeset
   349
	"/ It is NOT meant as a keyboardMap replacement.
f9a80cac659e only init once
Claus Gittinger <cg@exept.de>
parents: 382
diff changeset
   350
f9a80cac659e only init once
Claus Gittinger <cg@exept.de>
parents: 382
diff changeset
   351
	RawKeysymTranslation := d := Dictionary new.
f9a80cac659e only init once
Claus Gittinger <cg@exept.de>
parents: 382
diff changeset
   352
	d at:'Delete_line' put:#DeleteLine.
f9a80cac659e only init once
Claus Gittinger <cg@exept.de>
parents: 382
diff changeset
   353
	d at:'Delete_word' put:#DeleteWord.
f9a80cac659e only init once
Claus Gittinger <cg@exept.de>
parents: 382
diff changeset
   354
	d at:'Down' put:#CursorDown.
f9a80cac659e only init once
Claus Gittinger <cg@exept.de>
parents: 382
diff changeset
   355
	d at:'Up' put:#CursorUp.
f9a80cac659e only init once
Claus Gittinger <cg@exept.de>
parents: 382
diff changeset
   356
	d at:'Left' put:#CursorLeft.
f9a80cac659e only init once
Claus Gittinger <cg@exept.de>
parents: 382
diff changeset
   357
	d at:'Right' put:#CursorRight.
f9a80cac659e only init once
Claus Gittinger <cg@exept.de>
parents: 382
diff changeset
   358
    ]
250
eaa532ebcad7 modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
   359
! !
eaa532ebcad7 modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
   360
898
677e010d0cf8 exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents: 892
diff changeset
   361
!XWorkstation  class methodsFor:'error handling'!
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   362
129
752fbb07635a *** empty log message ***
claus
parents: 125
diff changeset
   363
debug:aBoolean
752fbb07635a *** empty log message ***
claus
parents: 125
diff changeset
   364
%{  /* NOCONTEXT */
752fbb07635a *** empty log message ***
claus
parents: 125
diff changeset
   365
752fbb07635a *** empty log message ***
claus
parents: 125
diff changeset
   366
    __debug__ = (aBoolean == true) ? 1 : 0;
752fbb07635a *** empty log message ***
claus
parents: 125
diff changeset
   367
%}
752fbb07635a *** empty log message ***
claus
parents: 125
diff changeset
   368
!
752fbb07635a *** empty log message ***
claus
parents: 125
diff changeset
   369
923
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
   370
debugResources
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
   371
%{
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
   372
#ifdef COUNT_RESOURCES
928
680dcd56df6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 923
diff changeset
   373
    printf("colors %d bitmaps %d view %d gc %d cursor %d font %d\n",
680dcd56df6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 923
diff changeset
   374
	    __cnt_color, __cnt_bitmap,
923
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
   375
	    __cnt_view, __cnt_gc, __cnt_cursor, __cnt_font);
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
   376
#endif
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
   377
%}
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
   378
!
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
   379
78
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   380
errorStringOfLastError
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   381
%{
216
f4fd44038317 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   382
    RETURN ( __MKSTRING(lastErrorMsg COMMA_CON) );
78
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   383
%}
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   384
!
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   385
135
claus
parents: 133
diff changeset
   386
lastErrorString
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   387
    "return the last X-error string - 
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   388
     when buffering is on, this may be
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   389
     an error for a long-ago operation"
78
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   390
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   391
    |string requestCode s match line|
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   392
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   393
    string := self errorStringOfLastError.
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   394
    requestCode := self requestCodeOfLastError.
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   395
    "
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   396
     X specific: search the requestCode in '/usr/lib/X11/XErrorDB',
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   397
     and append the name of the corresponding X-request
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   398
    "
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   399
    s := '/usr/lib/X11/XErrorDB' asFilename readStream.
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   400
    s notNil ifTrue:[
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   401
	match := 'XRequest.' , requestCode printString.
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   402
	line := s peekForLineStartingWith:match.
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   403
	line notNil ifTrue:[
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   404
	    string := string , ' in ' , (line copyFrom:(line indexOf:$:)+1)
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   405
	].
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   406
	s close.
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   407
    ].
1c9c22df3251 *** empty log message ***
claus
parents: 73
diff changeset
   408
    ^ string
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   409
!
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
minorCodeOfLastError
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   412
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   413
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   414
    RETURN ( __MKSMALLINT(lastMinorCode) );
295
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
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   417
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   418
requestCodeOfLastError
152
claus
parents: 150
diff changeset
   419
%{  /* NOCONTEXT */
claus
parents: 150
diff changeset
   420
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   421
    RETURN ( __MKSMALLINT(lastRequestCode) );
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   422
%}
135
claus
parents: 133
diff changeset
   423
!
claus
parents: 133
diff changeset
   424
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   425
resourceIdOfLastError
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   426
%{  /* NOCONTEXT */
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
    RETURN ( __MKOBJ(lastResource) );
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   429
%}
48194c26a46c Initial revision
claus
parents:
diff changeset
   430
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
   431
898
677e010d0cf8 exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents: 892
diff changeset
   432
!XWorkstation  class methodsFor:'queries'!
104
aa39cabdc13b *** empty log message ***
claus
parents: 98
diff changeset
   433
aa39cabdc13b *** empty log message ***
claus
parents: 98
diff changeset
   434
platformName
133
claus
parents: 132
diff changeset
   435
    "ST-80 compatibility.
claus
parents: 132
diff changeset
   436
     Return a string describing the display systems platform."
claus
parents: 132
diff changeset
   437
715
0c715cbd2bde checkin from browser
Claus Gittinger <cg@exept.de>
parents: 697
diff changeset
   438
    ^ 'X11'  "I don't know what ST-80 returns for X ..."
0c715cbd2bde checkin from browser
Claus Gittinger <cg@exept.de>
parents: 697
diff changeset
   439
0c715cbd2bde checkin from browser
Claus Gittinger <cg@exept.de>
parents: 697
diff changeset
   440
    "Modified: 26.5.1996 / 15:32:46 / cg"
104
aa39cabdc13b *** empty log message ***
claus
parents: 98
diff changeset
   441
! !
aa39cabdc13b *** empty log message ***
claus
parents: 98
diff changeset
   442
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   443
!XWorkstation methodsFor:'accessing & queries'!
48194c26a46c Initial revision
claus
parents:
diff changeset
   444
540
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   445
anyButtonMotionMask
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   446
    "return the state-mask for any button in motion events' state-field.
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   447
     This is the devices mask."
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   448
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   449
%{  /* NOCONTEXT */
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   450
    RETURN (__MKSMALLINT(Button1MotionMask | Button2MotionMask | Button3MotionMask));
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   451
%}.
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   452
    ^ nil
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   453
!
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   454
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   455
blackpixel
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   456
    "return the colornumber of black"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   457
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   458
    ^ blackpixel
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
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   461
button1MotionMask
540
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   462
    "return the state-mask for button1 in motion events' state-field.
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   463
     For backward compatibility."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   464
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   465
%{  /* NOCONTEXT */
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   466
    RETURN (__MKSMALLINT(Button1MotionMask));
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   467
%}
540
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   468
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   469
    "
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   470
     Display button1MotionMask
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   471
    "
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   472
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   473
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   474
button2MotionMask
540
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   475
    "return the state-mask for button2 in motion events' state-field
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   476
     For backward compatibility."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   477
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   478
%{  /* NOCONTEXT */
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   479
    RETURN (__MKSMALLINT(Button2MotionMask));
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   480
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   481
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   482
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   483
button3MotionMask
540
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   484
    "return the state-mask for button3 in motion events' state-field
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   485
     For backward compatibility."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   486
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   487
%{  /* NOCONTEXT */
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   488
    RETURN (__MKSMALLINT(Button3MotionMask));
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   489
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   490
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   491
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   492
buttonMotionMask:aButton
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   493
    "return the state-mask for button1 in motion events state-field.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   494
     This is the devices mask."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   495
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   496
%{  /* NOCONTEXT */
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   497
    if (aButton == __MKSMALLINT(1)) {
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   498
	RETURN (__MKSMALLINT(Button1MotionMask));
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   499
    }
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   500
    if (aButton == __MKSMALLINT(2)) {
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   501
	RETURN (__MKSMALLINT(Button2MotionMask));
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   502
    }
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   503
    if (aButton == __MKSMALLINT(3)) {
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   504
	RETURN (__MKSMALLINT(Button3MotionMask));
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   505
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   506
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   507
    ^ nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   508
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   509
382
92200ee9f558 added sendKey/sendButtonEvent
ah
parents: 378
diff changeset
   510
controlMask
540
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   511
    "return the state-mask for the CTRL modified in motion events' state-field."
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   512
382
92200ee9f558 added sendKey/sendButtonEvent
ah
parents: 378
diff changeset
   513
%{  /* NOCONTEXT */
92200ee9f558 added sendKey/sendButtonEvent
ah
parents: 378
diff changeset
   514
    RETURN (__MKSMALLINT(ControlMask));
92200ee9f558 added sendKey/sendButtonEvent
ah
parents: 378
diff changeset
   515
%}
92200ee9f558 added sendKey/sendButtonEvent
ah
parents: 378
diff changeset
   516
!
92200ee9f558 added sendKey/sendButtonEvent
ah
parents: 378
diff changeset
   517
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   518
defaultEventMask
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   519
    "return a mask to enable some events by default."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   520
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   521
%{  /* NOCONTEXT */
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   522
    RETURN (__MKSMALLINT( ExposureMask | StructureNotifyMask |
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   523
			 KeyPressMask | KeyReleaseMask |
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   524
			 EnterWindowMask | LeaveWindowMask |
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   525
			 ButtonPressMask | ButtonMotionMask | ButtonReleaseMask ));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   526
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   527
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   528
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   529
displayFileDescriptor
48194c26a46c Initial revision
claus
parents:
diff changeset
   530
    "return the displays fileNumber - for select"
48194c26a46c Initial revision
claus
parents:
diff changeset
   531
48194c26a46c Initial revision
claus
parents:
diff changeset
   532
%{  /* NOCONTEXT */
48194c26a46c Initial revision
claus
parents:
diff changeset
   533
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   534
    if (ISCONNECTED) {
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
   535
	RETURN ( __MKSMALLINT(ConnectionNumber(myDpy)) );
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   536
    }
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   537
    RETURN (nil);
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   538
%}
48194c26a46c Initial revision
claus
parents:
diff changeset
   539
!
48194c26a46c Initial revision
claus
parents:
diff changeset
   540
133
claus
parents: 132
diff changeset
   541
displayName
claus
parents: 132
diff changeset
   542
    "return the X-connections display name.
claus
parents: 132
diff changeset
   543
     This is (currently) nil for the default display, 
claus
parents: 132
diff changeset
   544
     something like foo:0 for any other remote display.
claus
parents: 132
diff changeset
   545
     Future versions may return non-nil strings for the default display as well."
claus
parents: 132
diff changeset
   546
claus
parents: 132
diff changeset
   547
    ^ displayName
claus
parents: 132
diff changeset
   548
!
claus
parents: 132
diff changeset
   549
341
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   550
protocolVersion
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   551
    "return the X-servers protocol version - should normally not be of
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   552
     any interest"
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   553
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   554
%{  /* NOCONTEXT */
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   555
    if (ISCONNECTED) {
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   556
	RETURN ( __MKSMALLINT(XProtocolVersion(myDpy)) );
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   557
    }
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   558
    RETURN (nil);
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   559
%}
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   560
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   561
    "
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   562
     Display protocolVersion
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   563
    "
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   564
!
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
serverVendor
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   567
    "return the X-server vendor string - this should normally not be of
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   568
     any interest, but can be for special cases
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   569
     (to avoid bugs in certain implementations)"
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   570
%{
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   571
    if (ISCONNECTED) {
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   572
	RETURN ( __MKSTRING(XServerVendor(myDpy) COMMA_CON) );
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   573
    }
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   574
    RETURN (nil);
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
     Display serverVendor
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
382
92200ee9f558 added sendKey/sendButtonEvent
ah
parents: 378
diff changeset
   582
shiftMask
540
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   583
    "return the state-mask for the SHIFT modified in motion events' state-field."
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   584
382
92200ee9f558 added sendKey/sendButtonEvent
ah
parents: 378
diff changeset
   585
%{  /* NOCONTEXT */
92200ee9f558 added sendKey/sendButtonEvent
ah
parents: 378
diff changeset
   586
    RETURN (__MKSMALLINT(ShiftMask));
92200ee9f558 added sendKey/sendButtonEvent
ah
parents: 378
diff changeset
   587
%}
92200ee9f558 added sendKey/sendButtonEvent
ah
parents: 378
diff changeset
   588
!
92200ee9f558 added sendKey/sendButtonEvent
ah
parents: 378
diff changeset
   589
341
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   590
translatePoint:aPoint from:windowId1 to:windowId2
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   591
    "given a point in window1, return the coordinate in window2.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   592
     This expects a device coordinate (relative to the first views origin)
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   593
     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
   594
     - use to xlate points from a window to rootwindow"
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
    |x1 y1 x2 y2|
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
    x1 := x2 := aPoint x truncated.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   599
    y1 := y2 := aPoint y truncated.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   600
%{
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   601
    int xpos, ypos;
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   602
    Window w1, w2, child_return;
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   603
    int screen = __intVal(__INST(screen));
341
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   604
    Display *dpy = myDpy;
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
    if (__isExternalAddress(windowId1)
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   607
     && __isExternalAddress(windowId2)
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   608
     && __bothSmallInteger(x1, y1)) {
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   609
	w1 = _WindowVal(windowId1);
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   610
	w2 = _WindowVal(windowId2);
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   611
#ifdef VIRTUAL_ROOT
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   612
	if ((w1 == RootWindow(dpy, screen))
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   613
	 || (w2 == RootWindow(dpy, screen))) {
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   614
	    if (w1 == RootWindow(dpy, screen)) {
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   615
		w1 = getRootWindow(dpy, screen);
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   616
	    }
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   617
	    if (w2 == RootWindow(dpy, screen)) {
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   618
		w2 = getRootWindow(dpy, screen);
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   619
	    }
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   620
	}
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   621
#endif
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   622
	BEGIN_INTERRUPTSBLOCKED
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   623
	XTranslateCoordinates(dpy, w1, w2,
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   624
			      __intVal(x1), __intVal(y1), 
341
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   625
			      &xpos, &ypos, &child_return);
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   626
	END_INTERRUPTSBLOCKED
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   627
	x2 = __MKSMALLINT(xpos);
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   628
	y2 = __MKSMALLINT(ypos);
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
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   632
    ^ (x2 @ y2)
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   633
!
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
vendorRelease
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   636
    "return the X-servers vendor release - should normally not be of
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   637
     any interest, but can be for special cases.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   638
     (to avoid bugs in certain implementations)"
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
%{  /* NOCONTEXT */
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   641
    if (ISCONNECTED) {
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   642
	RETURN ( __MKSMALLINT(XVendorRelease(myDpy)) );
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   643
    }
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   644
    RETURN (nil);
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
    "
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   648
     Display vendorRelease
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   649
    "
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   650
!
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   651
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   652
viewIdFromPoint:aPoint in:windowId
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   653
    "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
   654
     hit by this coordinate. Return nil if no view was hit.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   655
     The returned id may be the id of a non ST view.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   656
     - 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
   657
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   658
%{  /* NOCONTEXT */
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
    Display *dpy = myDpy;
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   661
    int screen = __intVal(__INST(screen));
341
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   662
    OBJ xp, yp;
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   663
    int xpos, ypos;
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   664
    Window child_return;
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   665
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   666
    if (__isExternalAddress(windowId)
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   667
     && __isPoint(aPoint)) {
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   668
	xp = _point_X(aPoint);
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   669
	yp = _point_Y(aPoint);
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   670
	if (__bothSmallInteger(xp, yp)) {
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   671
	    BEGIN_INTERRUPTSBLOCKED
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   672
	    XTranslateCoordinates(dpy,
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   673
				  RootWindow(dpy, screen),
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   674
				  _WindowVal(windowId),
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   675
				  __intVal(xp), __intVal(yp), 
341
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   676
				  &xpos, &ypos, &child_return);
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   677
	    END_INTERRUPTSBLOCKED
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   678
	    if (child_return) {
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   679
		RETURN ( __MKOBJ(child_return) );
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   680
	    }
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   681
	    RETURN ( nil );
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   682
	}
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   683
    }
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   684
%}.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   685
    windowId notNil ifTrue:[
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   686
	aPoint isPoint ifTrue:[
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   687
	    ^ self viewIdFromPoint:aPoint asPoint truncated in:windowId
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   688
	]
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   689
    ].
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   690
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   691
    ^ nil
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   692
!
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   693
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   694
virtualExtent
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   695
    "return the virtual extent of the display (in pixels).
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   696
     On most systems, this is the same as the physical width;
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   697
     except, if a window manager with a virtual desktop like olvwm
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   698
     (simulating a bigger screen) is running."
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   699
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   700
%{
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   701
    if ((__INST(rootId) != __INST(virtualRootId)) 
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   702
     && __isExternalAddress(__INST(virtualRootId))) {
341
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   703
	Window vRootWin;
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   704
	Window root;
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   705
	int x, y;
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   706
	unsigned int width, height;
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   707
	unsigned int dummy;
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   708
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   709
	vRootWin = _WindowVal(__INST(virtualRootId));
341
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   710
	if (XGetGeometry(myDpy, vRootWin, &root, &x, &y, &width, &height,
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   711
					  &dummy, &dummy)) {
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   712
	    RETURN ( __MKPOINT_INT(width, height) );
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   713
	}
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   714
    }
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   715
%}.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   716
    ^ width @ height
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   717
!
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   718
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   719
whitepixel
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   720
    "return the colornumber of white"
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   721
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   722
    ^ whitepixel
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   723
! !
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   724
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   725
!XWorkstation methodsFor:'accessing display capabilities'!
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   726
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   727
hasDPS
186
claus
parents: 180
diff changeset
   728
    "return true, if this workstation supports display postscript.
claus
parents: 180
diff changeset
   729
     Both the server must support it, and the feature must have been
claus
parents: 180
diff changeset
   730
     enabled in the smalltalk system, for true to be returned."
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   731
48194c26a46c Initial revision
claus
parents:
diff changeset
   732
    ^ hasDPSExtension
186
claus
parents: 180
diff changeset
   733
claus
parents: 180
diff changeset
   734
    "
claus
parents: 180
diff changeset
   735
     Display hasDPS 
claus
parents: 180
diff changeset
   736
    "
claus
parents: 180
diff changeset
   737
!
claus
parents: 180
diff changeset
   738
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   739
hasExtension:extensionString
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   740
    "query for an X extension. The argument, extensionString
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   741
     should be the name of the extension (i.e. 'SHAPE', 'XInputExtension' etc).
186
claus
parents: 180
diff changeset
   742
     Return true, if that extension is available in the server.
claus
parents: 180
diff changeset
   743
     (which does not imply, that there is support in smalltalk for it."
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   744
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   745
%{
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   746
    int dummy;
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   747
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   748
    if (__isString(extensionString) && ISCONNECTED) {
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   749
	if (XQueryExtension(myDpy, __stringVal(extensionString), &dummy, &dummy, &dummy)) {
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   750
	    RETURN ( true );
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   751
	}
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   752
    }
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   753
%}.
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   754
    ^ false
186
claus
parents: 180
diff changeset
   755
claus
parents: 180
diff changeset
   756
    "
claus
parents: 180
diff changeset
   757
     Display hasExtension:'XVideo' 
claus
parents: 180
diff changeset
   758
     Display hasExtension:'Input' 
claus
parents: 180
diff changeset
   759
     Display hasExtension:'GLX' 
claus
parents: 180
diff changeset
   760
     Display hasExtension:'X3D-PEX' 
claus
parents: 180
diff changeset
   761
     Display hasExtension:'XInputExtension' 
claus
parents: 180
diff changeset
   762
     Display hasExtension:'SHAPE' 
claus
parents: 180
diff changeset
   763
     Display hasExtension:'MIT-SHM' 
claus
parents: 180
diff changeset
   764
     Display hasExtension:'SGIFullScreenStereo' 
claus
parents: 180
diff changeset
   765
    "
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   766
!
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   767
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   768
hasImageExtension
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   769
    "return true, if this workstation supports the X image extension.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   770
     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
   771
     enabled in the smalltalk system, for true to be returned."
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
    ^ hasImageExtension
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   774
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   775
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   776
     Display hasImageExtension 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   777
    "
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
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   780
hasInputExtension
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   781
    "return true, if this workstation supports the X input extension.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   782
     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
   783
     enabled in the smalltalk system, for true to be returned."
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
    ^ hasInputExtension
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   786
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   787
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   788
     Display hasInputExtension 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   789
    "
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
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   792
hasMultibuffer
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   793
    "return true, if this workstation supports the multibuffer extension.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   794
     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
   795
     enabled in the smalltalk system, for true to be returned."
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
    ^ hasMbufExtension
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   798
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   799
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   800
     Display hasMultibuffer 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   801
    "
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
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   804
hasPEX
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   805
    "return true, if this workstation supports PEX 3D graphics.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   806
     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
   807
     enabled in the smalltalk system, for true to be returned."
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
    ^ hasPEXExtension
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   810
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   811
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   812
     Display hasPEX 
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
!
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
hasShape
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   817
    "return true, if this workstation supports non-rectangular windows.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   818
     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
   819
     enabled in the smalltalk system, for true to be returned."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   820
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   821
    ^ hasShapeExtension
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   822
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   823
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   824
     Display hasShape   
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   825
    "
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
hasShm
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   829
    "return true, if this workstation supports the shared pixmap extension.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   830
     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
   831
     enabled in the smalltalk system, for true to be returned."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   832
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   833
    ^ hasShmExtension
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
     Display hasShm 
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
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   839
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   840
hasXVideo
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   841
    "return true, if this workstation supports the XVideo extension.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   842
     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
   843
     enabled in the smalltalk system, for true to be returned."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   844
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   845
    ^ hasXVideoExtension
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   846
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
     Display hasXVideo 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   849
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   850
!
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
iconSizes
540
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   853
    "Get the preferred/supported icon sizes. These are set by the window manager.
819
88aaa6ff1ca3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 818
diff changeset
   854
     We return nil (if not set) or an OrderedCollection of iconSize specs."
295
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
    |xIconSizes count ret|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   857
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   858
%{
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   859
    Display *dpy = myDpy;
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   860
    int screen = __intVal(__INST(screen));
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   861
    XIconSize *sizeList;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   862
    int cnt;
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
    if (ISCONNECTED) {
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
   865
	if (XGetIconSizes(myDpy, RootWindow(dpy, screen), &sizeList, &cnt) > 0) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
   866
	   xIconSizes = __MKEXTERNALBYTES(sizeList);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
   867
	   count = __MKSMALLINT(cnt);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
   868
	}
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   869
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   870
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   871
    xIconSizes isNil ifTrue:[^ nil].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   872
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   873
    ret := OrderedCollection new:count.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   874
    1 to:count do:[ :i |
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
   875
	|minWidth minHeight maxWidth maxHeight widthStep heightStep d|
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   876
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   877
%{
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
   878
	XIconSize *slp;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
   879
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
   880
	slp = &((XIconSize *)__externalBytesAddress(xIconSizes))[__intVal(i)-1];
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
   881
	minWidth = __MKSMALLINT(slp->min_width);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
   882
	minHeight = __MKSMALLINT(slp->min_height);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
   883
	maxWidth = __MKSMALLINT(slp->max_width);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
   884
	maxHeight = __MKSMALLINT(slp->max_height);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
   885
	widthStep = __MKSMALLINT(slp->width_inc);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
   886
	heightStep = __MKSMALLINT(slp->height_inc);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   887
%}.
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
   888
	d := IdentityDictionary new.
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
   889
	d at:#minWidth put:minWidth.
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
   890
	d at:#maxWidth put:maxWidth.
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
   891
	d at:#widthStep put:widthStep.
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
   892
	d at:#minHeight put:minHeight.
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
   893
	d at:#maxHeight put:maxHeight.
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
   894
	d at:#heightStep put:heightStep.
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
   895
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
   896
	ret add:d
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   897
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   898
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   899
    xIconSizes free.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   900
    ^ ret
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   901
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   902
    "
819
88aaa6ff1ca3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 818
diff changeset
   903
     Display iconSizes
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   904
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   905
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   906
341
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   907
ignoreBackingStore:aBoolean
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   908
    "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
   909
     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
   910
     very slow or is broken (can be put into display-rc-file)"
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   911
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   912
    ignoreBackingStore := aBoolean
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   913
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   914
823
1a0933c804ba checkin from browser
Claus Gittinger <cg@exept.de>
parents: 819
diff changeset
   915
preferredIconSize
1a0933c804ba checkin from browser
Claus Gittinger <cg@exept.de>
parents: 819
diff changeset
   916
    "return the displays preferred size for icons.
1a0933c804ba checkin from browser
Claus Gittinger <cg@exept.de>
parents: 819
diff changeset
   917
     Redefined to return a special value on SGI servers."
1a0933c804ba checkin from browser
Claus Gittinger <cg@exept.de>
parents: 819
diff changeset
   918
1a0933c804ba checkin from browser
Claus Gittinger <cg@exept.de>
parents: 819
diff changeset
   919
    self serverVendor = 'Silicon Graphics' ifTrue:[
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
   920
	^ 86@68
823
1a0933c804ba checkin from browser
Claus Gittinger <cg@exept.de>
parents: 819
diff changeset
   921
    ].
1a0933c804ba checkin from browser
Claus Gittinger <cg@exept.de>
parents: 819
diff changeset
   922
    ^ super preferredIconSize
1a0933c804ba checkin from browser
Claus Gittinger <cg@exept.de>
parents: 819
diff changeset
   923
1a0933c804ba checkin from browser
Claus Gittinger <cg@exept.de>
parents: 819
diff changeset
   924
    "Created: 10.6.1996 / 21:06:48 / cg"
1a0933c804ba checkin from browser
Claus Gittinger <cg@exept.de>
parents: 819
diff changeset
   925
!
1a0933c804ba checkin from browser
Claus Gittinger <cg@exept.de>
parents: 819
diff changeset
   926
1025
40dde7d8f538 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   927
scrollsAsynchronous
1008
ca0a38a11bdc support (prepared) for devices which do not send asynchronous exposes
Claus Gittinger <cg@exept.de>
parents: 995
diff changeset
   928
    "return true, if this display asynchronously sends expose events after a
ca0a38a11bdc support (prepared) for devices which do not send asynchronous exposes
Claus Gittinger <cg@exept.de>
parents: 995
diff changeset
   929
     scroll operation. False otherwise. Asynchronous expose events are an X
ca0a38a11bdc support (prepared) for devices which do not send asynchronous exposes
Claus Gittinger <cg@exept.de>
parents: 995
diff changeset
   930
     speciality, which affects a few methods outside of the display class (sorry)"
ca0a38a11bdc support (prepared) for devices which do not send asynchronous exposes
Claus Gittinger <cg@exept.de>
parents: 995
diff changeset
   931
ca0a38a11bdc support (prepared) for devices which do not send asynchronous exposes
Claus Gittinger <cg@exept.de>
parents: 995
diff changeset
   932
    ^ true
ca0a38a11bdc support (prepared) for devices which do not send asynchronous exposes
Claus Gittinger <cg@exept.de>
parents: 995
diff changeset
   933
!
ca0a38a11bdc support (prepared) for devices which do not send asynchronous exposes
Claus Gittinger <cg@exept.de>
parents: 995
diff changeset
   934
43
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
   935
supportedImageFormats
235
579f3f804a46 padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents: 233
diff changeset
   936
    "return an array with supported image formats; 
579f3f804a46 padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents: 233
diff changeset
   937
     each array entry is an attribute dictionary, consisting of 
579f3f804a46 padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents: 233
diff changeset
   938
     depth, bitsPerPixel and padding values."
43
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
   939
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   940
    |nFormats "{ Class: SmallInteger }"
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   941
     formatArray|
43
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
   942
%{
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
   943
    Display *dpy = myDpy;
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   944
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   945
    if (! ISCONNECTED) {
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   946
	RETURN (nil);
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   947
    }
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   948
    nFormats = __MKSMALLINT(DISPLAYACCESS(dpy)->nformats);
43
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
   949
%}.
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
   950
    formatArray := Array new:nFormats.
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   951
    1 to:nFormats do:[:index |
235
579f3f804a46 padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents: 233
diff changeset
   952
	|info bitsPerPixelInfo depthInfo paddingInfo i|
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   953
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
   954
	i := index.
43
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
   955
%{
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
   956
	ScreenFormat *format;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
   957
	Display *dpy = myDpy;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
   958
90
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   959
	format = DISPLAYACCESS(dpy)->pixmap_format;
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   960
	format += (__intVal(i)-1);
235
579f3f804a46 padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents: 233
diff changeset
   961
	bitsPerPixelInfo = __MKSMALLINT(format->bits_per_pixel);
579f3f804a46 padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents: 233
diff changeset
   962
	depthInfo = __MKSMALLINT(format->depth);
579f3f804a46 padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents: 233
diff changeset
   963
	paddingInfo = __MKSMALLINT(format->scanline_pad);
43
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
   964
%}.
235
579f3f804a46 padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents: 233
diff changeset
   965
	info := IdentityDictionary new.
579f3f804a46 padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents: 233
diff changeset
   966
	info at:#depth put:depthInfo.
579f3f804a46 padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents: 233
diff changeset
   967
	info at:#bitsPerPixel put:bitsPerPixelInfo.
579f3f804a46 padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents: 233
diff changeset
   968
	info at:#padding put:paddingInfo.
579f3f804a46 padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents: 233
diff changeset
   969
	formatArray at:index put:info.
43
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
   970
    ].
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
   971
    ^ formatArray
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
   972
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
   973
    "
235
579f3f804a46 padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents: 233
diff changeset
   974
     Display supportedImageFormats 
43
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
   975
    "
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
   976
!
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
   977
823
1a0933c804ba checkin from browser
Claus Gittinger <cg@exept.de>
parents: 819
diff changeset
   978
supportsIconViews
1a0933c804ba checkin from browser
Claus Gittinger <cg@exept.de>
parents: 819
diff changeset
   979
    "return true, if this device supports views as icons.
1a0933c804ba checkin from browser
Claus Gittinger <cg@exept.de>
parents: 819
diff changeset
   980
     Only Xservers (currently) support this."
1a0933c804ba checkin from browser
Claus Gittinger <cg@exept.de>
parents: 819
diff changeset
   981
1a0933c804ba checkin from browser
Claus Gittinger <cg@exept.de>
parents: 819
diff changeset
   982
    ^ true
1a0933c804ba checkin from browser
Claus Gittinger <cg@exept.de>
parents: 819
diff changeset
   983
1a0933c804ba checkin from browser
Claus Gittinger <cg@exept.de>
parents: 819
diff changeset
   984
    "
1a0933c804ba checkin from browser
Claus Gittinger <cg@exept.de>
parents: 819
diff changeset
   985
     Display supportsIconViews 
1a0933c804ba checkin from browser
Claus Gittinger <cg@exept.de>
parents: 819
diff changeset
   986
    "
1a0933c804ba checkin from browser
Claus Gittinger <cg@exept.de>
parents: 819
diff changeset
   987
1a0933c804ba checkin from browser
Claus Gittinger <cg@exept.de>
parents: 819
diff changeset
   988
    "Modified: 10.6.1996 / 20:11:48 / cg"
1a0933c804ba checkin from browser
Claus Gittinger <cg@exept.de>
parents: 819
diff changeset
   989
    "Created: 10.6.1996 / 21:08:18 / cg"
1a0933c804ba checkin from browser
Claus Gittinger <cg@exept.de>
parents: 819
diff changeset
   990
!
1a0933c804ba checkin from browser
Claus Gittinger <cg@exept.de>
parents: 819
diff changeset
   991
81
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
   992
supportsViewGravity
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
   993
    "return true, if this device supports gravity attributes.
82
98a70bce6d51 *** empty log message ***
claus
parents: 81
diff changeset
   994
     We do not depend on it being implemented, but some resizing operations
81
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
   995
     are faster, it is is."
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
   996
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
   997
    ^ true
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   998
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
   999
48194c26a46c Initial revision
claus
parents:
diff changeset
  1000
!XWorkstation methodsFor:'bitmap/window creation'!
48194c26a46c Initial revision
claus
parents:
diff changeset
  1001
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1002
createBitmapFromArray:anArray width:w height:h
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1003
    |bitmapId|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1004
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1005
    bitmapId := self primCreateBitmapFromArray:anArray width:w height:h.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1006
    bitmapId isNil ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1007
	self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1008
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1009
    ^ bitmapId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1010
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1011
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1012
createBitmapFromFile:aString for:aForm
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1013
    |id w h|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1014
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1015
%{
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1016
    Display *dpy = myDpy;
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1017
    int screen = __intVal(__INST(screen));
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1018
    Pixmap newBitmap;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1019
    char *filename;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1020
    unsigned b_width, b_height;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1021
    int b_x_hot, b_y_hot;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1022
    int status;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1023
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1024
    if (ISCONNECTED) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1025
	if (__isString(aString) || __isSymbol(aString)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1026
	    filename = (char *)_stringVal(aString);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1027
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1028
	    BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1029
	    status = XReadBitmapFile(dpy, RootWindow(dpy, screen),
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1030
				     filename, &b_width, &b_height, &newBitmap,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1031
				     &b_x_hot, &b_y_hot);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1032
	    END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1033
892
602b15686c95 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 857
diff changeset
  1034
	    if ((status == BitmapSuccess)  && newBitmap) {
923
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1035
#ifdef COUNT_RESOURCES
963
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1036
		__cnt_bitmap++;
923
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1037
#endif
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  1038
		w = __MKSMALLINT(b_width);
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  1039
		h = __MKSMALLINT(b_height);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1040
		id = __MKOBJ(newBitmap);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1041
	    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1042
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1043
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1044
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1045
    id notNil ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1046
	aForm setWidth:w height:h
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1047
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1048
    ^ id
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1049
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1050
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1051
createBitmapWidth:w height:h
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1052
    "allocate a bitmap on the Xserver, the contents is undefined
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1053
     (i.e. random). Return a bitmap id or nil"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1054
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1055
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1056
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1057
    Display *dpy = myDpy;
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1058
    int screen = __intVal(__INST(screen));
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1059
    Pixmap newBitmap;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1060
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1061
    if (__bothSmallInteger(w, h) && ISCONNECTED) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1062
	BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1063
	newBitmap = XCreatePixmap(dpy, RootWindow(dpy, screen),
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1064
				       __intVal(w), __intVal(h), 1);
923
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1065
#ifdef COUNT_RESOURCES
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1066
	if (newBitmap)
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1067
	    __cnt_bitmap++;
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1068
#endif
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1069
	END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1070
	RETURN ( (newBitmap != (Pixmap)0) ? __MKOBJ(newBitmap) : nil );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1071
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1072
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1073
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1074
    self primitiveFailed.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1075
    ^ nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1076
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1077
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1078
createPixmapWidth:w height:h depth:d
48194c26a46c Initial revision
claus
parents:
diff changeset
  1079
    "allocate a pixmap on the Xserver, the contents is undefined
48194c26a46c Initial revision
claus
parents:
diff changeset
  1080
     (i.e. random). Return a bitmap id or nil"
48194c26a46c Initial revision
claus
parents:
diff changeset
  1081
48194c26a46c Initial revision
claus
parents:
diff changeset
  1082
%{  /* NOCONTEXT */
48194c26a46c Initial revision
claus
parents:
diff changeset
  1083
48194c26a46c Initial revision
claus
parents:
diff changeset
  1084
    Display *dpy = myDpy;
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1085
    int screen = __intVal(__INST(screen));
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1086
    Pixmap newBitmap;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1087
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1088
    if (__bothSmallInteger(w, h) && ISCONNECTED) {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1089
	BEGIN_INTERRUPTSBLOCKED
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1090
	newBitmap = XCreatePixmap(dpy, RootWindow(dpy, screen),
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1091
				       __intVal(w), __intVal(h), __intVal(d));
923
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1092
#ifdef COUNT_RESOURCES
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1093
	if (newBitmap)
928
680dcd56df6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 923
diff changeset
  1094
	    __cnt_bitmap++;
923
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1095
#endif
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1096
	END_INTERRUPTSBLOCKED
207
9124817bbb03 use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents: 206
diff changeset
  1097
	RETURN ( (newBitmap != (Pixmap)0) ? __MKOBJ(newBitmap) : nil );
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1098
    }
48194c26a46c Initial revision
claus
parents:
diff changeset
  1099
%}
48194c26a46c Initial revision
claus
parents:
diff changeset
  1100
.
43
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
  1101
    self primitiveFailed.
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
  1102
    ^ nil
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1103
!
48194c26a46c Initial revision
claus
parents:
diff changeset
  1104
48194c26a46c Initial revision
claus
parents:
diff changeset
  1105
createWindowFor:aView left:xpos top:ypos width:wwidth height:wheight
46
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  1106
    "will vanish - for compatibility with previous versions"
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  1107
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  1108
    ^ self 
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  1109
	  createWindowFor:aView 
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  1110
	  origin:(xpos @ ypos)
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  1111
	  extent:(wwidth @ wheight)
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  1112
	  minExtent:(aView minExtent)
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  1113
	  maxExtent:(aView maxExtent)
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  1114
	  borderWidth:(aView borderWidth)
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  1115
	  subViewOf:(aView superView)
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  1116
	  onTop:(aView isPopUpView)
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  1117
	  inputOnly:(aView isInputOnly)
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  1118
	  label:(aView label)
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  1119
	  cursor:(aView cursor)
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  1120
	  icon:(aView icon)
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  1121
	  iconView:(aView iconView)
780
b2f13d436188 renamed #inputOnly to #isInputOnly
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
  1122
b2f13d436188 renamed #inputOnly to #isInputOnly
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
  1123
    "Modified: 1.6.1996 / 13:22:48 / cg"
46
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  1124
!
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  1125
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  1126
createWindowFor:aView
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1127
		 origin:origin
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1128
		 extent:extent
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1129
		 minExtent:minExt 
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1130
		 maxExtent:maxExt
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1131
		 borderWidth:bWidth
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1132
		 subViewOf:wsuperView
157
claus
parents: 154
diff changeset
  1133
		 onTop:wisPopUpView
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1134
		 inputOnly:winputOnly
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1135
		 label:wlabel
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1136
		 cursor:wcursor
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1137
		 icon:wicon
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1138
		 iconView:wiconView
46
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  1139
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  1140
    |xpos ypos wwidth wheight minWidth minHeight maxWidth maxHeight 
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  1141
     bColorId wsuperViewId wcursorId wiconId windowId
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  1142
     weventMask wiconViewId bitGravity viewGravity vBgColor
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1143
     vBgForm deepForm preferredVisual preferredDepth|
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1144
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1145
    displayId isNil ifTrue:[
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1146
	self primitiveFailed.
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1147
	^ nil
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1148
    ].
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1149
46
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  1150
    origin notNil ifTrue:[
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1151
	xpos := origin x.
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1152
	ypos := origin y.
46
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  1153
    ] ifFalse:[
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1154
	xpos := ypos := 0.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1155
    ].
46
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  1156
    extent notNil ifTrue:[
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1157
	wwidth := extent x.
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1158
	wheight := extent y.
46
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  1159
    ] ifFalse:[
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1160
	wwidth := wheight := 100.
46
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  1161
    ].
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  1162
    minExt notNil ifTrue:[
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1163
	minWidth := minExt x.
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1164
	minHeight := minExt y
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1165
    ].
46
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  1166
    maxExt notNil ifTrue:[
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1167
	maxWidth := maxExt x.
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1168
	maxHeight := maxExt y
46
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  1169
    ].
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  1170
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1171
    wsuperView notNil ifTrue:[
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1172
	wsuperViewId := wsuperView id
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1173
    ].
48194c26a46c Initial revision
claus
parents:
diff changeset
  1174
    wcursor isNil ifTrue:[
145
claus
parents: 144
diff changeset
  1175
	'XWORKSTATION: cursor nil - defaulted' errorPrintNL
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1176
    ] ifFalse:[
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1177
	wcursorId := wcursor id
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1178
    ].
48194c26a46c Initial revision
claus
parents:
diff changeset
  1179
48194c26a46c Initial revision
claus
parents:
diff changeset
  1180
    wicon notNil ifTrue:[
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1181
	wiconId := wicon id
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1182
    ].
48194c26a46c Initial revision
claus
parents:
diff changeset
  1183
    wiconView notNil ifTrue:[
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1184
	wiconViewId := wiconView id
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1185
    ].
48194c26a46c Initial revision
claus
parents:
diff changeset
  1186
    weventMask := aView eventMask.
48194c26a46c Initial revision
claus
parents:
diff changeset
  1187
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1188
    preferredVisual := aView preferredVisual.
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1189
    preferredDepth := aView preferredDepth.
23
4a7e02de7b72 *** empty log message ***
claus
parents: 21
diff changeset
  1190
72
3e84121988c3 *** empty log message ***
claus
parents: 70
diff changeset
  1191
%{  /* STACK:16000 */
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1192
    Display *dpy = myDpy;
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1193
    int screen = __intVal(__INST(screen));
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1194
    Visual visual;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1195
    XGCValues xgcv;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1196
    XSetWindowAttributes xswa;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1197
    XSizeHints sizehints;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1198
    XWMHints wmhints;
46
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  1199
    int bw, bd, bg;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1200
    Window newWindow, parentWindow;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1201
    char *windowName;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1202
    XFontStruct *f;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1203
    Pixmap backPixmap = (Pixmap)0, iconBitmap = (Pixmap)0;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1204
    int flags = 0, depth, ioClass;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1205
    Window iconWindow;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1206
    Atom WmDeleteWindowAtom, WmSaveYourselfAtom, WmProtocolsAtom;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1207
    Atom WmQuitAppAtom;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1208
    Atom atoms[3];
48194c26a46c Initial revision
claus
parents:
diff changeset
  1209
    int atomCount = 0, isTopWindow = 0;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1210
48194c26a46c Initial revision
claus
parents:
diff changeset
  1211
    sizehints.flags = 0;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1212
    sizehints.width = 100;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1213
    sizehints.height = 100;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1214
    sizehints.x = 0;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1215
    sizehints.y = 0;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1216
97
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  1217
    if (__bothSmallInteger(wwidth, wheight)) {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1218
	sizehints.flags |= PSize;
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1219
	sizehints.width = __intVal(wwidth);
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1220
	sizehints.height = __intVal(wheight);
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1221
    }
97
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  1222
    if (__bothSmallInteger(xpos, ypos)) {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1223
	sizehints.flags |= PPosition;
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1224
	sizehints.x = __intVal(xpos);
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1225
	sizehints.y = __intVal(ypos);
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1226
    }
97
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  1227
    if (__bothSmallInteger(minWidth, minHeight)) {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1228
	sizehints.flags |= PMinSize;
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1229
	sizehints.min_width = __intVal(minWidth);
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1230
	sizehints.min_height = __intVal(minHeight);
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1231
    }
97
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  1232
    if (__bothSmallInteger(maxWidth, maxHeight)) {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1233
	sizehints.flags |= PMaxSize;
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1234
	sizehints.max_width = __intVal(maxWidth);
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1235
	sizehints.max_height = __intVal(maxHeight);
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1236
    }
48194c26a46c Initial revision
claus
parents:
diff changeset
  1237
37
c2dc1832c0f1 *** empty log message ***
claus
parents: 36
diff changeset
  1238
    bg = WhitePixel(dpy, screen);
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1239
97
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  1240
    if (__isSmallInteger(bWidth)) {
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1241
	bw = __intVal(bWidth);
46
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  1242
    } else {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1243
	bw = 0;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1244
    }
48194c26a46c Initial revision
claus
parents:
diff changeset
  1245
72
3e84121988c3 *** empty log message ***
claus
parents: 70
diff changeset
  1246
    bd = BlackPixel(dpy, screen);
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  1247
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  1248
    if (__isExternalAddress(wsuperViewId)) {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1249
	parentWindow = _WindowVal(wsuperViewId);
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1250
    } else {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1251
	parentWindow = RootWindow(dpy, screen);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1252
	isTopWindow = 1;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1253
    }
48194c26a46c Initial revision
claus
parents:
diff changeset
  1254
157
claus
parents: 154
diff changeset
  1255
    if (wisPopUpView == true)
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1256
	xswa.override_redirect = 1;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1257
    else 
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1258
	xswa.override_redirect = 0;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1259
48194c26a46c Initial revision
claus
parents:
diff changeset
  1260
    if (winputOnly == true) 
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1261
	ioClass = InputOnly;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1262
    else 
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1263
	ioClass = InputOutput;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1264
97
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  1265
    if (__isSmallInteger(weventMask)) {
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1266
	xswa.event_mask = __intVal(weventMask);
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1267
    } else {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1268
	xswa.event_mask = 0;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1269
    }
48194c26a46c Initial revision
claus
parents:
diff changeset
  1270
48194c26a46c Initial revision
claus
parents:
diff changeset
  1271
    if (ioClass == InputOnly) {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1272
	bw = 0;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1273
	depth = 0;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1274
	flags |= CWEventMask;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1275
    } else {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1276
	depth = DefaultDepth(dpy,screen);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1277
	flags |= CWEventMask | CWBorderPixel | CWOverrideRedirect;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1278
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1279
	if (backPixmap != (Pixmap)0) {
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1280
	    xswa.background_pixmap = backPixmap;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1281
	    flags |= CWBackPixmap;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1282
	} else {
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1283
	    xswa.background_pixel = bg;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1284
	    flags |= CWBackPixel;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1285
	}
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1286
	xswa.border_pixel = bd;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1287
    }
23
4a7e02de7b72 *** empty log message ***
claus
parents: 21
diff changeset
  1288
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1289
    visual.visualid = CopyFromParent;
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1290
    if (__isSmallInteger(preferredDepth)) {
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1291
	depth = __intVal(preferredDepth);
23
4a7e02de7b72 *** empty log message ***
claus
parents: 21
diff changeset
  1292
    }
54
29a6b2f8e042 *** empty log message ***
claus
parents: 46
diff changeset
  1293
29a6b2f8e042 *** empty log message ***
claus
parents: 46
diff changeset
  1294
    BEGIN_INTERRUPTSBLOCKED
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1295
    if (preferredVisual != nil) {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1296
	XVisualInfo vi;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1297
	int cls;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1298
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1299
	if (preferredVisual == @symbol(StaticGray))
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1300
	    cls = StaticGray;
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1301
	else if (preferredVisual == @symbol(GrayScale)) 
857
df5125310d86 New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents: 850
diff changeset
  1302
	    cls = GrayScale;
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1303
	else if (preferredVisual == @symbol(StaticColor)) 
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1304
	    cls = StaticColor;
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1305
	else if (preferredVisual == @symbol(PseudoColor)) 
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1306
	    cls = PseudoColor;
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1307
	else if (preferredVisual == @symbol(TrueColor)) 
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1308
	    cls = TrueColor;
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1309
	else if (preferredVisual == @symbol(DirectColor)) 
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1310
	    cls = DirectColor;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1311
	else
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1312
	    cls = PseudoColor;
200
aa66f76133ab New Method: atomName:
Stefan Vogel <sv@exept.de>
parents: 193
diff changeset
  1313
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1314
	if (XMatchVisualInfo(dpy, screen, depth, cls, &vi)) {
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1315
	    visual.visualid = vi.visualid;
163
claus
parents: 162
diff changeset
  1316
/*
claus
parents: 162
diff changeset
  1317
	    printf("visualId=%x\n", vi.visualid);
claus
parents: 162
diff changeset
  1318
*/
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1319
	}
23
4a7e02de7b72 *** empty log message ***
claus
parents: 21
diff changeset
  1320
    }
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1321
48194c26a46c Initial revision
claus
parents:
diff changeset
  1322
    newWindow = XCreateWindow(dpy, parentWindow,
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1323
			   sizehints.x, sizehints.y,
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1324
			   sizehints.width, sizehints.height,
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1325
			   bw, depth, ioClass, &visual,
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1326
			   flags, &xswa);
54
29a6b2f8e042 *** empty log message ***
claus
parents: 46
diff changeset
  1327
    END_INTERRUPTSBLOCKED
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1328
48194c26a46c Initial revision
claus
parents:
diff changeset
  1329
    if (! newWindow) {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1330
	RETURN ( nil );
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1331
    }
48194c26a46c Initial revision
claus
parents:
diff changeset
  1332
923
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1333
#ifdef COUNT_RESOURCES
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1334
    __cnt_view++;
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1335
#endif
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1336
54
29a6b2f8e042 *** empty log message ***
claus
parents: 46
diff changeset
  1337
    BEGIN_INTERRUPTSBLOCKED
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1338
    /*
48194c26a46c Initial revision
claus
parents:
diff changeset
  1339
     * define its cursor
48194c26a46c Initial revision
claus
parents:
diff changeset
  1340
     */
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  1341
    if (__isExternalAddress(wcursorId)) {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1342
	XDefineCursor(dpy, newWindow, _CursorVal(wcursorId));
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1343
    }
48194c26a46c Initial revision
claus
parents:
diff changeset
  1344
48194c26a46c Initial revision
claus
parents:
diff changeset
  1345
    /*
48194c26a46c Initial revision
claus
parents:
diff changeset
  1346
     * define its icon and name
48194c26a46c Initial revision
claus
parents:
diff changeset
  1347
     * (only makes sense for topWindows)
48194c26a46c Initial revision
claus
parents:
diff changeset
  1348
     */
48194c26a46c Initial revision
claus
parents:
diff changeset
  1349
    if (isTopWindow) {
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  1350
	if (__isExternalAddress(wiconId))
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1351
	    iconBitmap = _PixmapVal(wiconId);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1352
	else
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1353
	    iconBitmap = (Pixmap)0;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1354
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  1355
	if (__isExternalAddress(wiconViewId))
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1356
	    iconWindow = _WindowVal(wiconViewId);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1357
	else
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1358
	    iconWindow = (Window)0;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1359
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1360
	if (__isString(wlabel) || __isSymbol(wlabel))
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1361
	    windowName = (char *)_stringVal(wlabel);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1362
	else
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1363
	    windowName = "";
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1364
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1365
	if (iconBitmap || windowName) {
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1366
	    XSetStandardProperties(dpy, newWindow,
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1367
					windowName, windowName,
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1368
					iconBitmap,
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1369
					0, 0, &sizehints);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1370
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1371
	}
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1372
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1373
	wmhints.flags = 0;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1374
	if (iconBitmap) {
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1375
	    wmhints.flags |= IconPixmapHint;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1376
	    wmhints.icon_pixmap = iconBitmap;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1377
	}
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1378
	if (iconWindow) {
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1379
	    wmhints.flags |= IconWindowHint;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1380
	    wmhints.icon_window = iconWindow;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1381
	}
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1382
/*
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1383
	wmhints.flags |= InputHint;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1384
	wmhints.input = True;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1385
*/
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1386
	XSetWMHints(dpy, newWindow, &wmhints);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1387
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1388
	/*
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1389
	 * tell window manager to not kill us but send an event instead
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1390
	 */
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1391
	/*
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1392
	 * get atoms first (if not already known)
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1393
	 */
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1394
	if (__INST(protocolsAtom) == nil) {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1395
	    WmProtocolsAtom = XInternAtom(dpy, "WM_PROTOCOLS", False);
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1396
	    __INST(protocolsAtom) = __MKATOMOBJ(WmProtocolsAtom);
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1397
#ifdef USE_SAVEYOURSELF_ATOM
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1398
	    WmSaveYourselfAtom = XInternAtom(dpy, "WM_SAVE_YOURSELF", False);
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1399
	    __INST(saveYourselfAtom) = __MKATOMOBJ(WmSaveYourselfAtom);
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1400
#endif
48194c26a46c Initial revision
claus
parents:
diff changeset
  1401
#ifdef USE_QUIT_APP_ATOM
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1402
	    WmQuitAppAtom = XInternAtom(dpy, "_WM_QUIT_APP", False);
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1403
	    __INST(quitAppAtom) = __MKATOMOBJ(WmQuitAppAtom);
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1404
#endif
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1405
	    WmDeleteWindowAtom = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1406
	    __INST(deleteWindowAtom) = __MKATOMOBJ(WmDeleteWindowAtom);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1407
	} else {
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1408
#ifdef USE_QUIT_APP_ATOM
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1409
	    WmQuitAppAtom = _AtomVal(__INST(quitAppAtom));
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1410
#else
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1411
	    WmQuitAppAtom = 0;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1412
#endif
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1413
	    WmProtocolsAtom = _AtomVal(__INST(protocolsAtom));
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1414
	    WmDeleteWindowAtom = _AtomVal(__INST(deleteWindowAtom));
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1415
#ifdef USE_SAVEYOURSELF_ATOM
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1416
	    WmSaveYourselfAtom = _AtomVal(__INST(saveYourselfAtom));
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1417
#else
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1418
	    WmSaveYourselfAtom = 0;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1419
#endif
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1420
	}
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1421
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1422
	atoms[0] = WmDeleteWindowAtom; atomCount++;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1423
#ifdef USE_SAVEYOURSELF_ATOM
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1424
	atoms[atomCount] = WmSaveYourselfAtom; atomCount++;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1425
#endif
48194c26a46c Initial revision
claus
parents:
diff changeset
  1426
#ifdef USE_QUIT_APP_ATOM
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1427
	atoms[atomCount] = WmQuitAppAtom; atomCount++;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1428
#endif
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1429
	XChangeProperty(dpy, newWindow, WmProtocolsAtom, XA_ATOM,
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1430
			32, PropModeReplace, (unsigned char *)atoms, atomCount);
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1431
    }
48194c26a46c Initial revision
claus
parents:
diff changeset
  1432
54
29a6b2f8e042 *** empty log message ***
claus
parents: 46
diff changeset
  1433
    END_INTERRUPTSBLOCKED
29a6b2f8e042 *** empty log message ***
claus
parents: 46
diff changeset
  1434
207
9124817bbb03 use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents: 206
diff changeset
  1435
    windowId = __MKOBJ(newWindow);
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  1436
%}.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1437
    self addKnownView:aView withId:windowId.
48194c26a46c Initial revision
claus
parents:
diff changeset
  1438
    ^ windowId
48194c26a46c Initial revision
claus
parents:
diff changeset
  1439
!
48194c26a46c Initial revision
claus
parents:
diff changeset
  1440
48194c26a46c Initial revision
claus
parents:
diff changeset
  1441
destroyGC:aGCId
48194c26a46c Initial revision
claus
parents:
diff changeset
  1442
48194c26a46c Initial revision
claus
parents:
diff changeset
  1443
%{  /* NOCONTEXT */
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  1444
    if (__isExternalAddress(aGCId) && ISCONNECTED) {
366
4783fabc35c0 validate GC before freeing
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
  1445
	GC gc = _GCVal(aGCId);
4783fabc35c0 validate GC before freeing
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
  1446
4783fabc35c0 validate GC before freeing
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
  1447
	if (gc) {
4783fabc35c0 validate GC before freeing
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
  1448
	    BEGIN_INTERRUPTSBLOCKED
4783fabc35c0 validate GC before freeing
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
  1449
	    XFreeGC(myDpy, gc);
923
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1450
#ifdef COUNT_RESOURCES
963
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1451
	    __cnt_gc--;
923
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1452
#endif
366
4783fabc35c0 validate GC before freeing
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
  1453
	    END_INTERRUPTSBLOCKED
4783fabc35c0 validate GC before freeing
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
  1454
	}
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1455
	RETURN ( self );
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1456
    }
118
25e775072a89 *** empty log message ***
claus
parents: 115
diff changeset
  1457
%}.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1458
    self primitiveFailed
48194c26a46c Initial revision
claus
parents:
diff changeset
  1459
!
48194c26a46c Initial revision
claus
parents:
diff changeset
  1460
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1461
destroyPixmap:aDrawableId
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1462
48194c26a46c Initial revision
claus
parents:
diff changeset
  1463
%{  /* NOCONTEXT */
48194c26a46c Initial revision
claus
parents:
diff changeset
  1464
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  1465
    if (__isExternalAddress(aDrawableId) && ISCONNECTED) {
963
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1466
	Pixmap pix = _PixmapVal(aDrawableId);
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1467
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1468
	if (pix) {
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1469
	    BEGIN_INTERRUPTSBLOCKED
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1470
	    XFreePixmap(myDpy, pix);
923
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1471
#ifdef COUNT_RESOURCES
963
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1472
	    __cnt_bitmap--;
923
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1473
#endif
963
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1474
	    END_INTERRUPTSBLOCKED
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1475
	}
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1476
	RETURN ( self );
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1477
    }
118
25e775072a89 *** empty log message ***
claus
parents: 115
diff changeset
  1478
%}.
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1479
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1480
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1481
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1482
destroyView:aView withId:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1483
%{
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1484
    if (__isExternalAddress(aWindowId) && ISCONNECTED) {
963
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1485
	Window win = _WindowVal(aWindowId);
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1486
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1487
	if (win) {
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1488
	    BEGIN_INTERRUPTSBLOCKED
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1489
	    XDestroyWindow(myDpy, win);
923
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1490
#ifdef COUNT_RESOURCES
963
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1491
	    __cnt_view--;
923
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1492
#endif
963
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1493
	    END_INTERRUPTSBLOCKED
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1494
	}
295
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
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1497
    self removeKnownView:aView
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1498
!
48194c26a46c Initial revision
claus
parents:
diff changeset
  1499
48194c26a46c Initial revision
claus
parents:
diff changeset
  1500
dpsContextFor:aDrawableId and:aGCId
48194c26a46c Initial revision
claus
parents:
diff changeset
  1501
48194c26a46c Initial revision
claus
parents:
diff changeset
  1502
%{  /* NOCONTEXT */
48194c26a46c Initial revision
claus
parents:
diff changeset
  1503
#ifdef XXDPS
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1504
    int screen = __intVal(__INST(screen));
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1505
    DPSContext dps;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1506
    int height;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1507
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  1508
    if (__isExternalAddress(aDrawableId)
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  1509
     && __isExternalAddress(aGCId)
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  1510
     && ISCONNECTED) {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1511
	BEGIN_INTERRUPTSBLOCKED
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1512
	dps = XDPSCreateContext(myDpy, (Drawable)_WindowVal(aDrawableId),
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1513
				       _GCVal(aGCId),
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1514
				       0, height, 0, colormap, NULL, 0,
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1515
				       XDPSDefaultTextBackstop,
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1516
				       XDPSDefaultErrorProc,
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1517
				       NULL);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  1518
	END_INTERRUPTSBLOCKED
207
9124817bbb03 use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents: 206
diff changeset
  1519
	RETURN ( dps ? __MKOBJ(dps) : nil );
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1520
    }
48194c26a46c Initial revision
claus
parents:
diff changeset
  1521
#endif
48194c26a46c Initial revision
claus
parents:
diff changeset
  1522
%}
48194c26a46c Initial revision
claus
parents:
diff changeset
  1523
.
43
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
  1524
    self primitiveFailed.
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
  1525
    ^ nil
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1526
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1527
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1528
gcFor:aDrawableId
132
claus
parents: 129
diff changeset
  1529
claus
parents: 129
diff changeset
  1530
%{  /* NOCONTEXT */
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1531
    int screen = __intVal(__INST(screen));
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1532
    GC gc;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1533
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1534
    if (__isExternalAddress(aDrawableId) && ISCONNECTED) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1535
	BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1536
	gc = XCreateGC(myDpy, (Drawable)_WindowVal(aDrawableId),
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1537
			      0L, (XGCValues *)0);
923
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1538
#ifdef COUNT_RESOURCES
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1539
	if (gc)
963
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1540
	    __cnt_gc++;
923
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1541
#endif
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1542
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1543
	END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1544
	RETURN ( gc ? __MKOBJ(gc) : nil );
200
aa66f76133ab New Method: atomName:
Stefan Vogel <sv@exept.de>
parents: 193
diff changeset
  1545
    }
aa66f76133ab New Method: atomName:
Stefan Vogel <sv@exept.de>
parents: 193
diff changeset
  1546
%}.
aa66f76133ab New Method: atomName:
Stefan Vogel <sv@exept.de>
parents: 193
diff changeset
  1547
    self primitiveFailed.
aa66f76133ab New Method: atomName:
Stefan Vogel <sv@exept.de>
parents: 193
diff changeset
  1548
    ^ nil
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1549
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1550
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1551
primCreateBitmapFromArray:anArray width:w height:h
154
claus
parents: 153
diff changeset
  1552
claus
parents: 153
diff changeset
  1553
%{  /* UNLIMITEDSTACK */
claus
parents: 153
diff changeset
  1554
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1555
    Display *dpy = myDpy;
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1556
    int screen = __intVal(__INST(screen));
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1557
    Pixmap newBitmap;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1558
    unsigned int b_width, b_height;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1559
    REGISTER unsigned char *cp;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1560
    REGISTER unsigned char *pBits;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1561
    unsigned char *b_bits, *allocatedBits;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1562
    int index, row;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1563
    REGISTER int col;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1564
    unsigned bits;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1565
    static char reverseBitTable[256];
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1566
    static firstCall = 1;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1567
    int nBytes;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1568
    unsigned char fastBits[10000];
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1569
    OBJ num, *op;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1570
    int bytesPerRow;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1571
898
677e010d0cf8 exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents: 892
diff changeset
  1572
    if (! ISCONNECTED) {
963
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1573
	RETURN (nil);
898
677e010d0cf8 exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents: 892
diff changeset
  1574
    }
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1575
    if (firstCall) {
963
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1576
	for (index=0; index < 256; index++) {
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1577
	    reverseBitTable[index] = 0;
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1578
	    if (index & 128) reverseBitTable[index] |=   1;
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1579
	    if (index &  64) reverseBitTable[index] |=   2;
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1580
	    if (index &  32) reverseBitTable[index] |=   4;
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1581
	    if (index &  16) reverseBitTable[index] |=   8;
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1582
	    if (index &   8) reverseBitTable[index] |=  16;
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1583
	    if (index &   4) reverseBitTable[index] |=  32;
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1584
	    if (index &   2) reverseBitTable[index] |=  64;
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1585
	    if (index &   1) reverseBitTable[index] |= 128;
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1586
	}
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1587
	firstCall = 0;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1588
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1589
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1590
    if (__bothSmallInteger(w, h) && _isNonNilObject(anArray)) {
963
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1591
	newBitmap = (Pixmap)0;
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1592
	b_width = __intVal(w);
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1593
	b_height = __intVal(h);
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1594
	bytesPerRow = (b_width + 7) / 8;
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1595
	nBytes = b_height * bytesPerRow;
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1596
	if (nBytes < sizeof(fastBits)) {
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1597
	    cp = b_bits = fastBits;
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1598
	    allocatedBits = 0;
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1599
	} else {
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1600
	    cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes);
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1601
	    if (! cp) goto fail;
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1602
	}
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1603
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1604
	if (__qClass(anArray) == @global(Array)) {
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1605
	    index = 1;
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1606
	    op = &(__ArrayInstPtr(anArray)->a_element[index - 1]);
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1607
	    for (row = b_height; row; row--) {
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1608
		for (col = bytesPerRow; col; col--) {
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1609
		    num = *op++;
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1610
		    if (! __isSmallInteger(num)) goto fail;
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1611
		    bits = __intVal(num);
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1612
		    *cp++ = reverseBitTable[bits];
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1613
		}
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1614
	    }
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1615
	} else {
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1616
	    if (__qClass(anArray) == @global(ByteArray)) {
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1617
		pBits = __ByteArrayInstPtr(anArray)->ba_element;
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1618
		for (col = b_height*bytesPerRow; col; col--) {
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1619
		    *cp++ = reverseBitTable[*pBits++];
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1620
		}
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1621
	    } else {
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1622
		goto fail;
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1623
	    }
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1624
	}
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1625
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1626
	BEGIN_INTERRUPTSBLOCKED
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1627
	newBitmap = XCreateBitmapFromData(dpy, RootWindow(dpy, screen),
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1628
					       (char *)b_bits, 
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1629
					       b_width, b_height);
923
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1630
#ifdef COUNT_RESOURCES
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1631
	if (newBitmap)
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1632
	    __cnt_bitmap++;
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1633
#endif
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1634
963
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1635
	END_INTERRUPTSBLOCKED
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1636
fail: ;
963
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1637
	if (allocatedBits)
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1638
	    free(allocatedBits);
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1639
	RETURN ( newBitmap ? __MKOBJ(newBitmap) : nil );
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1640
    }
48194c26a46c Initial revision
claus
parents:
diff changeset
  1641
%}
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1642
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1643
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1644
realRootWindowFor:aView
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1645
    "the name of this method is historic;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1646
     - it will vanish"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1647
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1648
    |id|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1649
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1650
    id := self realRootWindowId.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1651
    self addKnownView:aView withId:id.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1652
    ^ id
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1653
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1654
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1655
realRootWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1656
    "return the id of the real root window.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1657
     This may not be the window you see as background,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1658
     since some window managers install a virtual root window on top
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1659
     of it. Except for very special cases, use #rootWindowId, which takes
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1660
     care of any virtual root."
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1661
48194c26a46c Initial revision
claus
parents:
diff changeset
  1662
%{  /* NOCONTEXT */
48194c26a46c Initial revision
claus
parents:
diff changeset
  1663
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1664
    int screen = __intVal(__INST(screen));
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1665
    Window root;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1666
    OBJ id;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1667
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1668
    if (__INST(rootId) != nil) {
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1669
	RETURN (__INST(rootId));
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1670
    }
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1671
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1672
    if (ISCONNECTED) {
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1673
	root = RootWindow(myDpy, screen);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1674
	if (! root) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1675
	    id = nil;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1676
	} else {
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1677
	    __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
  1678
	}
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1679
	RETURN (id);
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  1680
    }
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  1681
%}.
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1682
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1683
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1684
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1685
rootWindowFor:aView
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1686
    |id|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1687
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1688
    id := self rootWindowId.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1689
    self addKnownView:aView withId:id.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1690
    ^ id
48194c26a46c Initial revision
claus
parents:
diff changeset
  1691
!
48194c26a46c Initial revision
claus
parents:
diff changeset
  1692
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1693
rootWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1694
    "return the id of the root window.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1695
     This is the window you see as background, 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1696
     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
  1697
     since some window managers install a virtual root window on top
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1698
     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
  1699
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1700
%{  /* NOCONTEXT */
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1701
    int screen = __intVal(__INST(screen));
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1702
    Window rootWin, vRootWin;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1703
    OBJ id;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1704
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1705
    if (__INST(virtualRootId) != nil) {
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1706
	RETURN (__INST(virtualRootId));
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1707
    }
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1708
169
claus
parents: 168
diff changeset
  1709
    if (ISCONNECTED) {
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1710
	vRootWin = rootWin = RootWindow(myDpy, screen);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1711
#ifndef IRIS
180
claus
parents: 176
diff changeset
  1712
	BEGIN_INTERRUPTSBLOCKED
295
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
	 * on IRIS, this creates a badwindow error - why ?
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1715
	 * children contains a funny window (000034)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1716
	 */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1717
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1718
	/*
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1719
	 * care for virtual root windows (tvtwm & friends)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1720
	 */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1721
	{
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1722
	    Atom vRootAtom = None;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1723
	    int i;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1724
	    Window rootReturn, parentReturn;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1725
	    Window* children;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1726
	    unsigned int numChildren;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1727
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1728
	    if (XQueryTree(myDpy, rootWin, 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1729
			   &rootReturn, &parentReturn, 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1730
			   &children, &numChildren)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1731
		vRootAtom = XInternAtom(myDpy, "__SWM_VROOT", True );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1732
		if (vRootAtom != None) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1733
		    for (i=0; i < numChildren; i++) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1734
			Atom actual_type;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1735
			int actual_format;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1736
			unsigned long nitems, bytesafter;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1737
			Window* newRoot = (Window*) 0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1738
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1739
			if (children[i]) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1740
			    if (XGetWindowProperty(myDpy, children[i], vRootAtom, 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1741
						     0L, 1L, False, XA_WINDOW,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1742
						     &actual_type, &actual_format, 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1743
						     &nitems, &bytesafter,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1744
						     (unsigned char**) &newRoot
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1745
						   ) == Success && newRoot) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1746
				vRootWin = *newRoot;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1747
				break;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1748
			    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1749
			}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1750
		    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1751
		    if (children) XFree( children );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1752
		}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1753
	    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1754
	}
180
claus
parents: 176
diff changeset
  1755
	END_INTERRUPTSBLOCKED
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1756
#endif
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1757
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1758
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1759
    /* cannot happen */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1760
    if (! vRootWin) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1761
	vRootWin = rootWin;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1762
	if (! rootWin) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1763
	    RETURN ( nil );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1764
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1765
    }
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1766
    __INST(rootId) = id = __MKOBJ(rootWin); __STORE(self, id);
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1767
    __INST(virtualRootId) = id = __MKOBJ(vRootWin); __STORE(self, id);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1768
    RETURN ( id );
63
b9d17e2b6c92 keyRelease and more event masks
claus
parents: 55
diff changeset
  1769
%}
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1770
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
  1771
48194c26a46c Initial revision
claus
parents:
diff changeset
  1772
!XWorkstation methodsFor:'color stuff'!
48194c26a46c Initial revision
claus
parents:
diff changeset
  1773
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1774
colorCell
834
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1775
    "allocate a color cell - return the color index (i.e. colorID).
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1776
     This method will return nil for StaticGrey, StaticGrey and TrueColor displays."
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1777
48194c26a46c Initial revision
claus
parents:
diff changeset
  1778
%{  /* NOCONTEXT */
48194c26a46c Initial revision
claus
parents:
diff changeset
  1779
48194c26a46c Initial revision
claus
parents:
diff changeset
  1780
    Display *dpy = myDpy;
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1781
    int screen = __intVal(__INST(screen));
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1782
    XColor color;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1783
    unsigned long dummy;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1784
    Status ok;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1785
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1786
    BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1787
    ok = XAllocColorCells(dpy, DefaultColormap(dpy, screen), (Bool)0,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1788
			       &dummy, 0, &color.pixel, 1);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1789
    END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1790
    if (ok) {
923
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1791
#ifdef COUNT_RESOURCES
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1792
	__cnt_color++;
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1793
#endif
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  1794
	RETURN ( __MKSMALLINT(color.pixel) );
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1795
    }
923
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1796
%}.
43
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
  1797
    ^ nil
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1798
!
48194c26a46c Initial revision
claus
parents:
diff changeset
  1799
48194c26a46c Initial revision
claus
parents:
diff changeset
  1800
colorNamed:aString
834
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1801
    "allocate a color with color name - return the color index (i.e. colorID).
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1802
     Dont use this method, colornames are mostly X specific"
48194c26a46c Initial revision
claus
parents:
diff changeset
  1803
48194c26a46c Initial revision
claus
parents:
diff changeset
  1804
%{  /* NOCONTEXT */
48194c26a46c Initial revision
claus
parents:
diff changeset
  1805
48194c26a46c Initial revision
claus
parents:
diff changeset
  1806
    char *colorname;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1807
    Display *dpy = myDpy;
48194c26a46c Initial revision
claus
parents:
diff changeset
  1808
    XColor scolor, ecolor;
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1809
    int screen = __intVal(__INST(screen));
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  1810
    int id;
54
29a6b2f8e042 *** empty log message ***
claus
parents: 46
diff changeset
  1811
    Status ok;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1812
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  1813
    if (ISCONNECTED) {
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  1814
	if (__isString(aString) || __isSymbol(aString)) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  1815
	    colorname = (char *)_stringVal(aString);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  1816
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  1817
	    BEGIN_INTERRUPTSBLOCKED
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  1818
	    ok = XParseColor(dpy, DefaultColormap(dpy, screen), colorname, &ecolor);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  1819
	    if (ok) {
847
f7c402bc5983 dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents: 846
diff changeset
  1820
#ifdef QUICK_TRUE_COLORS
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  1821
		if (__INST(visualType) == @symbol(TrueColor)) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  1822
		    id = ((ecolor.red >> (16 - __intVal(__INST(bitsRed)))) << __intVal(__INST(redShift))) & __intVal(__INST(redMask));
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  1823
		    id += ((ecolor.green >> (16 - __intVal(__INST(bitsGreen)))) << __intVal(__INST(greenShift))) & __intVal(__INST(greenMask));
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  1824
		    id += ((ecolor.blue >> (16 - __intVal(__INST(bitsBlue)))) << __intVal(__INST(blueShift))) & __intVal(__INST(blueMask));
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  1825
		    RETURN ( __MKSMALLINT(id) );
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  1826
		}
847
f7c402bc5983 dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents: 846
diff changeset
  1827
#endif
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  1828
		ok = XAllocColor(dpy, DefaultColormap(dpy, screen), &ecolor);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  1829
	    }
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  1830
	    END_INTERRUPTSBLOCKED
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  1831
	    if (! ok) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  1832
		RETURN ( nil );
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  1833
	    }
923
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1834
#ifdef COUNT_RESOURCES
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1835
	    __cnt_color++;
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1836
#endif
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  1837
	    RETURN ( __MKSMALLINT(ecolor.pixel) );
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  1838
	}
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1839
    }
834
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1840
%}.
43
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
  1841
    self primitiveFailed.
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
  1842
    ^ nil
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1843
!
48194c26a46c Initial revision
claus
parents:
diff changeset
  1844
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1845
colorRed:redVal green:greenVal blue:blueVal
834
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1846
    "allocate a color with rgb values (0..100) - return the color index (i.e. colorID).
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1847
     This method is obsoleted by #colorScaledRed:scaledGreen:scaledBlue:"
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1848
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1849
    |r g b|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1850
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1851
    r := self percentToXColorValue:redVal.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1852
    g := self percentToXColorValue:greenVal.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1853
    b := self percentToXColorValue:blueVal.
834
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1854
    ^ self colorScaledRed:r scaledGreen:g scaledBlue:b
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1855
!
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1856
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1857
colorScaledRed:r scaledGreen:g scaledBlue:b
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1858
    "allocate a color with rgb values (0..16rFFFF) - return the color index (i.e. colorID)"
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1859
%{
898
677e010d0cf8 exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents: 892
diff changeset
  1860
    Display *dpy;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1861
    XColor ecolor;
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1862
    int screen = __intVal(__INST(screen));
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1863
    Status ok;
846
49a4732dec95 dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents: 834
diff changeset
  1864
    int id;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1865
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1866
    if (__bothSmallInteger(r, g) 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1867
     && __isSmallInteger(b)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1868
     && ISCONNECTED) {
963
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1869
	ecolor.red = __intVal(r);
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1870
	ecolor.green= __intVal(g);
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1871
	ecolor.blue = __intVal(b);
846
49a4732dec95 dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents: 834
diff changeset
  1872
#ifdef QUICK_TRUE_COLORS
963
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1873
	if (__INST(visualType) == @symbol(TrueColor)) {
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1874
	    id = ((ecolor.red >> (16 - __intVal(__INST(bitsRed)))) << __intVal(__INST(redShift))) & __intVal(__INST(redMask));
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1875
	    id += ((ecolor.green >> (16 - __intVal(__INST(bitsGreen)))) << __intVal(__INST(greenShift))) & __intVal(__INST(greenMask));
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1876
	    id += ((ecolor.blue >> (16 - __intVal(__INST(bitsBlue)))) << __intVal(__INST(blueShift))) & __intVal(__INST(blueMask));
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1877
	    RETURN ( __MKSMALLINT(id) );
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1878
	}
846
49a4732dec95 dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents: 834
diff changeset
  1879
#endif
963
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1880
	dpy = myDpy;
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1881
	BEGIN_INTERRUPTSBLOCKED
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1882
	ok = XAllocColor(dpy, DefaultColormap(dpy, screen), &ecolor);
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1883
	END_INTERRUPTSBLOCKED
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1884
	if (! ok) {
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1885
	    RETURN ( nil );
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1886
	}
923
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1887
#ifdef COUNT_RESOURCES
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1888
	__cnt_color++;
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1889
#endif
963
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1890
	RETURN ( __MKSMALLINT(ecolor.pixel) );
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1891
    }
834
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1892
%}.
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1893
    self primitiveFailed.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1894
    ^ nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1895
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1896
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1897
freeColor:colorIndex
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1898
    "free a display color when its no longer needed"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1899
48194c26a46c Initial revision
claus
parents:
diff changeset
  1900
%{  /* NOCONTEXT */
48194c26a46c Initial revision
claus
parents:
diff changeset
  1901
48194c26a46c Initial revision
claus
parents:
diff changeset
  1902
    Display *dpy = myDpy;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1903
    unsigned long color;
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1904
    int screen = __intVal(__INST(screen));
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1905
846
49a4732dec95 dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents: 834
diff changeset
  1906
#ifdef QUICK_TRUE_COLORS
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1907
    if (__INST(visualType) == @symbol(TrueColor)) {
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  1908
	/* no need to do anything on TrueColor displays ... */
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  1909
	RETURN (self);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1910
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1911
#endif
846
49a4732dec95 dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents: 834
diff changeset
  1912
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1913
    if (__isSmallInteger(colorIndex) && ISCONNECTED) {
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  1914
	color = (long) __intVal(colorIndex);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  1915
	BEGIN_INTERRUPTSBLOCKED
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  1916
	XFreeColors(dpy, DefaultColormap(dpy, screen), &color, 1, 0L);
923
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1917
#ifdef COUNT_RESOURCES
963
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1918
	__cnt_color--;
923
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1919
#endif
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  1920
	END_INTERRUPTSBLOCKED
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  1921
	RETURN ( self );
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1922
    }
834
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1923
%}.
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1924
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1925
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1926
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1927
getRGBFrom:index into:aBlock
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1928
    "get rgb components (0..100) of color in map at:index,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1929
     and evaluate the 3-arg block, aBlock with them"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1930
834
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1931
    |val|
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1932
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1933
    self getScaledRGBFrom:index into:[:r :g :b |
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1934
	val := aBlock 
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1935
		value:(r * 100.0 / 16rFFFF)
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  1936
		value:(g * 100.0 / 16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  1937
		value:(b * 100.0 / 16rFFFF)
834
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1938
    ].
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1939
    ^ val
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1940
!
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1941
846
49a4732dec95 dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents: 834
diff changeset
  1942
getRGBFromName:colorName into:aBlock
49a4732dec95 dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents: 834
diff changeset
  1943
    "get rgb components (0..100) of color named colorName,
49a4732dec95 dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents: 834
diff changeset
  1944
     and evaluate the 3-arg block, aBlock with them"
49a4732dec95 dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents: 834
diff changeset
  1945
    |val|
49a4732dec95 dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents: 834
diff changeset
  1946
49a4732dec95 dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents: 834
diff changeset
  1947
    self getScaledRGBFromName:colorName into:[:r :g :b |
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  1948
	val := aBlock 
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  1949
		value:(r * 100.0 / 16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  1950
		value:(g * 100.0 / 16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  1951
		value:(b * 100.0 / 16rFFFF)
846
49a4732dec95 dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents: 834
diff changeset
  1952
    ].
49a4732dec95 dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents: 834
diff changeset
  1953
    ^ val
49a4732dec95 dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents: 834
diff changeset
  1954
!
49a4732dec95 dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents: 834
diff changeset
  1955
834
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1956
getScaledRGBFrom:index into:aBlock
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1957
    "get rgb components (0 .. 16rFFFF) of color in map at:index,
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1958
     and evaluate the 3-arg block, aBlock with them"
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1959
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1960
    |r g b|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1961
%{
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1962
    Display *dpy = myDpy;
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1963
    int screen = __intVal(__INST(screen));
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1964
    XColor color;
834
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1965
    int sr, sg, sb;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1966
    int bits, scale, shift;
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
    if (__isSmallInteger(index)) {
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1969
	color.pixel = __intVal(index);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1970
	BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1971
	XQueryColor(dpy, DefaultColormap(dpy, screen), &color);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1972
	END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1973
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1974
	/* 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1975
	 * 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
  1976
	 * colors correctly if lesser than 16bits are valid in a color,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1977
	 * (for example, color white on a 4bitsPerRGB server will return
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1978
	 * (16rF000 16rF000 16rF000) instead of (16rFFFF 16rFFFF 16rFFFF)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1979
	 */
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  1980
	bits = __intVal(__INST(bitsPerRGB));
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1981
	scale = (1<<bits) - 1;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1982
	shift = 16 - bits;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1983
834
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1984
	sr = ((double)(color.red>>shift) / scale) * 0xFFFF;
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1985
	sg = ((double)(color.green>>shift) / scale) * 0xFFFF;
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1986
	sb = ((double)(color.blue>>shift) / scale) * 0xFFFF;
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1987
	r = __MKSMALLINT(sr);
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1988
	g = __MKSMALLINT(sg);
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1989
	b = __MKSMALLINT(sb);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1990
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1991
%}.
834
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1992
    ^ aBlock value:r value:g value:b
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1993
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1994
834
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1995
getScaledRGBFromName:colorName into:aBlock
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1996
    "get rgb components (0..16rFFFF) of color named colorName,
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1997
     and evaluate the 3-arg block, aBlock with them"
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1998
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1999
    |r g b|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2000
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2001
    displayId isNil ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2002
	self pimitiveFailed.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2003
	^ nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2004
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2005
%{
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2006
    Display *dpy = myDpy;
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  2007
    int screen = __intVal(__INST(screen));
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2008
    XColor color;
834
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2009
    int sr, sg, sb;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2010
    double floor();
834
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2011
    int bits, scale, shift;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2012
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2013
    if (__isString(colorName) || __isSymbol(colorName)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2014
	BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2015
	if (XParseColor(dpy, DefaultColormap(dpy, screen), 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2016
			     (char *)_stringVal(colorName), &color)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2017
	    /* 
834
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2018
	     * have to compensate for an error in X ?, which does not scale
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2019
	     * colors correctly if lesser than 16bits are valid in a color,
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2020
	     * (for example, color white on a 4bitsPerRGB server will return
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2021
	     * (16rF000 16rF000 16rF000) instead of (16rFFFF 16rFFFF 16rFFFF)
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2022
	     */
834
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2023
	    bits = __intVal(__INST(bitsPerRGB));
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2024
	    scale = (1<<bits) - 1;
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2025
	    shift = 16 - bits;
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2026
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2027
	    sr = ((double)(color.red>>shift) / scale) * 0xFFFF;
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2028
	    sg = ((double)(color.green>>shift) / scale) * 0xFFFF;
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2029
	    sb = ((double)(color.blue>>shift) / scale) * 0xFFFF;
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2030
	    r = __MKSMALLINT(sr);
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2031
	    g = __MKSMALLINT(sg);
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2032
	    b = __MKSMALLINT(sb);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2033
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2034
	END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2035
    }
834
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2036
%}.
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2037
    ^ aBlock value:r value:g value:b
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2038
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2039
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2040
listOfAvailableColors
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2041
    "return a list of all available colornames.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2042
     This should not be used, since colornames are very
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2043
     display-specific (here X-specific)."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2044
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2045
    |aStream list line index colorName|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2046
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2047
    aStream := FileStream readonlyFileNamed:'/usr/lib/X11/rgb.txt'.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2048
    aStream isNil ifTrue:[^ nil].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2049
    list := OrderedCollection new.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2050
    [aStream atEnd] whileFalse:[
1047
b1ab39266b10 Fix #listOfAvailableColors.
Stefan Vogel <sv@exept.de>
parents: 1046
diff changeset
  2051
        line := aStream nextLine.
b1ab39266b10 Fix #listOfAvailableColors.
Stefan Vogel <sv@exept.de>
parents: 1046
diff changeset
  2052
        line notNil ifTrue:[
b1ab39266b10 Fix #listOfAvailableColors.
Stefan Vogel <sv@exept.de>
parents: 1046
diff changeset
  2053
            "skip the r/g/b numbers"
b1ab39266b10 Fix #listOfAvailableColors.
Stefan Vogel <sv@exept.de>
parents: 1046
diff changeset
  2054
            index := 1.
b1ab39266b10 Fix #listOfAvailableColors.
Stefan Vogel <sv@exept.de>
parents: 1046
diff changeset
  2055
            [(line at:index) isSeparator] whileTrue:[index := index + 1].
b1ab39266b10 Fix #listOfAvailableColors.
Stefan Vogel <sv@exept.de>
parents: 1046
diff changeset
  2056
            [(line at:index) isDigit] whileTrue:[index := index + 1].
b1ab39266b10 Fix #listOfAvailableColors.
Stefan Vogel <sv@exept.de>
parents: 1046
diff changeset
  2057
            [(line at:index) isSeparator] whileTrue:[index := index + 1].
b1ab39266b10 Fix #listOfAvailableColors.
Stefan Vogel <sv@exept.de>
parents: 1046
diff changeset
  2058
            [(line at:index) isDigit] whileTrue:[index := index + 1].
b1ab39266b10 Fix #listOfAvailableColors.
Stefan Vogel <sv@exept.de>
parents: 1046
diff changeset
  2059
            [(line at:index) isSeparator] whileTrue:[index := index + 1].
b1ab39266b10 Fix #listOfAvailableColors.
Stefan Vogel <sv@exept.de>
parents: 1046
diff changeset
  2060
            [(line at:index) isDigit] whileTrue:[index := index + 1].
b1ab39266b10 Fix #listOfAvailableColors.
Stefan Vogel <sv@exept.de>
parents: 1046
diff changeset
  2061
            [(line at:index) isSeparator] whileTrue:[index := index + 1].
b1ab39266b10 Fix #listOfAvailableColors.
Stefan Vogel <sv@exept.de>
parents: 1046
diff changeset
  2062
            colorName := line copyFrom:index.
b1ab39266b10 Fix #listOfAvailableColors.
Stefan Vogel <sv@exept.de>
parents: 1046
diff changeset
  2063
            ((colorName occurrencesOf:(Character space)) == 0) ifTrue:[
b1ab39266b10 Fix #listOfAvailableColors.
Stefan Vogel <sv@exept.de>
parents: 1046
diff changeset
  2064
                list add:colorName
b1ab39266b10 Fix #listOfAvailableColors.
Stefan Vogel <sv@exept.de>
parents: 1046
diff changeset
  2065
            ]
b1ab39266b10 Fix #listOfAvailableColors.
Stefan Vogel <sv@exept.de>
parents: 1046
diff changeset
  2066
        ]
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2067
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2068
    aStream close.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2069
    ^ list sort
1047
b1ab39266b10 Fix #listOfAvailableColors.
Stefan Vogel <sv@exept.de>
parents: 1046
diff changeset
  2070
b1ab39266b10 Fix #listOfAvailableColors.
Stefan Vogel <sv@exept.de>
parents: 1046
diff changeset
  2071
    "
b1ab39266b10 Fix #listOfAvailableColors.
Stefan Vogel <sv@exept.de>
parents: 1046
diff changeset
  2072
     Screen current listOfAvailableColors
b1ab39266b10 Fix #listOfAvailableColors.
Stefan Vogel <sv@exept.de>
parents: 1046
diff changeset
  2073
    "
b1ab39266b10 Fix #listOfAvailableColors.
Stefan Vogel <sv@exept.de>
parents: 1046
diff changeset
  2074
b1ab39266b10 Fix #listOfAvailableColors.
Stefan Vogel <sv@exept.de>
parents: 1046
diff changeset
  2075
    "Modified: 11.9.1996 / 15:26:28 / stefan"
295
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
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2078
percentToXColorValue:aPercentage
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2079
    "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
  2080
     x-component value (0..65k) as an integer"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2081
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2082
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2083
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2084
    if (__isSmallInteger(aPercentage)) {
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  2085
	RETURN ( __MKSMALLINT(0xFFFF * __intVal(aPercentage) / 100) );
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2086
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2087
    if (__isFloat(aPercentage)) {
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  2088
	RETURN ( __MKSMALLINT(0xFFFF * (int)(__floatVal(aPercentage)) / 100) );
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2089
    }
834
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2090
%}.
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2091
    ^ (16rFFFF * aPercentage / 100) rounded
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2092
!
48194c26a46c Initial revision
claus
parents:
diff changeset
  2093
892
602b15686c95 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 857
diff changeset
  2094
setColor:index scaledRed:sred scaledGreen:sgreen scaledBlue:sblue
834
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2095
    "change color in map at:index to rgb (0..16rFFFF).
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2096
     This method is a noop for StaticGrey, StaticGrey and TrueColor displays."
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2097
48194c26a46c Initial revision
claus
parents:
diff changeset
  2098
%{  /* NOCONTEXT */
48194c26a46c Initial revision
claus
parents:
diff changeset
  2099
48194c26a46c Initial revision
claus
parents:
diff changeset
  2100
    char *colorname;
48194c26a46c Initial revision
claus
parents:
diff changeset
  2101
    Display *dpy = myDpy;
48194c26a46c Initial revision
claus
parents:
diff changeset
  2102
    XColor color;
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  2103
    int screen = __intVal(__INST(screen));
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2104
    int r, g, b;
48194c26a46c Initial revision
claus
parents:
diff changeset
  2105
    int ok = 1;
48194c26a46c Initial revision
claus
parents:
diff changeset
  2106
892
602b15686c95 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 857
diff changeset
  2107
    if (__isSmallInteger(sred))
602b15686c95 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 857
diff changeset
  2108
	r = __intVal(sred);
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2109
    else ok = 0;
48194c26a46c Initial revision
claus
parents:
diff changeset
  2110
892
602b15686c95 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 857
diff changeset
  2111
    if (__isSmallInteger(sgreen))
602b15686c95 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 857
diff changeset
  2112
	g = __intVal(sgreen);
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2113
    else ok = 0;
48194c26a46c Initial revision
claus
parents:
diff changeset
  2114
892
602b15686c95 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 857
diff changeset
  2115
    if (__isSmallInteger(sblue))
602b15686c95 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 857
diff changeset
  2116
	b = __intVal(sblue);
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2117
    else ok = 0;
48194c26a46c Initial revision
claus
parents:
diff changeset
  2118
97
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  2119
    if (__isSmallInteger(index) && ok) {
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  2120
	color.pixel = __intVal(index);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2121
	color.red = r;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2122
	color.green = g;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2123
	color.blue = b;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2124
	color.flags = DoRed | DoGreen | DoBlue;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2125
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2126
	BEGIN_INTERRUPTSBLOCKED
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2127
	XStoreColor(dpy, DefaultColormap(dpy, screen), &color);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2128
	END_INTERRUPTSBLOCKED
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2129
	RETURN ( self );
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2130
    }
834
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2131
%}.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2132
    self primitiveFailed
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2133
! !
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2134
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2135
!XWorkstation methodsFor:'cursor stuff'!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2136
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2137
colorCursor:aCursorId foreground:fgColor background:bgColor
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2138
    "change a cursors colors"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2139
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2140
    |fgR fgG fgB bgR bgG bgB|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2141
834
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2142
    fgR := fgColor scaledRed.
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2143
    fgG := fgColor scaledGreen.
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2144
    fgB := fgColor scaledBlue.
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2145
    bgR := bgColor scaledRed.
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2146
    bgG := bgColor scaledGreen.
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2147
    bgB := bgColor scaledBlue.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2148
%{
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2149
    XColor fgcolor, bgcolor;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2150
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2151
    if (__isExternalAddress(aCursorId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2152
     && __bothSmallInteger(fgG, fgB)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2153
     && __bothSmallInteger(bgR, bgG) 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2154
     && __bothSmallInteger(bgB, fgR)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2155
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  2156
	fgcolor.red = __intVal(fgR);
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  2157
	fgcolor.green= __intVal(fgG);
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  2158
	fgcolor.blue = __intVal(fgB);
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  2159
	bgcolor.red = __intVal(bgR);
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  2160
	bgcolor.green= __intVal(bgG);
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  2161
	bgcolor.blue = __intVal(bgB);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2162
	BEGIN_INTERRUPTSBLOCKED
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2163
	XRecolorCursor(myDpy, _CursorVal(aCursorId), &fgcolor, &bgcolor);
72
3e84121988c3 *** empty log message ***
claus
parents: 70
diff changeset
  2164
	END_INTERRUPTSBLOCKED
3e84121988c3 *** empty log message ***
claus
parents: 70
diff changeset
  2165
	RETURN ( self );
3e84121988c3 *** empty log message ***
claus
parents: 70
diff changeset
  2166
    }
834
f71ba674da2a Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  2167
%}.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2168
    self primitiveFailed
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2169
!
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2170
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2171
createCursorShape:aShape
974
12797746a1f7 WIN32 changes
Claus Gittinger <cg@exept.de>
parents: 972
diff changeset
  2172
    "create a cursor given a shape-symbol. This only works
12797746a1f7 WIN32 changes
Claus Gittinger <cg@exept.de>
parents: 972
diff changeset
  2173
     for a few standard cursors, and returns nil if no such cursor exists.
12797746a1f7 WIN32 changes
Claus Gittinger <cg@exept.de>
parents: 972
diff changeset
  2174
     Always care for a fallBack, in case of a nil return."
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2175
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2176
    |number id|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2177
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2178
    displayId isNil ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2179
	self primitiveFailed.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2180
	^ nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2181
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2182
    number := self shapeNumberFromSymbol:aShape.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2183
%{
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2184
    Cursor newCursor;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2185
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2186
    if (__isSmallInteger(number)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2187
	BEGIN_INTERRUPTSBLOCKED
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  2188
	newCursor = XCreateFontCursor(myDpy, __intVal(number));
923
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  2189
#ifdef COUNT_RESOURCES
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  2190
	if (newCursor)
963
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  2191
	    __cnt_cursor++;
923
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  2192
#endif
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2193
	END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2194
	if (newCursor != (Cursor)0) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2195
	    id = __MKOBJ(newCursor);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2196
	}
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2197
    }
288
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  2198
%}.
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2199
    ^ id
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2200
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2201
974
12797746a1f7 WIN32 changes
Claus Gittinger <cg@exept.de>
parents: 972
diff changeset
  2202
createCursorSourceForm:sourceForm maskForm:maskForm hotX:hx hotY:hy width:w height:h
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2203
    "create a cursor given 2 bitmaps (source, mask) and a hotspot"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2204
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2205
    |id sourceId maskId|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2206
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2207
    displayId isNil ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2208
	self primitiveFailed.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2209
	^ nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2210
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2211
    sourceId := sourceForm id.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2212
    maskId := maskForm id.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2213
%{
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2214
    Cursor newCursor;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2215
    XColor fgColor, bgColor;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2216
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2217
    if (__isExternalAddress(sourceId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2218
     && __isExternalAddress(maskId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2219
     && __bothSmallInteger(hx, hy)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2220
	fgColor.red = 0;        /* fg is black */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2221
	fgColor.green = 0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2222
	fgColor.blue = 0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2223
	bgColor.red = 0xFFFF;   /* bg is white */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2224
	bgColor.green = 0xFFFF;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2225
	bgColor.blue = 0xFFFF;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2226
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2227
	BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2228
	newCursor = XCreatePixmapCursor(myDpy,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2229
				_PixmapVal(sourceId),
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2230
				_PixmapVal(maskId),
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  2231
				&fgColor, &bgColor, __intVal(hx), __intVal(hy));
923
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  2232
#ifdef COUNT_RESOURCES
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  2233
	if (newCursor)
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  2234
	    __cnt_cursor++;
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  2235
#endif
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2236
	END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2237
	if (newCursor != (Cursor)0) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2238
	    id = __MKOBJ(newCursor);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2239
	}
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2240
    }
288
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  2241
%}.
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2242
    ^ id
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2243
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2244
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2245
destroyCursor:aCursorId
974
12797746a1f7 WIN32 changes
Claus Gittinger <cg@exept.de>
parents: 972
diff changeset
  2246
    "release a cursor - frees any device resources"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2247
48194c26a46c Initial revision
claus
parents:
diff changeset
  2248
%{  /* NOCONTEXT */
48194c26a46c Initial revision
claus
parents:
diff changeset
  2249
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2250
    if (ISCONNECTED) {
963
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  2251
	if (__isExternalAddress(aCursorId)) {
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  2252
	    Cursor curs = _CursorVal(aCursorId);
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  2253
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  2254
	    if (curs) {
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  2255
		BEGIN_INTERRUPTSBLOCKED
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  2256
		XFreeCursor(myDpy, curs);
923
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  2257
#ifdef COUNT_RESOURCES
963
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  2258
		__cnt_cursor--;
923
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  2259
#endif
963
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  2260
		END_INTERRUPTSBLOCKED
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  2261
	    }
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  2262
	    RETURN ( self );
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  2263
	}
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2264
    }
974
12797746a1f7 WIN32 changes
Claus Gittinger <cg@exept.de>
parents: 972
diff changeset
  2265
%}.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2266
    self primitiveFailed
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2267
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2268
974
12797746a1f7 WIN32 changes
Claus Gittinger <cg@exept.de>
parents: 972
diff changeset
  2269
needDeviceFormsForCursor
12797746a1f7 WIN32 changes
Claus Gittinger <cg@exept.de>
parents: 972
diff changeset
  2270
    ^ true
12797746a1f7 WIN32 changes
Claus Gittinger <cg@exept.de>
parents: 972
diff changeset
  2271
!
12797746a1f7 WIN32 changes
Claus Gittinger <cg@exept.de>
parents: 972
diff changeset
  2272
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2273
shapeNumberFromSymbol:shape
974
12797746a1f7 WIN32 changes
Claus Gittinger <cg@exept.de>
parents: 972
diff changeset
  2274
    "given a shape-symbol, return the corresponding cursor-number,
12797746a1f7 WIN32 changes
Claus Gittinger <cg@exept.de>
parents: 972
diff changeset
  2275
     or nil if no such standard cursor exists."
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2276
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2277
    "this is pure X-knowlegde - but you may easily add more"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2278
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2279
    (shape == #upLeftArrow)     ifTrue:[ ^ %{ __MKSMALLINT(XC_top_left_arrow)    %} "132" ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2280
    (shape == #upRightHand)     ifTrue:[ ^ %{ __MKSMALLINT(XC_hand1)             %} "58" ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2281
    (shape == #upDownArrow)     ifTrue:[ ^ %{ __MKSMALLINT(XC_sb_v_double_arrow) %} "116" ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2282
    (shape == #leftRightArrow)  ifTrue:[ ^ %{ __MKSMALLINT(XC_sb_h_double_arrow) %} "108" ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2283
    (shape == #upLimitArrow)    ifTrue:[ ^ %{ __MKSMALLINT(XC_top_side)          %} "138" ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2284
    (shape == #downLimitArrow)  ifTrue:[ ^ %{ __MKSMALLINT(XC_bottom_side)       %} "16" ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2285
    (shape == #leftLimitArrow)  ifTrue:[ ^ %{ __MKSMALLINT(XC_left_side)         %} "70" ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2286
    (shape == #rightLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_right_side)        %} "96" ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2287
    (shape == #text)            ifTrue:[ ^ %{ __MKSMALLINT(XC_xterm)             %} "152" ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2288
    (shape == #upRightArrow)    ifTrue:[ ^ %{ __MKSMALLINT(XC_draft_large)       %} "44" ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2289
    (shape == #leftHand)        ifTrue:[ ^ %{ __MKSMALLINT(XC_hand2)             %} "60" ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2290
    (shape == #questionMark)    ifTrue:[ ^ %{ __MKSMALLINT(XC_question_arrow)    %} "92" ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2291
    (shape == #cross)           ifTrue:[ ^ %{ __MKSMALLINT(XC_X_cursor)          %} "0" ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2292
    (shape == #wait)            ifTrue:[ ^ %{ __MKSMALLINT(XC_watch)             %} "150" ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2293
    (shape == #crossHair)       ifTrue:[ ^ %{ __MKSMALLINT(XC_tcross)            %} "130" ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2294
    ((shape == #origin)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2295
    or:[shape == #topLeft])     ifTrue:[ ^ %{ __MKSMALLINT(XC_ul_angle)          %} "144" ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2296
    ((shape == #corner)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2297
    or:[shape == #bottomRight]) ifTrue:[ ^ %{ __MKSMALLINT(XC_lr_angle)          %} "78" ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2298
    (shape == #topRight)        ifTrue:[ ^ %{ __MKSMALLINT(XC_ur_angle)          %} "148" ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2299
    (shape == #bottomLeft)      ifTrue:[ ^ %{ __MKSMALLINT(XC_ll_angle)          %} "76" ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2300
    (shape == #square)          ifTrue:[ ^ %{ __MKSMALLINT(XC_dotbox)            %} "40" ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2301
    (shape == #fourWay)         ifTrue:[ ^ %{ __MKSMALLINT(XC_fleur)             %} "52" ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2302
    (shape == #crossCursor)     ifTrue:[ ^ %{ __MKSMALLINT(XC_X_cursor)          %} "0" ].
974
12797746a1f7 WIN32 changes
Claus Gittinger <cg@exept.de>
parents: 972
diff changeset
  2303
"/    ('XWORKSTATION: invalid cursorShape:' , shape printString) infoPrintNL.
12797746a1f7 WIN32 changes
Claus Gittinger <cg@exept.de>
parents: 972
diff changeset
  2304
    ^  nil
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2305
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
  2306
48194c26a46c Initial revision
claus
parents:
diff changeset
  2307
!XWorkstation methodsFor:'drawing'!
48194c26a46c Initial revision
claus
parents:
diff changeset
  2308
1030
ca9d23090688 pass srcGCId to bit-blitters (req'd on WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  2309
copyFromId:sourceId x:srcX y:srcY gc:srcGCId to:destId x:dstX y:dstY gc:dstGCId width:w height:h
118
25e775072a89 *** empty log message ***
claus
parents: 115
diff changeset
  2310
    "do a bit-blt; copy bits from the rectangle defined by
25e775072a89 *** empty log message ***
claus
parents: 115
diff changeset
  2311
     srcX/srcY and w/h from the sourceId drawable to the rectangle
25e775072a89 *** empty log message ***
claus
parents: 115
diff changeset
  2312
     below dstX/dstY in the destId drawable. Trigger an error if any
25e775072a89 *** empty log message ***
claus
parents: 115
diff changeset
  2313
     argument is not integer."
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2314
48194c26a46c Initial revision
claus
parents:
diff changeset
  2315
%{  /* NOCONTEXT */
48194c26a46c Initial revision
claus
parents:
diff changeset
  2316
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2317
    GC gc;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2318
    Drawable source, dest;
48194c26a46c Initial revision
claus
parents:
diff changeset
  2319
975
68f73e1ad6c9 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 974
diff changeset
  2320
    if (__isExternalAddress(dstGCId)
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  2321
     && __isExternalAddress(sourceId)
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  2322
     && __isExternalAddress(destId)
97
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  2323
     && __bothSmallInteger(w, h)
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  2324
     && __bothSmallInteger(srcX, srcY)
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  2325
     && __bothSmallInteger(dstX, dstY)) {
975
68f73e1ad6c9 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 974
diff changeset
  2326
	gc = _GCVal(dstGCId);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2327
	source = (Drawable) _WindowVal(sourceId);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2328
	dest = (Drawable) _WindowVal(destId);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2329
	XCopyArea(myDpy, source, dest, gc,
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  2330
				 __intVal(srcX), __intVal(srcY),
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  2331
				__intVal(w), __intVal(h),
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  2332
				__intVal(dstX), __intVal(dstY));
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2333
	RETURN ( self );
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2334
    }
118
25e775072a89 *** empty log message ***
claus
parents: 115
diff changeset
  2335
%}.
25e775072a89 *** empty log message ***
claus
parents: 115
diff changeset
  2336
    "badGC, bad sourceDrawableId or destDrawableID
25e775072a89 *** empty log message ***
claus
parents: 115
diff changeset
  2337
     or any non integer coordinate"
25e775072a89 *** empty log message ***
claus
parents: 115
diff changeset
  2338
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2339
    self primitiveFailed
48194c26a46c Initial revision
claus
parents:
diff changeset
  2340
!
48194c26a46c Initial revision
claus
parents:
diff changeset
  2341
1030
ca9d23090688 pass srcGCId to bit-blitters (req'd on WINDOWS)
Claus Gittinger <cg@exept.de>
parents: 1025
diff changeset
  2342
copyPlaneFromId:sourceId x:srcX y:srcY gc:srcGCId to:destId x:dstX y:dstY gc:dstGCId width:w height:h
118
25e775072a89 *** empty log message ***
claus
parents: 115
diff changeset
  2343
    "do a bit-blt, but only copy the low-bit plane; 
25e775072a89 *** empty log message ***
claus
parents: 115
diff changeset
  2344
     copy bits from the rectangle defined by
25e775072a89 *** empty log message ***
claus
parents: 115
diff changeset
  2345
     srcX/srcY and w/h from the sourceId drawable to the rectangle
25e775072a89 *** empty log message ***
claus
parents: 115
diff changeset
  2346
     below dstX/dstY in the destId drawable. Trigger an error if any
25e775072a89 *** empty log message ***
claus
parents: 115
diff changeset
  2347
     argument is not integer."
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2348
48194c26a46c Initial revision
claus
parents:
diff changeset
  2349
%{  /* NOCONTEXT */
48194c26a46c Initial revision
claus
parents:
diff changeset
  2350
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2351
    GC gc;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2352
    Drawable source, dest;
48194c26a46c Initial revision
claus
parents:
diff changeset
  2353
975
68f73e1ad6c9 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 974
diff changeset
  2354
    if (__isExternalAddress(dstGCId)
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  2355
     && __isExternalAddress(sourceId)
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  2356
     && __isExternalAddress(destId)
97
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  2357
     && __bothSmallInteger(w, h)
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  2358
     && __bothSmallInteger(srcX, srcY)
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  2359
     && __bothSmallInteger(dstX, dstY)) {
975
68f73e1ad6c9 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 974
diff changeset
  2360
	gc = _GCVal(dstGCId);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2361
	source = (Drawable) _WindowVal(sourceId);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2362
	dest = (Drawable) _WindowVal(destId);
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2363
	XCopyPlane(myDpy, source, dest, gc,
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  2364
				 __intVal(srcX), __intVal(srcY),
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  2365
				 __intVal(w), __intVal(h),
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  2366
				 __intVal(dstX), __intVal(dstY), 1);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2367
	RETURN ( self );
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2368
    }
118
25e775072a89 *** empty log message ***
claus
parents: 115
diff changeset
  2369
%}.
25e775072a89 *** empty log message ***
claus
parents: 115
diff changeset
  2370
    "badGC, bad sourceDrawableId or destDrawableID
25e775072a89 *** empty log message ***
claus
parents: 115
diff changeset
  2371
     or any non integer coordinate"
25e775072a89 *** empty log message ***
claus
parents: 115
diff changeset
  2372
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2373
    self primitiveFailed
48194c26a46c Initial revision
claus
parents:
diff changeset
  2374
!
48194c26a46c Initial revision
claus
parents:
diff changeset
  2375
652
30a701619098 fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 613
diff changeset
  2376
displayArcX:x y:y width:width height:height from:startAngle angle:angle in:aDrawableId with:aGCId
90
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
  2377
    "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
  2378
     The angles may be floats or integer - they are given in degrees."
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2379
48194c26a46c Initial revision
claus
parents:
diff changeset
  2380
%{  /* NOCONTEXT */
48194c26a46c Initial revision
claus
parents:
diff changeset
  2381
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2382
    GC gc;
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2383
    Window win;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2384
    int w, h, angle1, angle2;
48194c26a46c Initial revision
claus
parents:
diff changeset
  2385
    double f;
48194c26a46c Initial revision
claus
parents:
diff changeset
  2386
97
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  2387
    if (__isSmallInteger(startAngle))
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2388
	angle1 = __intVal(startAngle) * 64;
36
b297468551c6 *** empty log message ***
claus
parents: 31
diff changeset
  2389
    else if (__isFloat(startAngle)) {
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2390
	f = __floatVal(startAngle);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2391
	angle1 = f * 64;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2392
    }
97
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  2393
    if (__isSmallInteger(angle))
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2394
	angle2 = __intVal(angle) * 64;
36
b297468551c6 *** empty log message ***
claus
parents: 31
diff changeset
  2395
    else if (__isFloat(angle)) {
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2396
	f = __floatVal(angle);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2397
	angle2 = f * 64;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2398
    }
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  2399
    if (__isExternalAddress(aGCId)
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  2400
     && __isExternalAddress(aDrawableId)
97
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  2401
     && __bothSmallInteger(x, y)
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  2402
     && __bothSmallInteger(width, height)) {
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2403
	win = _WindowVal(aDrawableId);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2404
	gc = _GCVal(aGCId);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2405
	w = __intVal(width);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2406
	h = __intVal(height);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2407
	/*
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2408
	 * need this check here: some servers simply dump core with bad args
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2409
	 */
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2410
	if ((w >= 0) && (h >= 0) && (angle1 >= 0) && (angle2 >= 0)) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2411
	    XDrawArc(myDpy, win, gc, __intVal(x), __intVal(y),
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2412
				   w, h, angle1, angle2);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2413
	}
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2414
	RETURN ( self );
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2415
    }
73
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2416
%}.
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2417
    "badGC, badDrawable or coordinates not integer"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2418
    self primitiveFailed
48194c26a46c Initial revision
claus
parents:
diff changeset
  2419
!
48194c26a46c Initial revision
claus
parents:
diff changeset
  2420
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2421
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
  2422
    "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
  2423
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2424
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2425
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2426
    GC gc;
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2427
    Window win;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2428
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2429
    if (__isExternalAddress(aGCId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2430
     && __isExternalAddress(aDrawableId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2431
     && __bothSmallInteger(x0, y0)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2432
     && __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
  2433
	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
  2434
	win = _WindowVal(aDrawableId);
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  2435
	XDrawLine(myDpy, win, gc, __intVal(x0), __intVal(y0),
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  2436
				  __intVal(x1), __intVal(y1));
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2437
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2438
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2439
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2440
    "badGC, badDrawable or coordinates not integer"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2441
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2442
!
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
displayPointX:x y:y in:aDrawableId with:aGCId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2445
    "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
  2446
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2447
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2448
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2449
    GC gc;
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2450
    Window win;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2451
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2452
    if (__isExternalAddress(aGCId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2453
     && __isExternalAddress(aDrawableId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2454
     && __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
  2455
	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
  2456
	win = _WindowVal(aDrawableId);
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  2457
	XDrawPoint(myDpy, win, gc, __intVal(x), __intVal(y));
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2458
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2459
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2460
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2461
    "badGC, badDrawable or x/y not integer"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2462
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2463
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2464
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2465
displayPolygon:aPolygon in:aDrawableId with:aGCId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2466
    "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
  2467
     define the polygon.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2468
     If any coordinate is not integer, an error is triggered."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2469
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2470
    |numberOfPoints newPoints|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2471
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2472
    numberOfPoints := aPolygon size.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2473
%{
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2474
    GC gc;
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2475
    Window win;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2476
    OBJ point, x, y;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2477
    int i, num;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2478
    XPoint *points;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2479
    XPoint qPoints[100];
377
191915daff5e *** empty log message ***
ah
parents: 374
diff changeset
  2480
    int mustFree = 0;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2481
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2482
    if (__isExternalAddress(aGCId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2483
     && __isExternalAddress(aDrawableId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2484
     && __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
  2485
	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
  2486
	win = _WindowVal(aDrawableId);
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  2487
	num = __intVal(numberOfPoints);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2488
	/*
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2489
	 * avoid a (slow) malloc, if the number of points is small
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2490
	 */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2491
	if (num > 100) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2492
	    points = (XPoint *)malloc(sizeof(XPoint) * num);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2493
	    if (! points) goto fail;
377
191915daff5e *** empty log message ***
ah
parents: 374
diff changeset
  2494
	    mustFree = 1;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2495
	} else
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2496
	    points = qPoints;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2497
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2498
	for (i=0; i<num; i++) {
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  2499
	    point = __AT_(aPolygon COMMA_CON, __MKSMALLINT(i+1));
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2500
	    if (! __isPoint(point)) goto fail;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2501
	    x = _point_X(point);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2502
	    y = _point_Y(point);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2503
	    if (! __bothSmallInteger(x, y))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2504
		goto fail;
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  2505
	    points[i].x = __intVal(x);
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  2506
	    points[i].y = __intVal(y);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2507
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2508
	XDrawLines(myDpy, win, gc, points, num, CoordModeOrigin);
377
191915daff5e *** empty log message ***
ah
parents: 374
diff changeset
  2509
	if (mustFree)
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2510
	    free(points);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2511
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2512
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2513
fail: ;
377
191915daff5e *** empty log message ***
ah
parents: 374
diff changeset
  2514
    if (mustFree)
382
92200ee9f558 added sendKey/sendButtonEvent
ah
parents: 378
diff changeset
  2515
	free(points);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2516
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2517
    "badGC, badDrawable or coordinates not integer"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2518
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2519
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2520
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2521
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
  2522
    "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
  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
    int w, h;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2529
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2530
    if (__isExternalAddress(aGCId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2531
     && __isExternalAddress(aDrawableId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2532
     && __bothSmallInteger(x, y)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2533
     && __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
  2534
	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
  2535
	win = _WindowVal(aDrawableId);
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  2536
	w = __intVal(width);
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  2537
	h = __intVal(height);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2538
	/*
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2539
	 * 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
  2540
	 */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2541
	if ((w >= 0) && (h >= 0)) {
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  2542
	    XDrawRectangle(myDpy, win, gc, __intVal(x), __intVal(y), w, h);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2543
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2544
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2545
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2546
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2547
    "badGC, badDrawable or coordinates not integer"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2548
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2549
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2550
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2551
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
  2552
    "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
  2553
     foreground and background characters.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2554
     If the coordinates are not integers, an error is triggered."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2555
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2556
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2557
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2558
    GC gc;
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2559
    Window win;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2560
    unsigned char *cp;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2561
    OBJ cls;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2562
    int  i1, i2, l, n;
486
0c35ed67797d oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents: 481
diff changeset
  2563
#   define NLOCALBUFFER 200
461
4a4b1384ab76 X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents: 459
diff changeset
  2564
    XChar2b xlatebuffer[NLOCALBUFFER];
481
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  2565
    int nInstBytes;
295
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
    if (__isExternalAddress(aGCId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2568
     && __isExternalAddress(aDrawableId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2569
     && __isNonNilObject(aString)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2570
     && __bothSmallInteger(index1, index2)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2571
     && __bothSmallInteger(x, y)) {
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2572
	gc = _GCVal(aGCId);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2573
	win = _WindowVal(aDrawableId);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2574
	cls = __qClass(aString);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2575
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2576
	i1 = __intVal(index1) - 1;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2577
	if (i1 >= 0) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2578
	    i2 = __intVal(index2) - 1;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2579
	    if (i2 < i1) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2580
		RETURN (self);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2581
	    }
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2582
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2583
	    cp = _stringVal(aString);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2584
	    l = i2 - i1 + 1;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2585
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2586
	    if ((cls == @global(String)) || (cls == @global(Symbol))) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2587
		n = _stringSize(aString);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2588
		if (i2 < n) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2589
		    cp += i1;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2590
		    if (l > 1000) l = 1000;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2591
		    if (opaque == true)
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2592
			XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2593
		    else
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2594
			XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2595
		    RETURN ( self );
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2596
		}
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2597
	    }
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2598
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2599
	    nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2600
	    cp += nInstBytes;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2601
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2602
	    if (__isBytes(aString)) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2603
		n = __byteArraySize(aString) - nInstBytes - 1;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2604
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2605
		if (i2 < n) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2606
		    cp += i1;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2607
		    if (l > 1000) l = 1000;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2608
		    if (opaque == true)
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2609
			XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2610
		    else
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2611
			XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2612
		    RETURN ( self );
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2613
		}
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2614
	    }
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2615
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2616
	    /* TWOBYTESTRINGS */
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2617
	    if (__isWords(aString)) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2618
		n = (__byteArraySize(aString) - nInstBytes) / 2;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2619
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2620
		if (i2 < n) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2621
		    union {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2622
			char b[2];
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2623
			unsigned short s;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2624
		    } u;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2625
		    int i;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2626
		    XChar2b *cp2 = (XChar2b *)0;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2627
		    int mustFree = 0;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2628
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2629
		    cp += (i1 * 2);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2630
		    if (l > 1000) l = 1000;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2631
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2632
		    /*
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2633
		     * ST/X TwoByteStrings store the asciiValue in native byteOrder;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2634
		     * X expects them MSB first
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2635
		     * convert as required
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2636
		     */
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2637
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2638
		    u.s = 0x1234;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2639
		    if (u.b[0] != 0x12) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2640
			if (l <= NLOCALBUFFER) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2641
			    cp2 = xlatebuffer;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2642
			} else {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2643
			    cp2 = (XChar2b *)(malloc(l * 2));
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2644
			    mustFree = 1;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2645
			}
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2646
			for (i=0; i<l; i++) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2647
			    cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2648
			    cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2649
			}
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2650
			cp = (char *) cp2;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2651
		    }
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2652
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2653
		    if (opaque == true)
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2654
			XDrawImageString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, l);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2655
		    else
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2656
			XDrawString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, l);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2657
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2658
		    if (mustFree) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2659
			free(cp2);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2660
		    }
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2661
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2662
		    RETURN ( self );
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2663
		}
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2664
	    }
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2665
	}
486
0c35ed67797d oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents: 481
diff changeset
  2666
    }
481
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  2667
#undef NLOCALBUFFER
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2668
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2669
    "x/y not integer, badGC or drawable, or not a string"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2670
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2671
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2672
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2673
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
  2674
    "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
  2675
     foreground and background characters.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2676
     If the coordinates are not integers, an error is triggered."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2677
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2678
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2679
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2680
    GC gc;
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2681
    Window win;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2682
    unsigned char *cp;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2683
    int n;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2684
    OBJ cls;
486
0c35ed67797d oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents: 481
diff changeset
  2685
#   define NLOCALBUFFER 200
461
4a4b1384ab76 X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents: 459
diff changeset
  2686
    XChar2b xlatebuffer[NLOCALBUFFER];
481
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  2687
    int nInstBytes;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2688
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2689
    if (__isExternalAddress(aGCId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2690
     && __isExternalAddress(aDrawableId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2691
     && __isNonNilObject(aString)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2692
     && __bothSmallInteger(x, y)) {
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2693
	gc = _GCVal(aGCId);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2694
	win = _WindowVal(aDrawableId);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2695
	cls = __qClass(aString);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2696
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2697
	cp = _stringVal(aString);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2698
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2699
	if ((cls == @global(String)) || (cls == @global(Symbol))) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2700
	    n = _stringSize(aString);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2701
	    if (n > 1000) n = 1000;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2702
	    if (opaque == true)
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2703
		XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2704
	    else
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2705
		XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2706
	    RETURN ( self );
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2707
	}
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2708
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2709
	nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2710
	cp += nInstBytes;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2711
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2712
	if (__isBytes(aString)) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2713
	    n = __byteArraySize(aString) - nInstBytes - 1;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2714
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2715
	    if (n > 1000) n = 1000;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2716
	    if (opaque == true)
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2717
		XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2718
	    else
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2719
		XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2720
	    RETURN ( self );
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2721
	}
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2722
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2723
	/* TWOBYTESTRINGS */
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2724
	if (__isWords(aString)) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2725
	    union {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2726
		char b[2];
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2727
		unsigned short s;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2728
	    } u;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2729
	    int i;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2730
	    XChar2b *cp2;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2731
	    int mustFree = 0;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2732
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2733
	    n = (__byteArraySize(aString) - nInstBytes) / 2;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2734
	    if (n > 1000) n = 1000;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2735
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2736
	    /*
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2737
	     * ST/X TwoByteStrings store the asciiValue in native byteOrder;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2738
	     * X expects them MSB first
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2739
	     * convert as required
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2740
	     */
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2741
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2742
	    u.s = 0x1234;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2743
	    if (u.b[0] != 0x12) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2744
		if (n <= NLOCALBUFFER) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2745
		    cp2 = xlatebuffer;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2746
		} else {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2747
		    cp2 = (XChar2b *)(malloc(n * 2));
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2748
		    mustFree = 1;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2749
		}
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2750
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2751
		for (i=0; i<n; i++) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2752
		    cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2753
		    cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2754
		}
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2755
		cp = (char *) cp2;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2756
	    }
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2757
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2758
	    if (opaque == true)
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2759
		XDrawImageString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, n);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2760
	    else
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2761
		XDrawString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, n);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2762
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2763
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2764
	    if (mustFree) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2765
		free(cp2);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2766
	    }
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2767
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2768
	    RETURN ( self );
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2769
	}
486
0c35ed67797d oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents: 481
diff changeset
  2770
    }
461
4a4b1384ab76 X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents: 459
diff changeset
  2771
#undef NLOCALBUFFER
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2772
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2773
    "x/y not integer, badGC or drawable, or not a string"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2774
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2775
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2776
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2777
drawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2778
			  width:imageWidth height:imageHeight 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2779
			      x:srcx y:srcy
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2780
			   into:aDrawableId 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2781
			      x:dstx y:dsty 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2782
			  width:w height:h 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2783
			   with:aGCId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2784
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2785
    "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
  2786
     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
  2787
     Individual source pixels have bitsPerPixel bits, allowing to draw
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2788
     depth and pixel-units to be different.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2789
     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
  2790
     depth - otherwise, primitive failure will be signalled.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2791
     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
  2792
     colors are allocated - otherwise the colors may be wrong."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2793
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2794
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2795
     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
  2796
     an unlimited stack, and thus cannot send primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2797
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2798
    (self primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2799
					width:imageWidth height:imageHeight 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2800
					     x:srcx y:srcy
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2801
					  into:aDrawableId 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2802
					     x:dstx y:dsty 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2803
					 width:w height:h 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2804
					  with:aGCId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2805
    ifFalse:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2806
	"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2807
	 also happens, if a segmentation violation occurs in the 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2808
	 XPutImage ...
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2809
	"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2810
	self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2811
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2812
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2813
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2814
drawBits:imageBits depth:imageDepth 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2815
		   width:imageWidth height:imageHeight 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2816
		       x:srcx y:srcy
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2817
		    into:aDrawableId 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2818
		       x:dstx y:dsty 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2819
		   width:w height:h 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2820
		    with:aGCId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2821
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2822
    "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
  2823
     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
  2824
     Individual source pixels must have imageDepth bits.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2825
     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
  2826
     depth - otherwise, primitive failure will be signalled.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2827
     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
  2828
     colors are allocated - otherwise the colors may be wrong."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2829
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2830
    ^ self drawBits:imageBits bitsPerPixel:imageDepth depth:imageDepth 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2831
				     width:imageWidth height:imageHeight 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2832
					 x:srcx y:srcy
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2833
				      into:aDrawableId 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2834
					 x:dstx y:dsty 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2835
				     width:w height:h 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2836
				      with:aGCId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2837
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2838
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2839
652
30a701619098 fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents: 613
diff changeset
  2840
fillArcX:x y:y width:width height:height from:startAngle angle:angle
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2841
	       in:aDrawableId with:aGCId
90
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
  2842
    "fill an arc. If any coordinate is not integer, an error is triggered.
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
  2843
     The angles may be floats or integer - they are given in degrees."
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2844
48194c26a46c Initial revision
claus
parents:
diff changeset
  2845
%{  /* NOCONTEXT */
48194c26a46c Initial revision
claus
parents:
diff changeset
  2846
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2847
    GC gc;
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2848
    Window win;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2849
    int w, h, angle1, angle2;
48194c26a46c Initial revision
claus
parents:
diff changeset
  2850
    double f;
48194c26a46c Initial revision
claus
parents:
diff changeset
  2851
97
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  2852
    if (__isSmallInteger(startAngle))
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2853
	angle1 = __intVal(startAngle) * 64;
36
b297468551c6 *** empty log message ***
claus
parents: 31
diff changeset
  2854
    else if (__isFloat(startAngle)) {
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2855
	f = __floatVal(startAngle);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2856
	angle1 = f * 64;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2857
    }
97
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  2858
    if (__isSmallInteger(angle))
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2859
	angle2 = __intVal(angle) * 64;
36
b297468551c6 *** empty log message ***
claus
parents: 31
diff changeset
  2860
    else if (__isFloat(angle)) {
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2861
	f = __floatVal(angle);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2862
	angle2 = f * 64;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2863
    }
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  2864
    if (__isExternalAddress(aGCId)
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  2865
     && __isExternalAddress(aDrawableId)
97
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  2866
     && __bothSmallInteger(x, y)
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  2867
     && __bothSmallInteger(width, height)) {
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2868
	gc = _GCVal(aGCId);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2869
	win = _WindowVal(aDrawableId);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2870
	w = __intVal(width);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2871
	h = __intVal(height);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2872
	/*
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2873
	 * need this check here: some servers simply dump core with bad args
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2874
	 */
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2875
	if ((w >= 0) && (h >= 0) && (angle1 >= 0) && (angle2 >= 0)) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2876
	    XFillArc(myDpy, win, gc, __intVal(x), __intVal(y),
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2877
				   w, h, angle1, angle2);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2878
	}
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  2879
	RETURN ( self );
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2880
    }
73
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2881
%}.
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2882
    "badGC, badDrawable or coordinates not integer"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2883
    self primitiveFailed
48194c26a46c Initial revision
claus
parents:
diff changeset
  2884
!
48194c26a46c Initial revision
claus
parents:
diff changeset
  2885
48194c26a46c Initial revision
claus
parents:
diff changeset
  2886
fillPolygon:aPolygon in:aDrawableId with:aGCId
118
25e775072a89 *** empty log message ***
claus
parents: 115
diff changeset
  2887
    "fill a polygon given by its points. 
25e775072a89 *** empty log message ***
claus
parents: 115
diff changeset
  2888
     If any coordinate is not integer, an error is triggered."
73
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2889
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2890
    |numberOfPoints|
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2891
48194c26a46c Initial revision
claus
parents:
diff changeset
  2892
    numberOfPoints := aPolygon size.
48194c26a46c Initial revision
claus
parents:
diff changeset
  2893
%{
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2894
    GC gc;
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2895
    Window win;
73
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2896
    OBJ point, x, y;
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2897
    int i, num;
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2898
    XPoint *points;
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2899
    XPoint qPoints[100];
377
191915daff5e *** empty log message ***
ah
parents: 374
diff changeset
  2900
    int mustFree = 0;
73
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2901
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  2902
    if (__isExternalAddress(aGCId)
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  2903
     && __isExternalAddress(aDrawableId)
97
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  2904
     && __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
  2905
	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
  2906
	win = _WindowVal(aDrawableId);
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  2907
	num = __intVal(numberOfPoints);
73
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2908
	if (num < 3) {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2909
	    RETURN ( self );
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2910
	}
73
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2911
	/*
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2912
	 * avoid (slow) malloc, if not many points
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2913
	 */
96
claus
parents: 90
diff changeset
  2914
	if (num > 100) {
73
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2915
	    points = (XPoint *) malloc(sizeof(XPoint) * num);
96
claus
parents: 90
diff changeset
  2916
	    if (! points) goto fail;
377
191915daff5e *** empty log message ***
ah
parents: 374
diff changeset
  2917
	    mustFree = 1;
96
claus
parents: 90
diff changeset
  2918
	} else
73
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2919
	    points = qPoints;
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2920
	for (i=0; i<num; i++) {
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  2921
	    point = __AT_(aPolygon COMMA_CON, __MKSMALLINT(i+1));
73
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2922
	    if (! __isPoint(point)) goto fail;
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2923
	    x = _point_X(point);
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2924
	    y = _point_Y(point);
97
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  2925
	    if (! __bothSmallInteger(x, y))
73
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2926
		goto fail;
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  2927
	    points[i].x = __intVal(x);
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  2928
	    points[i].y = __intVal(y);
73
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2929
	}
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2930
	XFillPolygon(myDpy, win, gc, points, num, Complex, CoordModeOrigin);
377
191915daff5e *** empty log message ***
ah
parents: 374
diff changeset
  2931
	if (mustFree)
73
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2932
	    free(points);
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2933
	RETURN ( self );
377
191915daff5e *** empty log message ***
ah
parents: 374
diff changeset
  2934
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2935
fail: ;
382
92200ee9f558 added sendKey/sendButtonEvent
ah
parents: 378
diff changeset
  2936
	if (mustFree)
92200ee9f558 added sendKey/sendButtonEvent
ah
parents: 378
diff changeset
  2937
	    free(points);
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2938
    }
73
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2939
%}.
dd85c19ec8d9 final before switching to new primitive stuff
claus
parents: 72
diff changeset
  2940
    "badGC, badDrawable or coordinates not integer"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2941
    self primitiveFailed
48194c26a46c Initial revision
claus
parents:
diff changeset
  2942
!
48194c26a46c Initial revision
claus
parents:
diff changeset
  2943
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2944
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
  2945
    "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
  2946
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2947
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2948
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2949
    int w, h;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2950
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2951
    if (__isExternalAddress(aGCId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2952
     && __isExternalAddress(aDrawableId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2953
     && __bothSmallInteger(x, y)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2954
     && __bothSmallInteger(width, height)) {
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  2955
	w = __intVal(width);
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  2956
	h = __intVal(height);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2957
	/*
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2958
	 * 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
  2959
	 */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2960
	if ((w >= 0) && (h >= 0)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2961
	    XFillRectangle(myDpy,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2962
			   (Drawable)_WindowVal(aDrawableId), _GCVal(aGCId),
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  2963
			   __intVal(x), __intVal(y), w, h);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2964
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2965
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2966
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2967
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2968
    "badGC, badDrawable or coordinates not integer"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  2969
    self primitiveFailed
43
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
  2970
!
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
  2971
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
  2972
primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth 
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2973
			      width:imageWidth height:imageHeight 
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2974
				  x:srcx y:srcy
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2975
			       into:aDrawableId 
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2976
				  x:dstx y:dsty 
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2977
			      width:w height:h 
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  2978
			       with:aGCId
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2979
132
claus
parents: 129
diff changeset
  2980
    "since XPutImage may allocate huge amount of stack space 
claus
parents: 129
diff changeset
  2981
     (some implementations use alloca), this must run with unlimited stack."
claus
parents: 129
diff changeset
  2982
12
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  2983
%{  /* UNLIMITEDSTACK */
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  2984
43
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
  2985
    /*
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
  2986
     * need unlimited stack, since some Xlibs do a huge alloca in
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
  2987
     * XPutImage
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
  2988
     */
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
  2989
    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
  2990
    GC gc;
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2991
    Window win;
43
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
  2992
    XImage image;
377
191915daff5e *** empty log message ***
ah
parents: 374
diff changeset
  2993
    int imgWdth;
43
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
  2994
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  2995
    if (__isExternalAddress(aGCId)
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  2996
     && __isExternalAddress(aDrawableId)
97
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  2997
     && __bothSmallInteger(srcx, srcy)
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  2998
     && __bothSmallInteger(dstx, dsty)
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  2999
     && __bothSmallInteger(w, h)
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  3000
     && __bothSmallInteger(imageWidth, imageHeight)
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  3001
     && __bothSmallInteger(imageDepth, bitsPerPixel)
43
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
  3002
     && __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
  3003
	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
  3004
	win = _WindowVal(aDrawableId);
811
bf8721a1e3ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
  3005
	if (! gc || !win) 
bf8721a1e3ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
  3006
	    goto fail;
46
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  3007
#ifdef ARGDEBUG
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3008
	printf("args ok\n");
46
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  3009
#endif
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  3010
	image.data = (char *)__ByteArrayInstPtr(imageBits)->ba_element;
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  3011
	image.width = imgWdth = __intVal(imageWidth);
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  3012
	image.height = __intVal(imageHeight);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3013
	image.xoffset = 0;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3014
	image.format = ZPixmap;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3015
	image.byte_order = MSBFirst;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3016
	image.bitmap_unit = 8;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3017
	image.bitmap_bit_order = MSBFirst;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3018
	image.bitmap_pad = 8;
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  3019
	image.depth = __intVal(imageDepth);
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  3020
	image.bits_per_pixel = __intVal(bitsPerPixel);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3021
	switch (image.bits_per_pixel) {
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3022
	    case 1:
377
191915daff5e *** empty log message ***
ah
parents: 374
diff changeset
  3023
		image.bytes_per_line = (imgWdth + 7) / 8;
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3024
		break;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3025
	    case 2:
377
191915daff5e *** empty log message ***
ah
parents: 374
diff changeset
  3026
		image.bytes_per_line = (imgWdth*2 + 7) / 8;
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3027
		break;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3028
	    case 4:
377
191915daff5e *** empty log message ***
ah
parents: 374
diff changeset
  3029
		image.bytes_per_line = (imgWdth*4 + 7) / 8;
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3030
		break;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3031
	    case 8:
377
191915daff5e *** empty log message ***
ah
parents: 374
diff changeset
  3032
		image.bytes_per_line = imgWdth;
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3033
		break;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3034
	    case 16:
377
191915daff5e *** empty log message ***
ah
parents: 374
diff changeset
  3035
		image.bytes_per_line = imgWdth*2;
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3036
		break;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3037
	    case 24:
377
191915daff5e *** empty log message ***
ah
parents: 374
diff changeset
  3038
		image.bytes_per_line = imgWdth*3;
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3039
		break;
193
Claus Gittinger <cg@exept.de>
parents: 190
diff changeset
  3040
	    case 32:
377
191915daff5e *** empty log message ***
ah
parents: 374
diff changeset
  3041
		image.bytes_per_line = imgWdth*4;
193
Claus Gittinger <cg@exept.de>
parents: 190
diff changeset
  3042
		break;
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3043
	    default:
46
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  3044
#ifdef ARGDEBUG
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3045
		printf("bits_per_pixel=%d\n",image.bits_per_pixel);
46
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  3046
#endif
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3047
		goto fail;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3048
	}
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3049
	image.red_mask = 0xFFFF;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3050
	image.green_mask = 0xFFFF;
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3051
	image.blue_mask = 0xFFFF;
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  3052
	XPutImage(dpy, win, gc, &image, __intVal(srcx), __intVal(srcy),
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  3053
					__intVal(dstx), __intVal(dsty),
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  3054
					__intVal(w), __intVal(h));
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3055
	RETURN ( true );
43
1d44cc4da884 *** empty log message ***
claus
parents: 37
diff changeset
  3056
    }
46
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  3057
#ifdef ARGDEBUG
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  3058
    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
  3059
    if (!! __isExternalAddress(aDrawableId)) printf("aDrawableId\n");
193
Claus Gittinger <cg@exept.de>
parents: 190
diff changeset
  3060
    if (!! __isSmallInteger(srcx)) printf("srcx\n");
Claus Gittinger <cg@exept.de>
parents: 190
diff changeset
  3061
    if (!! __isSmallInteger(srcy)) printf("srcy\n");
Claus Gittinger <cg@exept.de>
parents: 190
diff changeset
  3062
    if (!! __isSmallInteger(dstx)) printf("dstx\n");
Claus Gittinger <cg@exept.de>
parents: 190
diff changeset
  3063
    if (!! __isSmallInteger(dsty)) printf("dsty\n");
Claus Gittinger <cg@exept.de>
parents: 190
diff changeset
  3064
    if (!! __isSmallInteger(w)) printf("w\n");
Claus Gittinger <cg@exept.de>
parents: 190
diff changeset
  3065
    if (!! __isSmallInteger(h)) printf("h\n");
Claus Gittinger <cg@exept.de>
parents: 190
diff changeset
  3066
    if (!! __isSmallInteger(imageWidth)) printf("imageWidth\n");
Claus Gittinger <cg@exept.de>
parents: 190
diff changeset
  3067
    if (!! __isSmallInteger(imageHeight)) printf("imageHeight\n");
Claus Gittinger <cg@exept.de>
parents: 190
diff changeset
  3068
    if (!! __isSmallInteger(imageDepth)) printf("imageDepth\n");
Claus Gittinger <cg@exept.de>
parents: 190
diff changeset
  3069
    if (!! __isSmallInteger(bitsPerPixel)) printf("bitsPerPixel\n");
Claus Gittinger <cg@exept.de>
parents: 190
diff changeset
  3070
    if (!! __isByteArray(imageBits)) printf("imageBits\n");
46
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  3071
#endif
7b331e9012fd *** empty log message ***
claus
parents: 44
diff changeset
  3072
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  3073
fail: ;
48194c26a46c Initial revision
claus
parents:
diff changeset
  3074
%}
48194c26a46c Initial revision
claus
parents:
diff changeset
  3075
.
12
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3076
    ^ false
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  3077
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
  3078
86
032006651226 *** empty log message ***
claus
parents: 83
diff changeset
  3079
!XWorkstation methodsFor:'event handling'!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  3080
48194c26a46c Initial revision
claus
parents:
diff changeset
  3081
dispatchEventFor:aViewIdOrNil withMask:eventMask
48194c26a46c Initial revision
claus
parents:
diff changeset
  3082
    "central event handling method:
54
29a6b2f8e042 *** empty log message ***
claus
parents: 46
diff changeset
  3083
     get next event and send appropriate message to the sensor or view.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  3084
     If the argument aViewIdOrNil is nil, events for any view are processed,
12
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3085
     otherwise only events for the view with given id are processed.
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3086
     If the argument aMask is nonNil, only events for this eventMask are
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3087
     handled."
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3088
54
29a6b2f8e042 *** empty log message ***
claus
parents: 46
diff changeset
  3089
    (self getEventFor:aViewIdOrNil withMask:eventMask) ifTrue:[
392
caf4452ec3dd merged sendKey/ButtonEvent into one method;
Claus Gittinger <cg@exept.de>
parents: 391
diff changeset
  3090
	AbortSignal catch:[
83
597bdb33e832 *** empty log message ***
claus
parents: 82
diff changeset
  3091
	    self dispatchLastEvent.
597bdb33e832 *** empty log message ***
claus
parents: 82
diff changeset
  3092
	]
54
29a6b2f8e042 *** empty log message ***
claus
parents: 46
diff changeset
  3093
    ].
12
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3094
!
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3095
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3096
dispatchExposeEventFor:aViewIdOrNil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3097
    "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
  3098
     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
  3099
     otherwise only events for the view with given id are processed."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3100
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3101
    self dispatchEventFor:aViewIdOrNil withMask:(self eventMaskFor:#expose)
12
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3102
!
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3103
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3104
dispatchLastEvent
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  3105
    |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
  3106
     eventType|
12
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3107
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3108
%{  /* STACK: 8000 */
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3109
#   define ANYBUTTON   (Button1MotionMask | Button2MotionMask | Button3MotionMask)
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  3110
48194c26a46c Initial revision
claus
parents:
diff changeset
  3111
    Display *dpy = myDpy;
135
claus
parents: 133
diff changeset
  3112
    OBJ eB;
claus
parents: 133
diff changeset
  3113
    XEvent *ev;
claus
parents: 133
diff changeset
  3114
claus
parents: 133
diff changeset
  3115
#   define ae ((XAnyEvent *)ev)
claus
parents: 133
diff changeset
  3116
#   define ee ((XExposeEvent *)ev)
claus
parents: 133
diff changeset
  3117
#   define ke ((XKeyPressedEvent *)ev)
claus
parents: 133
diff changeset
  3118
#   define be ((XButtonPressedEvent *)ev)
claus
parents: 133
diff changeset
  3119
#   define ce ((XConfigureEvent *)ev)
claus
parents: 133
diff changeset
  3120
#   define me ((XMotionEvent *)ev)
claus
parents: 133
diff changeset
  3121
#   define ewe ((XEnterWindowEvent *)ev)
claus
parents: 133
diff changeset
  3122
#   define lwe ((XLeaveWindowEvent *)ev)
claus
parents: 133
diff changeset
  3123
#   define de ((XDestroyWindowEvent *)ev)
claus
parents: 133
diff changeset
  3124
#   define ve ((XVisibilityEvent *)ev)
288
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  3125
#   define mape ((XMappingEvent *)ev)
135
claus
parents: 133
diff changeset
  3126
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  3127
    KeySym keySym;
48194c26a46c Initial revision
claus
parents:
diff changeset
  3128
    unsigned char buffer[10];
48194c26a46c Initial revision
claus
parents:
diff changeset
  3129
    int i, nchars;
48194c26a46c Initial revision
claus
parents:
diff changeset
  3130
    char *keySymString;
48194c26a46c Initial revision
claus
parents:
diff changeset
  3131
    char keySymStringBuffer[32];
48194c26a46c Initial revision
claus
parents:
diff changeset
  3132
    static unsigned multiClickTime = 0;
48194c26a46c Initial revision
claus
parents:
diff changeset
  3133
    unsigned nextMultiClickTime;
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3134
    OBJ upDown;
115
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3135
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3136
    struct inlineCache *ipS;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  3137
    static struct inlineCache vid = _ILC1;
12
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3138
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3139
    static struct inlineCache expS = _ILC5;
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3140
    static struct inlineCache gexpS = _ILC5;
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3141
    static struct inlineCache nexpS = _ILC1;
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3142
    static struct inlineCache motS = _ILC4;
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3143
    static struct inlineCache bpS = _ILC4;
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3144
    static struct inlineCache bmpS = _ILC4;
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3145
    static struct inlineCache bspS = _ILC4;
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3146
    static struct inlineCache brS = _ILC4;
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3147
    static struct inlineCache focInS = _ILC1;
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3148
    static struct inlineCache focOutS = _ILC1;
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3149
    static struct inlineCache peS = _ILC4;
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3150
    static struct inlineCache plS = _ILC2;
54
29a6b2f8e042 *** empty log message ***
claus
parents: 46
diff changeset
  3151
    static struct inlineCache termS = _ILC1;
29a6b2f8e042 *** empty log message ***
claus
parents: 46
diff changeset
  3152
    static struct inlineCache savtermS = _ILC1;
29a6b2f8e042 *** empty log message ***
claus
parents: 46
diff changeset
  3153
    static struct inlineCache destrS = _ILC1;
29a6b2f8e042 *** empty log message ***
claus
parents: 46
diff changeset
  3154
    static struct inlineCache unmapS = _ILC1;
29a6b2f8e042 *** empty log message ***
claus
parents: 46
diff changeset
  3155
    static struct inlineCache mapS = _ILC1;
29a6b2f8e042 *** empty log message ***
claus
parents: 46
diff changeset
  3156
    static struct inlineCache confS = _ILC5;
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3157
    static struct inlineCache coveredS = _ILC2;
12
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3158
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3159
    static struct inlineCache keymap = _ILC0;
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3160
    static struct inlineCache created = _ILC0;
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3161
    static struct inlineCache mapReq = _ILC0;
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3162
    static struct inlineCache repar = _ILC0;
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3163
    static struct inlineCache confReq = _ILC0;
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3164
    static struct inlineCache resReq = _ILC0;
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3165
    static struct inlineCache prop = _ILC0;
129
752fbb07635a *** empty log message ***
claus
parents: 125
diff changeset
  3166
    static struct inlineCache selClear = _ILC1;
90
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
  3167
    static struct inlineCache selReq = _ILC4;
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
  3168
    static struct inlineCache selNotify = _ILC4;
12
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3169
    static struct inlineCache colormap = _ILC0;
288
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  3170
    static struct inlineCache mapping = _ILC2;
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3171
    static struct inlineCache vis = _ILC1;
12
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3172
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3173
    static struct inlineCache skpS = _ILC4;
63
b9d17e2b6c92 keyRelease and more event masks
claus
parents: 55
diff changeset
  3174
    static struct inlineCache skrS = _ILC4;
12
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3175
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  3176
    eB = __INST(eventBuffer);
135
claus
parents: 133
diff changeset
  3177
    if (__isByteArray(eB)) {
1010
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3178
        ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element);
135
claus
parents: 133
diff changeset
  3179
    } else {
1010
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3180
        printf("DISPLAY: no eventBuffer\n");
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3181
        RETURN (false);
135
claus
parents: 133
diff changeset
  3182
    }
claus
parents: 133
diff changeset
  3183
207
9124817bbb03 use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents: 206
diff changeset
  3184
    windowID = __MKOBJ(ae->window);
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  3185
    theView = (*vid.ilc_func)(self, @symbol(viewFromId:) COMMA_CON, nil, &vid, windowID);
12
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3186
288
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  3187
    if ((theView == nil) && (ev->type != MappingNotify)) {
1010
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3188
        RETURN (nil);
12
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3189
    }
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3190
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3191
    /*
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3192
     * key, button and pointer events are sent to the sensor,
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3193
     * or (if there is none) to the delegate.
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3194
     * or (if there is none) to the view.
26
ac9f66dc8f53 *** empty log message ***
claus
parents: 23
diff changeset
  3195
     *
ac9f66dc8f53 *** empty log message ***
claus
parents: 23
diff changeset
  3196
     * expose events are sent to the sensor,
ac9f66dc8f53 *** empty log message ***
claus
parents: 23
diff changeset
  3197
     * or (if there is none) to the view
ac9f66dc8f53 *** empty log message ***
claus
parents: 23
diff changeset
  3198
     *
12
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3199
     * sensor and delegate get view as additional argument
115
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3200
     * all of this has been taken out of here to corresponding methods
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
  3201
     * in DeviceWorkstation.
12
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3202
     */
90
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
  3203
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  3204
#ifdef DEBUG
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  3205
    eventType = __MKSMALLINT(ev->type);
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  3206
#endif
135
claus
parents: 133
diff changeset
  3207
    switch (ev->type) {
1010
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3208
        case KeyRelease:
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3209
            symS = @symbol(keyRelease:x:y:view:);
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3210
            ipS = &skrS;
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3211
            upDown = false;
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3212
            goto keyPressAndRelease;
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3213
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3214
        case KeyPress:
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3215
            symS = @symbol(keyPress:x:y:view:);
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3216
            ipS = &skpS;
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3217
            upDown = true;
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3218
            /* FALL INTO */
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3219
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3220
        keyPressAndRelease:
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3221
            __INST(eventRootX) = __MKSMALLINT(ke->x_root);
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3222
            __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
  3223
#ifdef OLD
1010
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3224
            __INST(altDown) = (ke->state & Mod2Mask) ? true : false;
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3225
            __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
  3226
#else
1010
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3227
            __INST(altDown) = (ke->state & __intVal(__INST(altModifierMask))) ? true : false;
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3228
            __INST(metaDown) = (ke->state & __intVal(__INST(metaModifierMask))) ? true : false;
240
bdbab643c0e7 allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  3229
#endif
1010
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3230
            __INST(shiftDown) = (ke->state & ShiftMask) ? true : false;
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3231
            __INST(ctrlDown) = (ke->state & ControlMask) ? true : false;
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3232
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3233
            arg = nil;
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3234
            nchars = XLookupString(ke, (char *)buffer, sizeof(buffer), &keySym, NULL);
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3235
            if (nchars 
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3236
             && (((buffer[0] >= ' ') && (buffer[0] <= '~'))
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3237
                 || (buffer[0] >= 0x80))) {
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3238
                arg = _MKCHARACTER(buffer[0])/* *_CharacterTable[buffer[0]] */;
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3239
                keySymString = NULL;
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3240
            } else {
250
eaa532ebcad7 modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
  3241
#ifdef OLD
1010
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3242
                switch (keySym) {
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3243
                    case XK_Control_L:
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3244
                    case XK_Control_R:
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3245
                        __INST(ctrlDown) = upDown;
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3246
                        break;
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3247
                    case XK_Shift_L:
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3248
                    case XK_Shift_R:
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3249
                        __INST(shiftDown) = upDown;
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3250
                        break;
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3251
                    case XK_Meta_L:
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3252
                    case XK_Meta_R:
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3253
                        __INST(metaDown) = upDown;
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3254
                        break;
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3255
                    case XK_Alt_L:
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3256
                    case XK_Alt_R:
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3257
                        __INST(altDown) = upDown;
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3258
                        break;
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3259
                }
250
eaa532ebcad7 modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
  3260
#endif
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3261
1010
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3262
                keySymString = XKeysymToString(keySym);
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3263
                if (keySymString) {
250
eaa532ebcad7 modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
  3264
#ifdef OLD
1010
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3265
                    if (keySymString[0] == 'D') {
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3266
                        /*
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3267
                         * remove underscore, dont want it in symbols
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3268
                         */
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3269
                        if (strcmp(keySymString, "Delete_line") == 0) {
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3270
                            keySymString = "DeleteLine";
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3271
                        } else if (strcmp(keySymString, "Delete_word") == 0) {
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3272
                            keySymString = "DeleteWord";
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3273
                        }
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3274
                    }
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3275
                    /*
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3276
                     * make names compatible
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3277
                     */
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3278
                    if (strcmp(keySymString, "Down") == 0) {
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3279
                        keySymString = "CursorDown";
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3280
                    } else if (strcmp(keySymString, "Up") == 0) {
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3281
                        keySymString = "CursorUp";
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3282
                    } else if (strcmp(keySymString, "Left") == 0) {
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3283
                        keySymString = "CursorLeft";
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3284
                    } else if (strcmp(keySymString, "Right") == 0) {
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3285
                        keySymString = "CursorRight";
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3286
                    }
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3287
                    arg = __MKSYMBOL(keySymString, (OBJ *)0, __context);
250
eaa532ebcad7 modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
  3288
#else
1010
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3289
                    __PROTECT__(theView);
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3290
                    arg = __MKSTRING(keySymString COMMA_CON);
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3291
                    __UNPROTECT__(theView);
250
eaa532ebcad7 modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
  3292
#endif
1010
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3293
                }
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3294
            }
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3295
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3296
            if (arg == nil) {
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3297
                /* happens sometimes (alt-graph on sun has no keysym) */
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3298
                break;
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3299
            }
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3300
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3301
            (*(*ipS).ilc_func)(self, symS COMMA_CON, nil, ipS,
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3302
                               arg, 
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3303
                               __MKSMALLINT(ke->x), 
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3304
                               __MKSMALLINT(ke->y),
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3305
                               theView);
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3306
            break;
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3307
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3308
        case ButtonPress:
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3309
            __INST(buttonsPressed) = __MKSMALLINT(__intVal(__INST(buttonsPressed)) | (1 << be->button));
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3310
            __INST(eventRootX) = __MKSMALLINT(be->x_root);
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3311
            __INST(eventRootY) = __MKSMALLINT(be->y_root);
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3312
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3313
            if (__isSmallInteger(__INST(multiClickTimeDelta)))
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3314
                nextMultiClickTime = be->time + __intVal(__INST(multiClickTimeDelta));
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3315
            else
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3316
                nextMultiClickTime = 0;
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3317
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3318
            if (multiClickTime) {
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3319
                if (be->time < multiClickTime) {
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3320
                    multiClickTime = nextMultiClickTime;
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3321
                    ipS = &bmpS;
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3322
                    symS = @symbol(buttonMultiPress:x:y:view:);
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3323
                    goto sendButtonEvent;
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3324
                    break;
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3325
                }
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3326
            }
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3327
            multiClickTime = nextMultiClickTime;
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3328
#ifdef NO_LONGER
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3329
            if (be->state & ShiftMask) {
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3330
                ipS = &bspS;
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3331
                symS = @symbol(buttonShiftPress:x:y:view:);
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3332
                goto sendButtonEvent;
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3333
            }
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3334
#endif
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3335
            ipS = &bpS;
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3336
            symS = @symbol(buttonPress:x:y:view:);
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3337
            goto sendButtonEvent;
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3338
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3339
            /* NOT REACHED */
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3340
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3341
        case ButtonRelease:
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3342
            __INST(buttonsPressed) = __MKSMALLINT(__intVal(__INST(buttonsPressed)) & ~(1 << be->button));
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3343
            __INST(eventRootX) = __MKSMALLINT(be->x_root);
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3344
            __INST(eventRootY) = __MKSMALLINT(be->y_root);
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3345
            ipS = &brS;
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3346
            symS = @symbol(buttonRelease:x:y:view:);
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3347
            /* fall into */
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3348
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3349
        sendButtonEvent:
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3350
            butt = __MKSMALLINT(be->button);
12
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3351
#ifdef NOTDEF
1010
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3352
            /*
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3353
             * this allows operation with single button mouses: meta-click is always Button 2
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3354
             */
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3355
            if (__INST(metaDown) == true)
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3356
                butt = __MKSMALLINT(2);
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3357
            else 
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  3358
#endif
1010
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3359
                butt = __AT_(__INST(buttonTranslation), butt);
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3360
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3361
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3362
            (*(*ipS).ilc_func)(self, 
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3363
                               symS
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3364
                               COMMA_CON, nil, ipS,
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3365
                               butt, 
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3366
                               __MKSMALLINT(ke->x), 
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3367
                               __MKSMALLINT(ke->y),
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3368
                               theView);
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3369
            break;
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3370
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3371
        case MotionNotify:
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3372
            if (__INST(motionEventCompression) != false) {
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3373
                while (XCheckWindowEvent(dpy, me->window, ANYBUTTON, ev)) ;;
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3374
            }
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3375
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3376
            __INST(eventRootX) = __MKSMALLINT(me->x_root);
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3377
            __INST(eventRootY) = __MKSMALLINT(me->y_root);
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3378
240
bdbab643c0e7 allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  3379
#ifdef OLD
1010
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3380
            __INST(altDown) = (me->state & Mod2Mask) ? true : false;
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3381
            __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
  3382
#else
1010
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3383
            __INST(altDown) = (ke->state & __intVal(__INST(altModifierMask))) ? true : false;
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3384
            __INST(metaDown) = (ke->state & __intVal(__INST(metaModifierMask))) ? true : false;
240
bdbab643c0e7 allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  3385
#endif
1010
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3386
            __INST(shiftDown) = (me->state & ShiftMask) ? true : false;
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3387
            __INST(ctrlDown) = (me->state & ControlMask) ? true : false;
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3388
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3389
            (*motS.ilc_func)(self, 
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3390
                             @symbol(buttonMotion:x:y:view:)
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3391
                             COMMA_CON, nil, &motS,
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3392
                             __MKSMALLINT(me->state),
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3393
                             __MKSMALLINT(me->x),
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3394
                             __MKSMALLINT(me->y),
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3395
                             theView);
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3396
            break;
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3397
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3398
        case FocusIn:
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3399
            (*focInS.ilc_func)(self, 
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3400
                               @symbol(focusInView:)
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3401
                               COMMA_CON, nil, &focInS, 
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3402
                               theView);
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3403
            break;
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3404
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3405
        case FocusOut:
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3406
            (*focOutS.ilc_func)(self, 
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3407
                                @symbol(focusOutView:)
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3408
                                COMMA_CON, nil, &focOutS, 
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3409
                                theView);
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3410
            break;
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3411
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3412
        case EnterNotify:
240
bdbab643c0e7 allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  3413
#ifdef OLD
1010
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3414
            __INST(altDown) = (ewe->state & Mod2Mask) ? true : false;
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3415
            __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
  3416
#else
1010
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3417
            __INST(altDown) = (ke->state & __intVal(__INST(altModifierMask))) ? true : false;
b8576573e6aa no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
  3418
            __INST(metaDown) = (ke->state & __intVal(__INST(metaModifierMask))) ? true : false;
240
bdbab643c0e7 allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  3419
#endif
1014
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3420
	    __INST(shiftDown) = (ewe->state & ShiftMask) ? true : false;
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3421
	    __INST(ctrlDown) = (ewe->state & ControlMask) ? true : false;
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3422
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3423
	    (*peS.ilc_func)(self, 
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3424
			    @symbol(pointerEnter:x:y:view:)
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3425
			    COMMA_CON, nil, &peS,
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3426
			    __MKSMALLINT(ewe->state),
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3427
			    __MKSMALLINT(ewe->x), 
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3428
			    __MKSMALLINT(ewe->y),
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3429
			    theView);
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3430
	    break;
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3431
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3432
	case LeaveNotify:
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3433
	    (*plS.ilc_func)(self, 
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3434
			    @symbol(pointerLeave:view:)
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3435
			    COMMA_CON, nil, &plS,
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3436
			    __MKSMALLINT(lwe->state), 
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3437
			    theView);
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3438
	    break;
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3439
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3440
	case GraphicsExpose:
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3441
	    (*gexpS.ilc_func)(self, 
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3442
			      @symbol(graphicExposeX:y:width:height:view:)
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3443
			      COMMA_CON, nil, &gexpS,
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3444
			      __MKSMALLINT(ee->x),
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3445
			      __MKSMALLINT(ee->y),
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3446
			      __MKSMALLINT(ee->width),
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3447
			      __MKSMALLINT(ee->height),
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3448
			      theView);
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3449
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3450
	    if (ee->count != 0) {
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3451
		break;
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3452
	    }
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3453
	    /* fall into */
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3454
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3455
	case NoExpose:
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3456
	    (*nexpS.ilc_func)(self, 
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3457
			      @symbol(noExposeView:)
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3458
			      COMMA_CON, nil, &nexpS, 
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3459
			      theView);
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3460
	    break;
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3461
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3462
	case Expose:
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3463
	    (*expS.ilc_func)(self, 
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3464
			     @symbol(exposeX:y:width:height:view:)
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3465
			     COMMA_CON, nil, &expS,
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3466
			     __MKSMALLINT(ee->x),
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3467
			     __MKSMALLINT(ee->y),
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3468
			     __MKSMALLINT(ee->width),
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3469
			     __MKSMALLINT(ee->height),
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3470
			     theView);
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3471
	    break;
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3472
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3473
	case ConfigureNotify:
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3474
	    if (ce->above != None) {
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3475
		siblingID = __MKOBJ(ce->above);
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3476
		sibling = (*vid.ilc_func)(self, @symbol(viewFromId:) 
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3477
					  COMMA_CON, nil, &vid, siblingID);
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3478
	    }
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3479
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3480
	    (*confS.ilc_func)(self, 
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3481
			     @symbol(configureX:y:width:height:view:)
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3482
			     COMMA_CON, nil, &confS,
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3483
			     __MKSMALLINT(ce->x),
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3484
			     __MKSMALLINT(ce->y),
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3485
			     __MKSMALLINT(ce->width),
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3486
			     __MKSMALLINT(ce->height),
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3487
			     theView);
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3488
	    if (sibling != nil) {
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3489
		(*coveredS.ilc_func)(self,
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3490
				    @symbol(coveredBy:view:)
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3491
				    COMMA_CON, nil, &coveredS,
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3492
				    theView,
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3493
				    sibling);
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3494
	    }
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3495
	    break;
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3496
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3497
	case ClientMessage:
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3498
	    if (ev->xclient.message_type == (int) _AtomVal(__INST(protocolsAtom))) {
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3499
		if ((ev->xclient.data.l[0] == (int) _AtomVal(__INST(quitAppAtom)))
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3500
		 || (ev->xclient.data.l[0] == (int) _AtomVal(__INST(deleteWindowAtom)))) {
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3501
		    (*termS.ilc_func)(self, 
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3502
				      @symbol(terminateView:)
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3503
				      COMMA_CON, nil, &termS, theView);
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3504
		    break;
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3505
		}
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3506
		if (ev->xclient.data.l[0] == (int) _AtomVal(__INST(saveYourselfAtom))) {
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3507
		    (*savtermS.ilc_func)(self, 
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3508
					 @symbol(saveAndTerminateView:)
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3509
					 COMMA_CON, nil, &savtermS, theView);
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3510
		    break;
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3511
		}
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3512
	    }
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3513
	    break;
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3514
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3515
	case DestroyNotify:
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3516
	    (*destrS.ilc_func)(self, @symbol(destroyedView:)
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3517
			       COMMA_CON, nil, &destrS, theView);
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3518
	    break;
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3519
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3520
	case UnmapNotify:
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3521
	    (*unmapS.ilc_func)(self, @symbol(unmappedView:) 
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3522
			       COMMA_CON, nil, &unmapS, theView);
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3523
	    break;
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3524
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3525
	case MapNotify:
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3526
	    (*mapS.ilc_func)(self, 
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3527
			     @symbol(mappedView:) 
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3528
			     COMMA_CON, nil, &mapS, theView);
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3529
	    break;
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3530
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3531
	case KeymapNotify:
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3532
	    (*keymap.ilc_func)(theView, 
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3533
			       @symbol(keyMapChange) 
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3534
			       COMMA_CON, nil, &keymap);
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3535
	    break;
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3536
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3537
	case VisibilityNotify:
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3538
	    switch (ve->state) {
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3539
		case VisibilityUnobscured:
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3540
		    arg = @symbol(unobscured);
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3541
		    break;
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3542
		case VisibilityPartiallyObscured:
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3543
		    arg = @symbol(partiallyObscured);
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3544
		    break;
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3545
		case VisibilityFullyObscured:
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3546
		    arg = @symbol(fullyObscured);
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3547
		    break;
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3548
	    }
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3549
	    (*vis.ilc_func)(theView, @symbol(visibilityChange:) COMMA_CON, nil, &vis, arg);
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3550
	    break;
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3551
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3552
	case CreateNotify:
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3553
	    (*created.ilc_func)(theView, @symbol(created) COMMA_CON, nil, &created);
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3554
	    break;
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3555
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3556
	case MapRequest:
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3557
	    (*mapReq.ilc_func)(theView, @symbol(mapRequest) COMMA_CON, nil, &mapReq);
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3558
	    break;
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3559
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3560
	case ReparentNotify:
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3561
	    (*repar.ilc_func)(theView, @symbol(reparented) COMMA_CON, nil, &repar);
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3562
	    break;
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3563
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3564
	case ConfigureRequest:
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3565
	    (*confReq.ilc_func)(theView, @symbol(configRequest) COMMA_CON, nil, &confReq);
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3566
	    break;
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3567
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3568
	case GravityNotify:
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3569
	case ResizeRequest:
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3570
	    (*resReq.ilc_func)(theView, @symbol(resizeRequest) COMMA_CON, nil, &resReq);
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3571
	    break;
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3572
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3573
	case CirculateNotify:
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3574
	case CirculateRequest:
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3575
	    break;
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3576
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3577
	case PropertyNotify:
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3578
	    (*prop.ilc_func)(theView, 
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3579
			     @symbol(propertyChange) 
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3580
			     COMMA_CON, nil, &prop);
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3581
	    break;
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3582
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3583
	case SelectionClear:
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3584
	    selectionID = __MKATOMOBJ(ev->xselectionclear.selection);
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3585
	    (*selClear.ilc_func)(theView, 
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3586
				 @symbol(selectionClear:) 
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3587
				 COMMA_CON, nil, &selClear,
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3588
				 selectionID);
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3589
	    break;
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3590
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3591
	case SelectionNotify:
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3592
	    /*
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3593
	     * returned selection value (answer from SelectionRequest)
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3594
	     */
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3595
	    DPRINTF(("SelectionNotify prop=%x target=%x selection= %x requestor=%x\n", 
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3596
			ev->xselection.property, ev->xselection.target,
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3597
			ev->xselection.selection, ev->xselection.requestor));
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3598
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3599
	    propertyID = __MKATOMOBJ(ev->xselection.property);
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3600
	    targetID = __MKATOMOBJ(ev->xselection.target);
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3601
	    selectionID = __MKATOMOBJ(ev->xselection.selection);
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3602
	    requestorID = __MKOBJ(ev->xselection.requestor);
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3603
	    (*selNotify.ilc_func)(theView, 
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3604
				  @symbol(selectionNotify:target:selection:from:) 
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3605
				  COMMA_CON, nil, &selNotify,
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3606
				  propertyID, targetID, selectionID, requestorID);
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3607
	    break;
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3608
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3609
	case SelectionRequest:
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3610
	    /*
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3611
	     * someone wants the selection
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3612
	     */
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3613
	    DPRINTF(("SelectionRequest prop=%x target=%x selection=%x requestor=%x\n", 
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3614
			ev->xselectionrequest.property,
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3615
			ev->xselectionrequest.target,
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3616
			ev->xselectionrequest.selection,
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3617
			ev->xselectionrequest.requestor));
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3618
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3619
	    propertyID = __MKATOMOBJ(ev->xselectionrequest.property);
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3620
	    targetID = __MKATOMOBJ(ev->xselectionrequest.target);
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3621
	    selectionID = __MKATOMOBJ(ev->xselectionrequest.selection);
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3622
	    requestorID = __MKOBJ(ev->xselectionrequest.requestor);
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3623
	    (*selReq.ilc_func)(theView, 
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3624
			       @symbol(selectionRequest:target:selection:from:) 
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3625
			       COMMA_CON, nil, &selReq,
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3626
			       propertyID, targetID, selectionID, requestorID);
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3627
	    break;
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3628
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3629
	case ColormapNotify:
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3630
	    (*colormap.ilc_func)(theView, 
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3631
				 @symbol(colorMapChange) 
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3632
				 COMMA_CON, nil, &colormap);
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3633
	    break;
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3634
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3635
	case MappingNotify:
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3636
	    switch(mape->request) {
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3637
		case MappingModifier:
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3638
		    arg = @symbol(mappingModifier);
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3639
		    break;
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3640
		case MappingKeyboard:
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3641
		    arg = @symbol(mappingKeyboard);
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3642
		    break;
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3643
		case MappingPointer:
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3644
		    arg = @symbol(mappingPointer);
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3645
		    break;
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3646
		default:
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3647
		    arg = nil;
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3648
		    break;
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3649
	    }
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3650
	    (*mapping.ilc_func)(self, 
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3651
				@symbol(mappingChanged:event:) 
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3652
				COMMA_CON, nil, &mapping, arg, eB);
6be12d5937f5 removed obsolete font access methods
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  3653
	    break;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  3654
    }
135
claus
parents: 133
diff changeset
  3655
#undef ae
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  3656
#undef ee
48194c26a46c Initial revision
claus
parents:
diff changeset
  3657
#undef ke
48194c26a46c Initial revision
claus
parents:
diff changeset
  3658
#undef be
48194c26a46c Initial revision
claus
parents:
diff changeset
  3659
#undef ce
48194c26a46c Initial revision
claus
parents:
diff changeset
  3660
#undef me
48194c26a46c Initial revision
claus
parents:
diff changeset
  3661
#undef ewe
48194c26a46c Initial revision
claus
parents:
diff changeset
  3662
#undef lwe
48194c26a46c Initial revision
claus
parents:
diff changeset
  3663
#undef de
288
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  3664
#undef mape
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  3665
%}
48194c26a46c Initial revision
claus
parents:
diff changeset
  3666
.
48194c26a46c Initial revision
claus
parents:
diff changeset
  3667
    ^ true
48194c26a46c Initial revision
claus
parents:
diff changeset
  3668
!
48194c26a46c Initial revision
claus
parents:
diff changeset
  3669
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3670
dispatchPendingEvents
404
0db38d8283a4 removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents: 402
diff changeset
  3671
    "central event handling method for modal operation.
0db38d8283a4 removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents: 402
diff changeset
  3672
     (i.e. this is now only used in the modal debugger)
0db38d8283a4 removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents: 402
diff changeset
  3673
     This code is somewhat special, since X has a concept of graphic
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3674
     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
  3675
     we only handle exposes until the graphicsExpose arrives.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3676
     Other systems may not need such a kludge"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3677
320
b7b8dc88fe9f interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
  3678
    "interested in exposes only ?"
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3679
    dispatchingExpose notNil ifTrue:[
404
0db38d8283a4 removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents: 402
diff changeset
  3680
	[self exposeEventPendingFor:dispatchingExpose withSync:false] whileTrue:[
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3681
	    self dispatchExposeEventFor:dispatchingExpose
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3682
	].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3683
	^ self
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
    "no, general dispatch"
404
0db38d8283a4 removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents: 402
diff changeset
  3687
    [self eventPendingWithSync:false] whileTrue:[
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3688
	self dispatchEventFor:nil withMask:nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3689
    ]
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3690
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3691
81
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
  3692
disposeEventsWithMask:aMask for:aWindowIdOrNil
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
  3693
    "dispose (throw away) specific events. If aWindowId is nil,
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
  3694
     events matching the mask are thrown away regardless of which
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
  3695
     view they are for. Otherwise, only matching events for that 
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
  3696
     view are flushed."
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  3697
48194c26a46c Initial revision
claus
parents:
diff changeset
  3698
%{  /* NOCONTEXT */
48194c26a46c Initial revision
claus
parents:
diff changeset
  3699
48194c26a46c Initial revision
claus
parents:
diff changeset
  3700
    Display *dpy = myDpy;
48194c26a46c Initial revision
claus
parents:
diff changeset
  3701
    XEvent ev;
48194c26a46c Initial revision
claus
parents:
diff changeset
  3702
    Window win;
48194c26a46c Initial revision
claus
parents:
diff changeset
  3703
97
dd6116883ac0 *** empty log message ***
claus
parents: 96
diff changeset
  3704
    if (__isSmallInteger(aMask)) {
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  3705
	if (__isExternalAddress(aWindowIdOrNil)) {
81
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
  3706
	    win = _WindowVal(aWindowIdOrNil);
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  3707
	    while (XCheckWindowEvent(dpy, win, __intVal(aMask), &ev)) ;;
81
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
  3708
	} else {
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  3709
	    while (XCheckMaskEvent(dpy, __intVal(aMask), &ev)) ;;
81
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
  3710
	}
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3711
	RETURN ( self );
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  3712
    }
48194c26a46c Initial revision
claus
parents:
diff changeset
  3713
%}
48194c26a46c Initial revision
claus
parents:
diff changeset
  3714
.
48194c26a46c Initial revision
claus
parents:
diff changeset
  3715
    self primitiveFailed
48194c26a46c Initial revision
claus
parents:
diff changeset
  3716
!
48194c26a46c Initial revision
claus
parents:
diff changeset
  3717
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3718
eventMaskFor:anEventSymbol
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3719
    "return the eventMask bit-constant corresponding to an event symbol"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3720
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3721
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3722
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3723
    int m = 0;
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
    if (anEventSymbol == @symbol(keyPress)) m = KeyPressMask;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3726
    else if (anEventSymbol == @symbol(keyRelease)) m = KeyReleaseMask;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3727
    else if (anEventSymbol == @symbol(buttonPress)) m = ButtonPressMask;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3728
    else if (anEventSymbol == @symbol(buttonRelease)) m = ButtonReleaseMask;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3729
    else if (anEventSymbol == @symbol(buttonMotion)) m = ButtonMotionMask;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3730
    else if (anEventSymbol == @symbol(pointerMotion)) m = PointerMotionMask;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3731
    else if (anEventSymbol == @symbol(expose)) m = ExposureMask;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3732
    else if (anEventSymbol == @symbol(focusChange)) m = FocusChangeMask;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3733
    else if (anEventSymbol == @symbol(enter)) m = EnterWindowMask;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3734
    else if (anEventSymbol == @symbol(leave)) m = LeaveWindowMask;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3735
    else if (anEventSymbol == @symbol(keymapState)) m = KeymapStateMask;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3736
    else if (anEventSymbol == @symbol(visibilityChange)) m = VisibilityChangeMask;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3737
    else if (anEventSymbol == @symbol(structureNotify)) m = StructureNotifyMask;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3738
    else if (anEventSymbol == @symbol(resizeRedirect)) m = ResizeRedirectMask;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3739
    else if (anEventSymbol == @symbol(propertyChange)) m = PropertyChangeMask;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3740
    else if (anEventSymbol == @symbol(colormapChange)) m = ColormapChangeMask;
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  3741
    RETURN (__MKSMALLINT(m));
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
12
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3745
eventPending
310
6ed27eebc243 stefans event queue changes
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
  3746
    "return true, if any event is pending. 
6ed27eebc243 stefans event queue changes
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
  3747
     This looks for both the internal queue and the display connection."
12
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3748
404
0db38d8283a4 removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents: 402
diff changeset
  3749
    ConservativeSyncing == true ifTrue:[self sync].
0db38d8283a4 removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents: 402
diff changeset
  3750
12
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3751
    dispatchingExpose notNil ifTrue:[
404
0db38d8283a4 removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents: 402
diff changeset
  3752
	^ self exposeEventPendingFor:dispatchingExpose withSync:false
12
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3753
    ].
404
0db38d8283a4 removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents: 402
diff changeset
  3754
    ^ self eventPendingWithSync:false
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  3755
!
48194c26a46c Initial revision
claus
parents:
diff changeset
  3756
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3757
eventPending:anEventSymbol for:aWindowIdOrNil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3758
    "return true, if a specific event is pending"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3759
404
0db38d8283a4 removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents: 402
diff changeset
  3760
    ^ self eventsPending:(self eventMaskFor:anEventSymbol) for:aWindowIdOrNil withSync:false
0db38d8283a4 removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents: 402
diff changeset
  3761
!
0db38d8283a4 removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents: 402
diff changeset
  3762
0db38d8283a4 removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents: 402
diff changeset
  3763
eventPendingWithSync:doSync
7
9b4a00211ca5 last version before dispatch change
claus
parents: 6
diff changeset
  3764
    "return true, if any event is pending. 
404
0db38d8283a4 removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents: 402
diff changeset
  3765
     If doSync is true, do a sync output buffer (i.e. send all to the display and wait until its processed)
310
6ed27eebc243 stefans event queue changes
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
  3766
     before checking."
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  3767
12
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3768
%{  /* UNLIMITEDSTACK */
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  3769
48194c26a46c Initial revision
claus
parents:
diff changeset
  3770
    Display *dpy = myDpy;
48194c26a46c Initial revision
claus
parents:
diff changeset
  3771
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3772
    if (ISCONNECTED) {
404
0db38d8283a4 removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents: 402
diff changeset
  3773
	if (doSync == true) {
0db38d8283a4 removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents: 402
diff changeset
  3774
	    XSync(dpy, 0);      /* make certain everything is flushed */
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3775
	}
404
0db38d8283a4 removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents: 402
diff changeset
  3776
	if (XPending(dpy)) {
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3777
	    RETURN (true);
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3778
	}
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3779
    }
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3780
    RETURN ( false );
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  3781
%}
48194c26a46c Initial revision
claus
parents:
diff changeset
  3782
!
48194c26a46c Initial revision
claus
parents:
diff changeset
  3783
341
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3784
eventQueued
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3785
    "return true, if any event is queued"
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3786
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3787
    dispatchingExpose notNil ifTrue:[
404
0db38d8283a4 removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents: 402
diff changeset
  3788
	^ self exposeEventPendingFor:dispatchingExpose withSync:false
341
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3789
    ].
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3790
    ^ self eventQueuedAlready
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3791
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3792
    "Created: 12.12.1995 / 21:43:00 / stefan"
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3793
!
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3794
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3795
eventQueuedAlready
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3796
    "return true, if any event is queued internally.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3797
     (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
  3798
      nextEvent calls AND whenever drawing is done and events are pending on
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3799
      the display connection)."
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3800
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3801
%{  /* UNLIMITEDSTACK */
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3802
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3803
    if (ISCONNECTED) {
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3804
	if (XEventsQueued(myDpy, QueuedAlready)) {
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3805
	    RETURN (true);
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3806
	}
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3807
    }
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3808
    RETURN ( false );
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3809
%}
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3810
!
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  3811
404
0db38d8283a4 removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents: 402
diff changeset
  3812
eventsPending:anEventMask for:aWindowIdOrNil withSync:doSync
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3813
    "return true, if any of the masked events is pending"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3814
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3815
%{  /* UNLIMITEDSTACK */
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
    Display *dpy = myDpy;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3818
    XEvent ev;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3819
    Window win;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3820
    int thereIsOne;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3821
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3822
    if (ISCONNECTED && __isSmallInteger(anEventMask)) {
404
0db38d8283a4 removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents: 402
diff changeset
  3823
	if (doSync == true) {
0db38d8283a4 removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents: 402
diff changeset
  3824
	    XSync(dpy, 0);      /* make certain everything is flushed */
0db38d8283a4 removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents: 402
diff changeset
  3825
	}
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3826
	if (__isExternalAddress(aWindowIdOrNil)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3827
	    win = _WindowVal(aWindowIdOrNil);
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  3828
	    thereIsOne = XCheckWindowEvent(dpy, win, __intVal(anEventMask), &ev);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3829
	} else {
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  3830
	    thereIsOne = XCheckMaskEvent(dpy, __intVal(anEventMask), &ev);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3831
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3832
	if (thereIsOne) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3833
	    XPutBackEvent(dpy, &ev);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3834
	    RETURN ( true );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3835
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3836
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3837
    RETURN ( false );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3838
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3839
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3840
404
0db38d8283a4 removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents: 402
diff changeset
  3841
exposeEventPendingFor:aWindowIdOrNil withSync:doSync
310
6ed27eebc243 stefans event queue changes
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
  3842
    "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
  3843
     or any view (if the arg is nil).
6ed27eebc243 stefans event queue changes
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
  3844
     This is an X specific, only required after a scroll operation."
7
9b4a00211ca5 last version before dispatch change
claus
parents: 6
diff changeset
  3845
12
9f0995fac1fa *** empty log message ***
claus
parents: 7
diff changeset
  3846
%{  /* UNLIMITEDSTACK */
7
9b4a00211ca5 last version before dispatch change
claus
parents: 6
diff changeset
  3847
9b4a00211ca5 last version before dispatch change
claus
parents: 6
diff changeset
  3848
    Display *dpy = myDpy;
9b4a00211ca5 last version before dispatch change
claus
parents: 6
diff changeset
  3849
    XEvent ev;
9b4a00211ca5 last version before dispatch change
claus
parents: 6
diff changeset
  3850
    Window win;
81
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
  3851
    int thereIsOne;
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
  3852
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3853
    if (ISCONNECTED) {
404
0db38d8283a4 removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents: 402
diff changeset
  3854
	if (doSync == true) {
0db38d8283a4 removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents: 402
diff changeset
  3855
	    XSync(dpy, 0);      /* make certain everything is flushed */
0db38d8283a4 removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents: 402
diff changeset
  3856
	}
206
4284b80bebdf changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  3857
	if (__isExternalAddress(aWindowIdOrNil)) {
150
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3858
	    win = _WindowVal(aWindowIdOrNil);
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3859
	    thereIsOne = XCheckWindowEvent(dpy, win, ExposureMask, &ev);
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3860
	} else {
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3861
	    thereIsOne = XCheckMaskEvent(dpy, ExposureMask, &ev);
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3862
	}
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3863
	if (thereIsOne) {
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3864
	    XPutBackEvent(dpy, &ev);
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3865
	    RETURN ( true );
5d0b9d669832 *** empty log message ***
claus
parents: 146
diff changeset
  3866
	}
81
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
  3867
    }
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
  3868
    RETURN ( false );
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
  3869
%}
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
  3870
!
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
  3871
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3872
getEventFor:aViewIdOrNil withMask:eventMask
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3873
    "read next event - put into local eventBuffer. 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3874
     If aViewIdOrNil is nil, events for any view are fetched; 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3875
     otherwise only events for that specific view will be fetched.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3876
     Returns true, if there was an event, false otherwise.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3877
     This method may block - so you better check for pending events
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3878
     before calling for it.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3879
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3880
     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
  3881
     handle method to allow unlimitedstack here.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3882
     (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
  3883
     dispatchLastEvent, since it dispatches out into ST-methods.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3884
     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
  3885
     display connections.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3886
    "
81
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
  3887
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
  3888
%{  /* UNLIMITEDSTACK */
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
  3889
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
  3890
    Display *dpy = myDpy;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3891
    Window win, wWanted;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3892
    int evMask;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3893
    OBJ eB;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3894
    XEvent *ev;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3895
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3896
    if (! ISCONNECTED) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3897
	RETURN (false);
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
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  3900
    eB = __INST(eventBuffer);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3901
    if (__isByteArray(eB)) {
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  3902
	ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3903
    } else {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3904
	printf("DISPLAY: no eventBuffer\n");
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3905
	RETURN (false);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3906
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3907
    ev->type = 0;
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
    if (__isSmallInteger(eventMask)) {
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  3910
	evMask = __intVal(eventMask);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3911
    } else {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3912
	evMask = ~0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3913
    }
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
    if (__isExternalAddress(aViewIdOrNil)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3916
	wWanted = _WindowVal(aViewIdOrNil);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3917
	if (XCheckWindowEvent(dpy, wWanted, evMask, ev)) {
70
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3918
	    RETURN ( true );
3cb3992ead10 *** empty log message ***
claus
parents: 66
diff changeset
  3919
	}
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3920
    } else {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3921
	if (evMask == ~0) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3922
	    XNextEvent(dpy, ev);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3923
	    RETURN (true);
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
	if (XCheckMaskEvent(dpy, evMask, ev)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3926
	   RETURN (true);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3927
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3928
    }
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
    ^ false
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3931
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3932
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3933
handleAllEvents
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3934
    "from now on, handle any kind of event"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3935
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3936
    dispatchingExpose := nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3937
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3938
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3939
handleExposeOnlyFor:aView
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3940
    "from now on, handle expose events only"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3941
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3942
    dispatchingExpose := aView id
288
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  3943
!
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  3944
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  3945
mappingChanged:what event:eB
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  3946
    "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
  3947
     Tell xlib about the fact."
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  3948
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  3949
    (what == #mappingKeyboard or:[what == #mappingModifier]) ifTrue:[
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  3950
	self refreshKeyboardMapping:eB.
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  3951
	"Maybe some of our modifiers have been changed"
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  3952
	self initializeModifierMappings.
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  3953
    ].
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  3954
5d49b00f2bad changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  3955
    "Created: 1.12.1995 / 16:28:23 / stefan"
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
setEventMask:aMask in:aWindowId
320
b7b8dc88fe9f interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
  3959
    "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
  3960
     is the bitwise or of the eventMask bits (see 'eventMaskFor:')"
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
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3963
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3964
    int mask;
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
    if (__isExternalAddress(aWindowId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3967
     && __isSmallInteger(aMask)) {
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  3968
	mask = __intVal(aMask);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3969
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3970
#ifdef OLD
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3971
	/* these may not be disabled */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3972
	mask |= ExposureMask | StructureNotifyMask |
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3973
		KeyPressMask | KeyReleaseMask |
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3974
		EnterWindowMask | LeaveWindowMask |
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3975
		ButtonPressMask | ButtonMotionMask | ButtonReleaseMask;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3976
#endif
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3977
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3978
	XSelectInput(myDpy, _WindowVal(aWindowId), mask);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3979
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3980
    }
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
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3983
    self primitiveFailed
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
startDispatch
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3987
    "redefined to clear dispatchingExpose, which is a special X feature"
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
    dispatching ifTrue:[^ self].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3990
    dispatchingExpose := nil.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3991
    super startDispatch
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  3992
! !
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  3993
440
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  3994
!XWorkstation methodsFor:'event sending'!
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  3995
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  3996
sendKeyOrButtonEvent:typeSymbol x:xPos y:yPos keyOrButton:keySymCodeOrButtonNr state:stateMask toViewId:targetId
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  3997
    "send a keyPress/Release or buttonPress/Release event to some (possibly alien) view.
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  3998
     TypeSymbol must be one of: #keyPress, #keyRelease, #buttonPress , #buttonRelease.
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  3999
     For buttonEvents, the keySymCodeOrButtonNr must be the buttons number (1, 2 ...);
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4000
     for key events, it can be either a symbol (as listen in X's keySyms)
480
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4001
     or a numeric keysym code. If state is nil, the modifier bits (shift & control)
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4002
     are computed from the keyboardMap - if non-nil, these are passed as modifierbits.
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4003
     The non-nil case is the lowlevel entry, where state must include any shift/ctrl information
440
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4004
     (not very user friendly)"
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4005
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4006
%{  /* NOCONTEXT */
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4007
    Display *dpy = myDpy;
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4008
    int type;
480
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4009
    int state;
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4010
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4011
    if (__isSmallInteger(stateMask)) {
481
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4012
	state = __intVal(stateMask);
480
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4013
    } else {
481
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4014
	state = 0;
480
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4015
    }
440
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4016
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4017
    if (ISCONNECTED
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4018
     && __isSmallInteger(xPos) && __isSmallInteger(yPos)
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4019
     && (__isSmallInteger(keySymCodeOrButtonNr) || __isSymbol(keySymCodeOrButtonNr) || __isString(keySymCodeOrButtonNr))
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4020
     && (__isExternalAddress(targetId) || __isInteger(targetId))) {
481
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4021
	XEvent ev;
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4022
	Window target;
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4023
	Status result;
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4024
	KeySym keySym, *syms;
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  4025
	int screen = __intVal(__INST(screen));
481
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4026
	char s[2];
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4027
	int nSyms;
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4028
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4029
	if ((typeSymbol == @symbol(keyPress))
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4030
	 || (typeSymbol == @symbol(keyRelease))) {
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4031
	    if (__isSymbol(keySymCodeOrButtonNr) || __isString(keySymCodeOrButtonNr)) {
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4032
		keySym = XStringToKeysym(__stringVal(keySymCodeOrButtonNr));
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4033
	    } else {
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4034
		if (__isCharacter(keySymCodeOrButtonNr)) {
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4035
		    s[0] = __intVal(__characterVal(keySymCodeOrButtonNr));
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4036
		    s[1] = '\0';
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4037
		    keySym = XStringToKeysym(s);
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4038
		} else {
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4039
		    keySym = (KeySym) __intVal(keySymCodeOrButtonNr);
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4040
		}
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4041
	    }
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4042
	    ev.xkey.keycode = XKeysymToKeycode(dpy, keySym);
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4043
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4044
	    if (stateMask == nil) {
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4045
		/*
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4046
		 * get the modifier from the keySym
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4047
		 */
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4048
		nSyms = 0;
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4049
		syms = XGetKeyboardMapping(dpy, ev.xkey.keycode, 1, &nSyms);
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4050
		if (syms) {
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4051
		    int i;
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4052
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4053
		    for (i=0; i<nSyms; i++) {
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4054
			if (syms[i] == keySym) {
480
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4055
#ifdef MODIFIERDEBUG
481
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4056
			    printf("modifier-index is %d\n", i);
480
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4057
#endif
481
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4058
			    if (i) state = (1 << (i-1));
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4059
			    break;
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4060
			}
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4061
		    }
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4062
		    XFree(syms);
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4063
		}
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4064
	    }
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4065
	} else {
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4066
	    if ((typeSymbol == @symbol(buttonPress))
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4067
	     || (typeSymbol == @symbol(buttonRelease))) {
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4068
		if (__isSmallInteger(keySymCodeOrButtonNr)) {
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4069
		    ev.xbutton.button = __intVal(keySymCodeOrButtonNr);
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4070
		} else {
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4071
		    ev.xbutton.button = 1;
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4072
		}
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4073
	    } else {
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4074
		DPRINTF(("invalid sendEvent typeSymbol\n"));
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4075
		RETURN (false);
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4076
	    }
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4077
	}
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4078
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4079
	if (typeSymbol == @symbol(keyPress))
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4080
	    ev.xany.type = KeyPress;
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4081
	else if (typeSymbol == @symbol(keyRelease))
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4082
	    ev.xany.type = KeyRelease;
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4083
	else if (typeSymbol == @symbol(buttonPress))
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4084
	    ev.xany.type = ButtonPress;
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4085
	else if (typeSymbol == @symbol(buttonRelease))
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4086
	    ev.xany.type = ButtonRelease;
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4087
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4088
	if (__isExternalAddress(targetId)) {
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4089
	    target = _WindowVal(targetId);
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4090
	} else {
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4091
	    target = (Window) __longIntVal(targetId);
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4092
	}
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4093
	ev.xkey.window = target;
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4094
	ev.xkey.same_screen = 1;
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4095
	ev.xkey.subwindow = 0;
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4096
	ev.xkey.root = RootWindow(myDpy, screen);
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4097
	ev.xkey.x = __intVal(xPos);
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4098
	ev.xkey.y = __intVal(yPos);
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4099
	ev.xkey.state = state;
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4100
	ev.xkey.time = CurrentTime;
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4101
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4102
	result = XSendEvent(dpy, target, False, 0 , &ev);
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4103
	if ((result == BadValue) || (result == BadWindow)) {
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4104
	    DPRINTF(("bad status\n"));
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4105
	    RETURN ( false )
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4106
	}
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  4107
	RETURN (true)
440
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4108
    }
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4109
%}.
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4110
    self primitiveFailed.
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4111
    ^ false
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4112
!
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4113
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4114
simulateKeyboardInput:aCharacterOrString inViewId:viewId
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4115
    "send input to some other view, by simulating keyPress/keyRelease
480
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4116
     events. 
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4117
     Only a few control characters are supported.
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4118
     Notice: not all alien views allow this kind of synthetic input;
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4119
	     some simply ignore it."
480
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4120
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4121
    |control code state|
440
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4122
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4123
    aCharacterOrString isString ifTrue:[
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4124
	aCharacterOrString do:[:char |
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4125
	    self simulateKeyboardInput:char inViewId:viewId
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4126
	].
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4127
	^ self
440
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4128
    ].
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4129
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4130
    control := false.
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4131
    code := aCharacterOrString asciiValue.
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4132
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4133
    (aCharacterOrString == Character cr) ifTrue:[
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4134
	code := #Return
440
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4135
    ] ifFalse:[
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4136
	(aCharacterOrString == Character tab) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4137
	    code := #Tab 
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4138
	] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4139
	    (aCharacterOrString == Character esc) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4140
		code := #Escape 
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4141
	    ]
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4142
	]
440
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4143
    ].
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4144
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4145
    control ifTrue:[
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4146
	state := self controlMask
830
76fd3d86dd15 fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents: 823
diff changeset
  4147
    ].
76fd3d86dd15 fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents: 823
diff changeset
  4148
76fd3d86dd15 fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents: 823
diff changeset
  4149
76fd3d86dd15 fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents: 823
diff changeset
  4150
    "/ the stuff below should not be needed 
76fd3d86dd15 fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents: 823
diff changeset
  4151
    "/ (sendKeyOrButtonevent should be able to figure out things itself)
76fd3d86dd15 fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents: 823
diff changeset
  4152
    "/ however, on some linux systems it seems to not work correctly.
76fd3d86dd15 fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents: 823
diff changeset
  4153
    "/ Hopefully, this is correct ...
76fd3d86dd15 fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents: 823
diff changeset
  4154
76fd3d86dd15 fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents: 823
diff changeset
  4155
    code isNumber ifTrue:[
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4156
	code >= $A asciiValue ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4157
	    code <= $Z asciiValue ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4158
		state := self shiftMask
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4159
	    ]
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4160
	]
440
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4161
    ].
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4162
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4163
    self sendKeyOrButtonEvent:#keyPress x:0 y:0 keyOrButton:code state:state toViewId:viewId.
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4164
    self sendKeyOrButtonEvent:#keyRelease x:0 y:0 keyOrButton:code state:state toViewId:viewId
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4165
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4166
    "
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4167
      sending input to some (possibly alien) view:
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4168
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4169
      |point id|
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4170
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4171
      point :=  Display pointFromUser.
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4172
      id := Display viewIdFromPoint:point.
480
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4173
      Display simulateKeyboardInput:'Hello_world' inViewId:id
440
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4174
    "
480
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4175
830
76fd3d86dd15 fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents: 823
diff changeset
  4176
    "Modified: 11.6.1996 / 10:59:42 / cg"
440
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4177
! !
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4178
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4179
!XWorkstation methodsFor:'font stuff'!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4180
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4181
createFontFor:aFontName
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4182
    "a basic method for X-font allocation; this method allows
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4183
     any font to be aquired (even those not conforming to
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4184
     standard naming conventions, such as cursor, fixed or k14)"
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
%{  /* UNLIMITEDSTACK */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4187
    /* UNLIMITEDSTACK STACK:100000 xxNOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4188
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4189
    XFontStruct *newFont;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4190
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4191
    if (ISCONNECTED) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4192
	if (__isString(aFontName) || __isSymbol(aFontName)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4193
	    BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4194
	    newFont = XLoadQueryFont(myDpy, (char *)__stringVal(aFontName));
923
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  4195
#ifdef COUNT_RESOURCES
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  4196
	    if (newFont)
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  4197
		__cnt_font++;
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  4198
#endif
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4199
	    END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4200
	    RETURN ( newFont ? __MKOBJ(newFont) : nil );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4201
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4202
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4203
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4204
    ^ nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4205
!
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
decomposeXFontName:aString into:aBlock
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4208
    "extract family, face, style and size from an
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4209
     X-font name 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4210
     (-brand-family-face-style-moreStyle--height-size-res-res-?-??-coding); 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4211
     evaluate aBlock with these"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4212
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4213
    |origin family face style moreStyle skip fheight size
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4214
     resX resY x1 x2 coding start end |
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4215
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4216
    aString isNil ifTrue:[^ false].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4217
    (aString startsWith:'-') ifFalse:[
963
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4218
	"
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4219
	 take care for ill-named fonts (i.e. pre Rel4 fonts)
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4220
	"
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4221
	('*-*-[0-9]*' match:aString) ifTrue:[
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4222
	    end := aString indexOf:$- startingAt:1.
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4223
	    family := aString copyFrom:1 to:(end - 1).
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4224
	    start := end + 1.
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4225
	    end := aString indexOf:$- startingAt:start.
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4226
	    style := aString copyFrom:start to:(end - 1).
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4227
	    start := end + 1.
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4228
	    size := aString copyFrom:start.
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4229
	    size := (Number readFromString:size onError:[^false]).
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4230
	    aBlock value:family value:nil value:style value:size value:nil.
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4231
	    ^ true.
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4232
	].
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4233
	('*-[0-9]*' match:aString) ifTrue:[
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4234
	    "
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4235
	     something like lucidasans-24
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4236
	    "
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4237
	    end := aString indexOf:$- startingAt:1.
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4238
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4239
	    family := aString copyFrom:1 to:(end - 1).
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4240
	    start := end + 1.
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4241
	    size := aString copyFrom:start.
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4242
	    size := (Number readFromString:size onError:[^false]).
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4243
	    aBlock value:family value:nil value:nil value:size value:nil.
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4244
	    ^ true.
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4245
	].
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4246
	aBlock value:aString value:nil value:nil value:nil value:nil.
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4247
	^ true.
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4248
    ].
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
    end := aString indexOf:$- startingAt:2.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4251
    (end == 0) ifTrue:[^ false].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4252
    origin := aString copyFrom:2 to:(end - 1).
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
    start := end + 1.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4255
    end := aString indexOf:$- startingAt:start.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4256
    (end == 0) ifTrue:[^ false].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4257
    family := aString copyFrom:start to:(end - 1).
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
    start := end + 1.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4260
    end := aString indexOf:$- startingAt:start.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4261
    (end == 0) ifTrue:[^ false].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4262
    face := aString copyFrom:start to:(end - 1).
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4263
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4264
    start := end + 1.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4265
    end := aString indexOf:$- startingAt:start.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4266
    (end == 0) ifTrue:[^ false].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4267
    style := aString copyFrom:start to:(end - 1).
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4268
    (style = 'o') ifTrue:[
963
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4269
	style := 'oblique'
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4270
    ] ifFalse:[
963
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4271
	(style = 'i') ifTrue:[
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4272
	    style := 'italic'
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4273
	] ifFalse:[
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4274
	    (style = 'r') ifTrue:[
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4275
		style := 'roman'
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4276
	    ]
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4277
	]
295
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
    start := end + 1.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4281
    end := aString indexOf:$- startingAt:start.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4282
    (end == 0) ifTrue:[^ false].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4283
    moreStyle := aString copyFrom:start to:(end - 1).
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
    start := end + 1.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4286
    end := aString indexOf:$- startingAt:start.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4287
    (end == 0) ifTrue:[^ false].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4288
    skip := aString copyFrom:start to:(end - 1).
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4289
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4290
    start := end + 1.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4291
    end := aString indexOf:$- startingAt:start.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4292
    (end == 0) ifTrue:[^ false].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4293
    fheight := aString copyFrom:start to:(end - 1).
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4294
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4295
    start := end + 1.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4296
    end := aString indexOf:$- startingAt:start.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4297
    (end == 0) ifTrue:[^ false].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4298
    size := aString copyFrom:start to:(end - 1).
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4299
    size := (Number readFromString:size) / 10.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4300
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4301
    start := end + 1.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4302
    end := aString indexOf:$- startingAt:start.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4303
    (end == 0) ifTrue:[^ false].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4304
    resX := aString copyFrom:start to:(end - 1).
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4305
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4306
    start := end + 1.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4307
    end := aString indexOf:$- startingAt:start.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4308
    (end == 0) ifTrue:[^ false].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4309
    resY := aString copyFrom:start to:(end - 1).
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4310
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4311
    start := end + 1.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4312
    end := aString indexOf:$- startingAt:start.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4313
    (end == 0) ifTrue:[^ false].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4314
    x1 := aString copyFrom:start to:(end - 1).
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
    start := end + 1.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4317
    end := aString indexOf:$- startingAt:start.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4318
    (end == 0) ifTrue:[^ false].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4319
    x2 := aString copyFrom:start to:(end - 1).
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4320
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4321
    start := end + 1.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4322
    end := aString indexOf:$- startingAt:start.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4323
    (end == 0) ifTrue:[^ false].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4324
    coding := aString copyFrom:start to:(end - 1).
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4325
914
6cf4cc647095 Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents: 911
diff changeset
  4326
    (moreStyle ~= 'normal' and:[moreStyle ~= '']) ifTrue:[
963
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4327
	style := style, '-', moreStyle.
914
6cf4cc647095 Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents: 911
diff changeset
  4328
    ].
6cf4cc647095 Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents: 911
diff changeset
  4329
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4330
    aBlock value:family value:face value:style value:size value:coding.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4331
    ^ true
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4332
914
6cf4cc647095 Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents: 911
diff changeset
  4333
    "Modified: 4.7.1996 / 11:12:25 / stefan"
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4334
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4335
440
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4336
encodingOf:aFontId
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4337
    "the fonts encoding - if the font does not provide that info,
457
b40bf5d8727c ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents: 449
diff changeset
  4338
     return nil (and assume #ascii, which is a subset of #iso8859)."
440
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4339
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4340
    |enc fullName fontName registry encoding charSetCollections|
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4341
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4342
%{ 
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4343
    XFontStruct *f;
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4344
    XFontProp *prop;
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4345
    int n;
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4346
    char *cp;
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4347
    Atom fontAtom, registryAtom, encodingAtom, charSetCollAtom;
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4348
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4349
    registryAtom = XInternAtom(myDpy, "CHARSET_REGISTRY", True);
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4350
    encodingAtom = XInternAtom(myDpy, "CHARSET_ENCODING", True);
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4351
    charSetCollAtom = XInternAtom(myDpy, "CHARSET_COLLECTIONS", True);
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4352
    fontAtom = XInternAtom(myDpy, "FONT", True);
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4353
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4354
    if (ISCONNECTED) {
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4355
	if (__isExternalAddress(aFontId)) {
440
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4356
        
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4357
	    f = _FontVal(aFontId);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4358
	    if (f) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4359
		n = f->n_properties;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4360
		prop = f->properties;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4361
		if (prop) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4362
		    while (n--) {
1045
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4363
#ifdef SUPERDEBUG
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4364
			cp = XGetAtomName(myDpy, prop->name);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4365
			printf("%s (%d) -> %d\n", cp, prop->name, prop->card32);
1049
59cc92776676 oops - free XGetAtomName string after use
Claus Gittinger <cg@exept.de>
parents: 1047
diff changeset
  4366
			XFree(cp);
440
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4367
#endif
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4368
			if (prop->name == XA_FULL_NAME) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4369
			    cp = XGetAtomName(myDpy, prop->card32);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4370
			    if (cp) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4371
				fullName = __MKSTRING(cp COMMA_CON);
440
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4372
#ifdef SUPERDEBUG
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4373
				printf("   FULL_NAME -> %s\n", cp);
440
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4374
#endif
1049
59cc92776676 oops - free XGetAtomName string after use
Claus Gittinger <cg@exept.de>
parents: 1047
diff changeset
  4375
				XFree(cp);
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4376
			    }
1045
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4377
			} else if (prop->name == fontAtom) {
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4378
			    cp = XGetAtomName(myDpy, prop->card32);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4379
			    if (cp) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4380
				fontName = __MKSTRING(cp COMMA_CON);
440
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4381
#ifdef SUPERDEBUG
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4382
				printf("   FONT -> %s\n", cp);
440
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4383
#endif
1049
59cc92776676 oops - free XGetAtomName string after use
Claus Gittinger <cg@exept.de>
parents: 1047
diff changeset
  4384
				XFree(cp);
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4385
			    }
1045
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4386
			} else if (prop->name == encodingAtom) {
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4387
			    cp = XGetAtomName(myDpy, prop->card32);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4388
			    if (cp) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4389
				encoding = __MKSTRING(cp COMMA_CON);
440
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4390
#ifdef SUPERDEBUG
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4391
				printf("   ENCODING -> %s\n", cp);
440
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4392
#endif
1049
59cc92776676 oops - free XGetAtomName string after use
Claus Gittinger <cg@exept.de>
parents: 1047
diff changeset
  4393
				XFree(cp);
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4394
			    }
1045
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4395
			} else if (prop->name == registryAtom) {
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4396
			    cp = XGetAtomName(myDpy, prop->card32);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4397
			    if (cp) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4398
				registry = __MKSTRING(cp COMMA_CON);
440
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4399
#ifdef SUPERDEBUG
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4400
				printf("   REGISTRY -> %s\n", cp);
440
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4401
#endif
1049
59cc92776676 oops - free XGetAtomName string after use
Claus Gittinger <cg@exept.de>
parents: 1047
diff changeset
  4402
				XFree(cp);
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4403
			    }
1045
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4404
			} else if (prop->name == charSetCollAtom) {
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4405
			    cp = XGetAtomName(myDpy, prop->card32);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4406
			    if (cp) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4407
				charSetCollections = __MKSTRING(cp COMMA_CON);
440
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4408
#ifdef SUPERDEBUG
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4409
				printf("   CHARSET_COLLECTIONS -> %s\n", cp);
440
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4410
#endif
1049
59cc92776676 oops - free XGetAtomName string after use
Claus Gittinger <cg@exept.de>
parents: 1047
diff changeset
  4411
				XFree(cp);
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4412
			    }
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4413
			}
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4414
			prop++;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4415
		    }
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4416
		}
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4417
	    }
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4418
	}
440
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4419
    }
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4420
%}.
567
7b735ef0974b separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents: 558
diff changeset
  4421
    ^ self
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4422
	extractEncodingFromRegistry:registry 
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4423
	encoding:encoding 
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4424
	charSetCollections:charSetCollections
567
7b735ef0974b separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents: 558
diff changeset
  4425
!
7b735ef0974b separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents: 558
diff changeset
  4426
7b735ef0974b separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents: 558
diff changeset
  4427
extractEncodingFromRegistry:registry encoding:encoding charSetCollections:charSetCollections
7b735ef0974b separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents: 558
diff changeset
  4428
    "this is pure magic ..."
7b735ef0974b separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents: 558
diff changeset
  4429
7b735ef0974b separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents: 558
diff changeset
  4430
    |enc charSets|
7b735ef0974b separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents: 558
diff changeset
  4431
440
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4432
    (registry notNil and:[registry notEmpty]) ifTrue:[
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4433
	enc := registry asLowercase asSymbol.
440
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4434
    ] ifFalse:[
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4435
	(encoding notNil and:[encoding notEmpty]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4436
	    enc := encoding asLowercase asSymbol
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4437
	] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4438
	    charSets := charSetCollections.    
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4439
	    (charSets notNil and:[charSets notEmpty]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4440
		charSets := charSets asUppercase asCollectionOfWords.
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4441
		(charSets includes:'ISO8859-1') ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4442
		    enc := #iso8859
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4443
		] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4444
		    (charSets includes:'ISO8859') ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4445
			enc := #iso8859
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4446
		    ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4447
			(charSets includes:'ASCII') ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4448
			    enc := #ascii
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4449
			] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4450
			    (charSets includes:'ADOBE-STANDARD') ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4451
				enc := #iso8859
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4452
			    ]
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4453
			]
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4454
		    ]
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4455
		]
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4456
	    ] 
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4457
	]
440
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4458
    ].
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4459
    ^  enc
567
7b735ef0974b separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents: 558
diff changeset
  4460
7b735ef0974b separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents: 558
diff changeset
  4461
    "Created: 17.4.1996 / 14:57:06 / cg"
568
ded98de3475f return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
  4462
    "Modified: 17.4.1996 / 17:22:35 / cg"
440
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4463
!
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4464
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4465
flushListOfAvailableFonts
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4466
    "flush the cached list of all available fonts on this display.
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4467
     Required if new fonts have been added on the display server."
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4468
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4469
    listOfXFonts := nil
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4470
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4471
    "
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4472
     Display flushListOfAvailableFonts.
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4473
     Display listOfAvailableFonts
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4474
    "
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4475
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4476
    "Modified: 27.9.1995 / 10:54:47 / stefan"
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4477
    "Created: 20.2.1996 / 22:55:52 / cg"
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4478
!
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4479
991
b3a0b903bd7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  4480
fontMetricsOf:fontId into:aBlock
b3a0b903bd7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  4481
    "evaluate aBlock, passing a fonts metrics as arguments"
b3a0b903bd7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  4482
b3a0b903bd7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  4483
    |encoding avgAscent avgDescent
1045
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4484
     maxAscent maxDescent minWidth maxWidth avgWidth
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4485
     res resX resY|
991
b3a0b903bd7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  4486
994
7e720b29c838 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 991
diff changeset
  4487
%{
991
b3a0b903bd7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  4488
    XFontStruct *f;
b3a0b903bd7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  4489
    int len;
b3a0b903bd7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  4490
b3a0b903bd7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  4491
    if (ISCONNECTED) {
994
7e720b29c838 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 991
diff changeset
  4492
	if (__isExternalAddress(fontId)) {
7e720b29c838 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 991
diff changeset
  4493
	    f = _FontVal(fontId);
995
2f2c0b2bff1a check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents: 994
diff changeset
  4494
	    if (f) {
1045
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4495
#ifdef NOTDEF
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4496
    		char *cp;
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4497
    	        XFontProp *prop;
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4498
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4499
                n = f->n_properties;
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4500
                prop = f->properties;
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4501
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4502
		if (prop) {
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4503
		    while (n--) {
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4504
			if (prop->name == RESOLUTION_X) {
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4505
			    resX = __MKSMALLINT(prop->card32);
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4506
			} else if (prop->name == RESOLUTION_Y) {
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4507
			    resY = __MKSMALLINT(prop->card32);
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4508
			} else if (prop->name == RESOLUTION) {
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4509
			    res = __MKSMALLINT(prop->card32);
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4510
			}
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4511
			prop++;
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4512
		    }
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4513
		}
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4514
#endif
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4515
995
2f2c0b2bff1a check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents: 994
diff changeset
  4516
	        avgAscent = __MKSMALLINT(f->ascent);
2f2c0b2bff1a check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents: 994
diff changeset
  4517
	        avgDescent = __MKSMALLINT(f->descent);
2f2c0b2bff1a check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents: 994
diff changeset
  4518
	        maxAscent = __MKSMALLINT(f->max_bounds.ascent);
2f2c0b2bff1a check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents: 994
diff changeset
  4519
	        maxDescent = __MKSMALLINT(f->max_bounds.descent);
2f2c0b2bff1a check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents: 994
diff changeset
  4520
	        minWidth = __MKSMALLINT(f->min_bounds.width);
2f2c0b2bff1a check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents: 994
diff changeset
  4521
	        maxWidth = __MKSMALLINT(f->max_bounds.width);
2f2c0b2bff1a check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents: 994
diff changeset
  4522
	        BEGIN_INTERRUPTSBLOCKED
2f2c0b2bff1a check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents: 994
diff changeset
  4523
                len = XTextWidth(f, " ", 1);
2f2c0b2bff1a check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents: 994
diff changeset
  4524
                END_INTERRUPTSBLOCKED
2f2c0b2bff1a check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents: 994
diff changeset
  4525
                avgWidth = __MKSMALLINT( len );
2f2c0b2bff1a check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents: 994
diff changeset
  4526
	    }
991
b3a0b903bd7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  4527
	}
b3a0b903bd7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  4528
    }
b3a0b903bd7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  4529
%}.
b3a0b903bd7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  4530
    encoding := self encodingOf:fontId.
b3a0b903bd7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  4531
    aBlock value:encoding
b3a0b903bd7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  4532
           value:avgAscent
b3a0b903bd7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  4533
           value:avgDescent
b3a0b903bd7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  4534
           value:maxAscent
b3a0b903bd7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  4535
           value:maxDescent
b3a0b903bd7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  4536
           value:minWidth
b3a0b903bd7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  4537
           value:maxWidth
b3a0b903bd7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  4538
           value:avgWidth
b3a0b903bd7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  4539
!
b3a0b903bd7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  4540
1045
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4541
fontResolutionOf:fontId
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4542
    "return the resolution (as dpiX @ dpiY) of the font - this is usually the displays resolution,
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4543
     but due to errors in some XServer installations, some use 75dpi fonts on higher
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4544
     resolution displays and vice/versa."
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4545
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4546
    |res resX resY|
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4547
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4548
%{
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4549
    XFontStruct *f;
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4550
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4551
    if (ISCONNECTED) {
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4552
        if (__isExternalAddress(fontId)) {
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4553
            f = _FontVal(fontId);
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4554
            if (f) {
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4555
                char *cp;
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4556
                XFontProp *prop;
1046
Claus Gittinger <cg@exept.de>
parents: 1045
diff changeset
  4557
                Atom resolutionXAtom, resolutionYAtom;
Claus Gittinger <cg@exept.de>
parents: 1045
diff changeset
  4558
                int n;
1045
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4559
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4560
                n = f->n_properties;
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4561
                prop = f->properties;
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4562
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4563
                if (prop) {
1046
Claus Gittinger <cg@exept.de>
parents: 1045
diff changeset
  4564
                    resolutionXAtom = XInternAtom(myDpy, "RESOLUTION_X", True);
Claus Gittinger <cg@exept.de>
parents: 1045
diff changeset
  4565
                    resolutionYAtom = XInternAtom(myDpy, "RESOLUTION_Y", True);
1045
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4566
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4567
                    while (n--) {
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4568
                        if (prop->name == resolutionXAtom) {
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4569
                            resX = __MKSMALLINT(prop->card32);
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4570
                        } else if (prop->name == resolutionYAtom) {
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4571
                            resY = __MKSMALLINT(prop->card32);
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4572
                        } else if (prop->name == XA_RESOLUTION) {
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4573
                            res = __MKSMALLINT(prop->card32);
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4574
                        }
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4575
                        prop++;
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4576
                    }
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4577
                }
1046
Claus Gittinger <cg@exept.de>
parents: 1045
diff changeset
  4578
            }
Claus Gittinger <cg@exept.de>
parents: 1045
diff changeset
  4579
        }
1045
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4580
    }
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4581
%}.
1046
Claus Gittinger <cg@exept.de>
parents: 1045
diff changeset
  4582
    (resX notNil and:[resY notNil]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1045
diff changeset
  4583
        ^ resX @ resY
1045
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4584
    ].
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4585
    res notNil ifTrue:[
1046
Claus Gittinger <cg@exept.de>
parents: 1045
diff changeset
  4586
        ^ res @ res
1045
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4587
    ].
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4588
    ^ self resolution
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4589
!
b03222053583 added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
  4590
440
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4591
fullNameOf:aFontId
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4592
    "the fonts fullName - this is very device specific and should only be
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4593
     used for user feed-back (for example: in the fontPanel).
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4594
     If the display/font do not provide that info, return nil."
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4595
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4596
    |fullName fontName|
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4597
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4598
%{ 
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4599
    XFontStruct *f;
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4600
    XFontProp *prop;
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4601
    int n;
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4602
    char *cp;
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4603
    Atom fontAtom;
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4604
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4605
    fontAtom = XInternAtom(myDpy, "FONT", True);
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4606
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4607
    if (ISCONNECTED) {
480
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4608
	if (__isExternalAddress(aFontId)) {
440
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4609
        
480
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4610
	    f = _FontVal(aFontId);
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4611
	    if (f) {
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4612
		n = f->n_properties;
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4613
		prop = f->properties;
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4614
		if (prop) {
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4615
		    while (n--) {
1049
59cc92776676 oops - free XGetAtomName string after use
Claus Gittinger <cg@exept.de>
parents: 1047
diff changeset
  4616
#ifdef SUPERDEBUG
480
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4617
			cp = XGetAtomName(myDpy, prop->name);
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4618
			printf("%s (%d) -> %d\n", cp, prop->name, prop->card32);
1049
59cc92776676 oops - free XGetAtomName string after use
Claus Gittinger <cg@exept.de>
parents: 1047
diff changeset
  4619
			XFree(cp);
440
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4620
#endif
480
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4621
			if (prop->name == XA_FULL_NAME) {
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4622
			    cp = XGetAtomName(myDpy, prop->card32);
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4623
			    if (cp) {
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4624
				fullName = __MKSTRING(cp COMMA_CON);
440
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4625
#ifdef SUPERDEBUG
480
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4626
				printf("   FULL_NAME -> %s\n", cp);
440
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4627
#endif
1049
59cc92776676 oops - free XGetAtomName string after use
Claus Gittinger <cg@exept.de>
parents: 1047
diff changeset
  4628
				XFree(cp);
480
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4629
			    }
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4630
			}
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4631
			if (prop->name == fontAtom) {
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4632
			    cp = XGetAtomName(myDpy, prop->card32);
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4633
			    if (cp) {
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4634
				fontName = __MKSTRING(cp COMMA_CON);
440
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4635
#ifdef SUPERDEBUG
480
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4636
				printf("   FONT -> %s\n", cp);
440
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4637
#endif
1049
59cc92776676 oops - free XGetAtomName string after use
Claus Gittinger <cg@exept.de>
parents: 1047
diff changeset
  4638
				XFree(cp);
480
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4639
			    }
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4640
			}
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4641
			prop++;
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4642
		    }
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4643
		}
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4644
	    }
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4645
	}
440
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4646
    }
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4647
%}.
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4648
    (fullName notNil and:[fullName notEmpty]) ifTrue:[
480
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4649
	^ fullName
440
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4650
    ].
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4651
    ^ fontName
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4652
!
e959b8e18453 font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4653
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4654
getAvailableFontsMatching:pattern
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4655
    "return an Array filled with font names matching aPattern"
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
%{  /* UNLIMITEDSTACK */
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
    int nnames = 1500;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4660
    int available = nnames + 1;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4661
    char **fonts;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4662
    OBJ arr, str;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4663
    int i;
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
    if (ISCONNECTED) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4666
	if (__isString(pattern)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4667
	    for (;;) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4668
		fonts = XListFonts(myDpy, __stringVal(pattern), nnames, &available);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4669
		if ((fonts == NULL) || (available < nnames)) break;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4670
		XFreeFontNames(fonts);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4671
		nnames = available * 2;
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
	    if (fonts == NULL) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4674
		RETURN ( nil );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4675
	    }
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
	     * now, that we know the number of font names,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4678
	     * create the array ...
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4679
	     */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4680
	    arr = __ARRAY_NEW_INT(available);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4681
	    if (! arr) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4682
		RETURN (nil);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4683
	    }
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
	     * ... and fill it
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4686
	     */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4687
	    for (i=0; i<available; i++) {
350
ade060e42304 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 342
diff changeset
  4688
		__PROTECT__(arr);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4689
		str = __MKSTRING(fonts[i] COMMA_CON);
350
ade060e42304 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 342
diff changeset
  4690
		__UNPROTECT__(arr);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4691
		__ArrayInstPtr(arr)->a_element[i] = str; __STORE(arr, str);
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
	    RETURN (arr);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4694
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4695
    }
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
    ^ nil
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
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4700
getDefaultFont
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4701
    "return a default font id - used when class Font cannot
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4702
     find anything usable"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4703
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4704
     ^ self createFontFor:'fixed'
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4705
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4706
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4707
getFontWithFamily:familyString face:faceString
963
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4708
	    style:styleArgString size:sizeArg encoding:encodingSym
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4709
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4710
    "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
  4711
     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
  4712
     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
  4713
     can be aquired that way."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4714
914
6cf4cc647095 Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents: 911
diff changeset
  4715
    |styleString theName theId xlatedStyle id spacing|
6cf4cc647095 Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents: 911
diff changeset
  4716
6cf4cc647095 Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents: 911
diff changeset
  4717
    styleString := styleArgString.
295
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
    "special: if face is nil, allow access to X-fonts"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4720
    faceString isNil ifTrue:[
963
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4721
	sizeArg notNil ifTrue:[
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4722
	    theName := familyString , '-' , sizeArg printString
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4723
	] ifFalse:[
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4724
	    theName := familyString
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4725
	].
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4726
	theName isNil ifTrue:[
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4727
	    "
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4728
	     mhmh - fall back to the default font
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4729
	    "
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4730
	    theName := 'fixed'
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4731
	].
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4732
	theId := self createFontFor:theName.
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4733
	theId isNil ifTrue:[
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4734
	    theId := self getDefaultFont
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4735
	].
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4736
	^ theId
914
6cf4cc647095 Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents: 911
diff changeset
  4737
    ].
6cf4cc647095 Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents: 911
diff changeset
  4738
6cf4cc647095 Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents: 911
diff changeset
  4739
    "/ spacing other than 'normal' is contained as last component
6cf4cc647095 Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents: 911
diff changeset
  4740
    "/ in style
6cf4cc647095 Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents: 911
diff changeset
  4741
6cf4cc647095 Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents: 911
diff changeset
  4742
    ((styleString endsWith:'-narrow') 
6cf4cc647095 Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents: 911
diff changeset
  4743
     or:[styleString endsWith:'-semicondensed']) ifTrue:[
963
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4744
	|i|
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4745
	i := styleString lastIndexOf:$-.
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4746
	spacing := styleString copyFrom:(i+1).
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4747
	styleString := styleString copyTo:(i-1).
914
6cf4cc647095 Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents: 911
diff changeset
  4748
    ] ifFalse:[
963
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4749
	spacing := 'normal'.
295
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
    xlatedStyle := styleString.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4753
    xlatedStyle notNil ifTrue:[
963
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4754
	xlatedStyle := xlatedStyle first asString
295
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
457
b40bf5d8727c ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents: 449
diff changeset
  4757
    id := self 
963
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4758
	    getFontWithFoundry:'*'
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4759
	    family:familyString asLowercase
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4760
	    weight:faceString
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4761
	    slant:xlatedStyle
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4762
	    spacing:spacing
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4763
	    pixelSize:nil
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4764
	    size:sizeArg 
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4765
	    registry:encodingSym
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4766
	    encoding:'*'.
457
b40bf5d8727c ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents: 449
diff changeset
  4767
b40bf5d8727c ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents: 449
diff changeset
  4768
    id isNil ifTrue:[
963
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4769
	(encodingSym notNil and:[encodingSym ~= '*']) ifTrue:[
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4770
	    "/ too stupid: encodings come in both cases
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4771
	    "/ and X does not ignore case
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4772
	    "/
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4773
	    id := self 
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4774
		    getFontWithFoundry:'*'
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4775
		    family:familyString asLowercase
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4776
		    weight:faceString
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4777
		    slant:xlatedStyle
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4778
		    spacing:spacing
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4779
		    pixelSize:nil
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4780
		    size:sizeArg 
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4781
		    registry:encodingSym asUppercase
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4782
		    encoding:'*'.
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4783
	    id isNil ifTrue:[
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4784
		id := self 
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4785
			getFontWithFoundry:'*'
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4786
			family:familyString asLowercase
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4787
			weight:faceString
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4788
			slant:xlatedStyle
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4789
			spacing:spacing
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4790
			pixelSize:nil
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4791
			size:sizeArg 
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4792
			registry:encodingSym asLowercase
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4793
			encoding:'*'.
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4794
	    ]
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  4795
	]
457
b40bf5d8727c ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents: 449
diff changeset
  4796
    ].
b40bf5d8727c ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents: 449
diff changeset
  4797
    ^ id
b40bf5d8727c ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents: 449
diff changeset
  4798
b40bf5d8727c ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents: 449
diff changeset
  4799
    "Modified: 24.2.1996 / 22:37:24 / cg"
914
6cf4cc647095 Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents: 911
diff changeset
  4800
    "Modified: 4.7.1996 / 11:38:47 / stefan"
295
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
getFontWithFoundry:foundry family:family weight:weight
480
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4804
	      slant:slant spacing:spc pixelSize:pSize size:size 
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4805
	      registry:registry encoding:encoding
295
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
    "get the specified font, if not available, return nil.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4808
     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
  4809
     use this entry.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4810
     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
  4811
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4812
     foundry: 'adobe', 'misc', 'dec', 'schumacher' ... usually '*'
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4813
     family:  'helvetica' 'courier' 'times' ...
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4814
     weight:  'bold' 'medium' 'demi' ...
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4815
     slant:   'r(oman)' 'i(talic)' 'o(blique)'
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4816
     spacing: 'narrow' 'normal' semicondensed' ... usually '*'
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4817
     pixelSize: 16,18 ... usually left empty
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4818
     size:      size in point (1/72th of an inch)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4819
     registry:  iso8859, sgi ... '*'
457
b40bf5d8727c ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents: 449
diff changeset
  4820
     encoding:  vendor specific encoding (usually '*')
295
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
457
b40bf5d8727c ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents: 449
diff changeset
  4823
    |theName sizeMatch 
b40bf5d8727c ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents: 449
diff changeset
  4824
     foundryMatch familyMatch weightMatch slantMatch spcMatch
b40bf5d8727c ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents: 449
diff changeset
  4825
     pSizeMatch registryMatch encodingMatch
b40bf5d8727c ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents: 449
diff changeset
  4826
     id|
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4827
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4828
    "this works only on 'Release >= 3' - X-servers"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4829
    "name is:
480
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4830
	-foundry-family    -weight -slant-
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4831
	 sony    helvetica bold     r
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4832
	 adobe   courier   medium   i
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4833
	 msic    fixed              o
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4834
	 ...     ...
295
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
457
b40bf5d8727c ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents: 449
diff changeset
  4837
    size isNil ifTrue:[
480
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4838
	sizeMatch := '*'
457
b40bf5d8727c ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents: 449
diff changeset
  4839
    ] ifFalse:[
480
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4840
	sizeMatch := size printString , '0'
457
b40bf5d8727c ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents: 449
diff changeset
  4841
    ].
b40bf5d8727c ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents: 449
diff changeset
  4842
    foundry isNil ifTrue:[
480
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4843
	foundryMatch := '*'
457
b40bf5d8727c ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents: 449
diff changeset
  4844
    ] ifFalse:[
480
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4845
	foundryMatch := foundry
457
b40bf5d8727c ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents: 449
diff changeset
  4846
    ].
b40bf5d8727c ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents: 449
diff changeset
  4847
    family isNil ifTrue:[
480
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4848
	familyMatch := '*'
457
b40bf5d8727c ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents: 449
diff changeset
  4849
    ] ifFalse:[
480
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4850
	familyMatch := family
457
b40bf5d8727c ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents: 449
diff changeset
  4851
    ].
b40bf5d8727c ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents: 449
diff changeset
  4852
    weight isNil ifTrue:[
480
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4853
	weightMatch := '*'
457
b40bf5d8727c ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents: 449
diff changeset
  4854
    ] ifFalse:[
480
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4855
	weightMatch := weight
457
b40bf5d8727c ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents: 449
diff changeset
  4856
    ].
b40bf5d8727c ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents: 449
diff changeset
  4857
    slant isNil ifTrue:[
480
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4858
	slantMatch := '*'
457
b40bf5d8727c ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents: 449
diff changeset
  4859
    ] ifFalse:[
480
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4860
	slantMatch := slant
457
b40bf5d8727c ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents: 449
diff changeset
  4861
    ].
b40bf5d8727c ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents: 449
diff changeset
  4862
    spc isNil ifTrue:[
480
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4863
	spcMatch := '*'
457
b40bf5d8727c ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents: 449
diff changeset
  4864
    ] ifFalse:[
480
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4865
	spcMatch := spc
457
b40bf5d8727c ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents: 449
diff changeset
  4866
    ].
b40bf5d8727c ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents: 449
diff changeset
  4867
    pSize isNil ifTrue:[
480
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4868
	pSizeMatch := '*'
457
b40bf5d8727c ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents: 449
diff changeset
  4869
    ] ifFalse:[
480
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4870
	pSizeMatch := pSize printString
457
b40bf5d8727c ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents: 449
diff changeset
  4871
    ].
b40bf5d8727c ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents: 449
diff changeset
  4872
    registry isNil ifTrue:[
480
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4873
	registryMatch := '*'
457
b40bf5d8727c ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents: 449
diff changeset
  4874
    ] ifFalse:[
480
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4875
	registryMatch := registry
457
b40bf5d8727c ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents: 449
diff changeset
  4876
    ].
b40bf5d8727c ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents: 449
diff changeset
  4877
    encoding isNil ifTrue:[
480
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4878
	encodingMatch := '*'
457
b40bf5d8727c ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents: 449
diff changeset
  4879
    ] ifFalse:[
480
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4880
	encodingMatch := encoding
457
b40bf5d8727c ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents: 449
diff changeset
  4881
    ].
b40bf5d8727c ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents: 449
diff changeset
  4882
b40bf5d8727c ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents: 449
diff changeset
  4883
    theName := ('-' , foundryMatch,
480
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4884
		'-' , familyMatch,
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4885
		'-' , weightMatch ,
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4886
		'-' , slantMatch , 
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4887
		'-' , spcMatch ,
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4888
		'-*' ,
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4889
		'-' , pSizeMatch ,
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4890
		'-' , sizeMatch ,
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4891
		'-*-*-*-*' ,
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4892
		'-' , registryMatch ,
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4893
		'-' , encodingMatch).
457
b40bf5d8727c ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents: 449
diff changeset
  4894
697
cba925eed3da showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 652
diff changeset
  4895
"/  Transcript showCR:theName; endEntry.
295
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
    ^ self createFontFor:theName.
457
b40bf5d8727c ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents: 449
diff changeset
  4898
        
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4899
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
     Display getFontWithFoundry:'*'
480
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4902
			 family:'courier'
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4903
			 weight:'medium'
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4904
			  slant:'r'
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4905
			spacing:nil
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4906
		      pixelSize:nil
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4907
			   size:13
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4908
		       registry:'iso8859'
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  4909
		       encoding:'*'
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4910
    "
457
b40bf5d8727c ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents: 449
diff changeset
  4911
b40bf5d8727c ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents: 449
diff changeset
  4912
    "Modified: 24.2.1996 / 22:33:29 / cg"
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4913
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4914
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4915
listOfAvailableFonts
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4916
    "return a list with all available fonts on this display.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4917
     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
  4918
     next time. The elements of the returned collection are instances of
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4919
     FontDescription."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4920
392
caf4452ec3dd merged sendKey/ButtonEvent into one method;
Claus Gittinger <cg@exept.de>
parents: 391
diff changeset
  4921
    |"stream aName fntDescr" names|
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4922
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4923
    listOfXFonts isNil ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4924
"/
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4925
"/ old code; using a pipe to xlsfonts
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
"/      stream := PipeStream readingFrom:'xlsfonts ''*'''.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4928
"/      stream isNil ifTrue:[^ nil].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4929
"/      listOfXFonts := OrderedCollection new.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4930
"/      [stream atEnd] whileFalse:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4931
"/          aName := stream nextLine.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4932
"/          aName notNil ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4933
"/          self decomposeXFontName:aName into:
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4934
"/                  [:family :face :style :size :coding |
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4935
"/                      family notNil ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4936
"/                          fntDescr := FontDescription
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4937
"/                                          family:family
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4938
"/                                          face:face
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4939
"/                                          style:style
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4940
"/                                          size:size
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4941
"/                                          encoding:coding.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4942
"/                          listOfXFonts add:fntDescr
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4943
"/                      ]
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4944
"/                  ]
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
"/      ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4947
"/      stream close.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4948
"/      "if xlsfont is broken ... (hey sco)"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4949
"/      (listOfXFonts size == 0) ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4950
"/          listOfXFonts := nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4951
"/      ] ifFalse:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4952
"/          listOfXFonts sort:[:a :b | a family < b family].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4953
"/      ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4954
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4955
	"/
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4956
	"/ new code:
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4957
	"/ use new primitive to get font names;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4958
	"/ this is much faster, and also works on systems where
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4959
	"/      a) xlsfonts is broken (sco)
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4960
	"/      b) xlsfonts is not available (aix)
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4961
	"/
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4962
	names := self getAvailableFontsMatching:'*'.
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4963
	names isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4964
	    "no names returned ..."
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4965
	    ^ nil
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4966
	].
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4967
	listOfXFonts := names collect:[:aName |
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4968
				    |fntDescr|
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4969
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4970
				    (self decomposeXFontName:aName into:
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4971
					[:family :face :style :size :coding |
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4972
					   family notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4973
					       fntDescr := FontDescription
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4974
							       family:family
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4975
							       face:face
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4976
							       style:style
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4977
							       size:size
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4978
							       encoding:coding.
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4979
					   ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4980
					       fntDescr := FontDescription
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4981
							       name:aName
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4982
					   ]
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4983
					]
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4984
				    ) ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4985
					fntDescr := FontDescription name:aName.
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4986
				    ].  
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4987
				    fntDescr
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  4988
			    ].
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4989
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4990
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4991
    ^ listOfXFonts
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4992
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4993
    "
568
ded98de3475f return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
  4994
     Display listOfAvailableFonts.
ded98de3475f return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
  4995
ded98de3475f return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
  4996
     Display getAvailableFontsMatching:'*'.
295
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
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  4999
    "Modified: 27.9.1995 / 10:54:47 / stefan"
568
ded98de3475f return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
  5000
    "Modified: 17.4.1996 / 15:27:57 / cg"
295
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
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5003
releaseFont:aFontId
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
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5006
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5007
    XFontStruct *f;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5008
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5009
    if (ISCONNECTED) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5010
	if (__isExternalAddress(aFontId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5011
	    f = _FontVal(aFontId);
995
2f2c0b2bff1a check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents: 994
diff changeset
  5012
	    if (f) {
2f2c0b2bff1a check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents: 994
diff changeset
  5013
	        BEGIN_INTERRUPTSBLOCKED
2f2c0b2bff1a check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents: 994
diff changeset
  5014
	        XFreeFont(myDpy, f);
923
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  5015
#ifdef COUNT_RESOURCES
995
2f2c0b2bff1a check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents: 994
diff changeset
  5016
	        __cnt_font--;
923
64bbcd3ee100 added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  5017
#endif
995
2f2c0b2bff1a check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents: 994
diff changeset
  5018
	        END_INTERRUPTSBLOCKED
2f2c0b2bff1a check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents: 994
diff changeset
  5019
	        RETURN ( self );
2f2c0b2bff1a check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents: 994
diff changeset
  5020
	    }
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5021
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5022
    }
402
f5a53e2a868d check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents: 397
diff changeset
  5023
%}.
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5024
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5025
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5026
466
257f4414a176 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 463
diff changeset
  5027
sizesInFamily:aFamilyName face:aFaceName style:aStyleName filtering:filter
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5028
    "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
  5029
     on this display.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5030
     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
  5031
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5032
    |sizes|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5033
466
257f4414a176 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 463
diff changeset
  5034
    sizes := super sizesInFamily:aFamilyName face:aFaceName style:aStyleName filtering:filter.
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5035
    (sizes notNil and:[sizes includes:0]) ifTrue:[
480
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  5036
	"special: in X11R5 and above, size 0 means:
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  5037
	 there are scaled versions in all sizes available"
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  5038
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  5039
	^ #(4 5 6 7 8 9 10 11 12 14 16 18 20 22 24 28 32 48 64)
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5040
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5041
    ^ sizes
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5042
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5043
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5044
     Display sizesInFamily:'courier' face:'bold' style:'roman'
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5045
    "
466
257f4414a176 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 463
diff changeset
  5046
257f4414a176 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 463
diff changeset
  5047
    "Created: 27.2.1996 / 01:38:15 / cg"
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5048
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5049
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5050
widthOf:aString from:index1 to:index2 inFont:aFontId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5051
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5052
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5053
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5054
    XFontStruct *f;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5055
    char *cp;
486
0c35ed67797d oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents: 481
diff changeset
  5056
    int len, n, i1, i2, l;
447
9a58924e921b dont hardcode TwoByteString - use __isWords to check for doubleByteStringDraw
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5057
    OBJ cls;
486
0c35ed67797d oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents: 481
diff changeset
  5058
#   define NLOCALBUFFER 200
0c35ed67797d oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents: 481
diff changeset
  5059
    XChar2b xlatebuffer[NLOCALBUFFER];
481
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  5060
    int nInstBytes;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5061
402
f5a53e2a868d check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents: 397
diff changeset
  5062
    if (ISCONNECTED) {
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5063
	if (__bothSmallInteger(index1, index2)
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5064
	 && __isExternalAddress(aFontId)
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5065
	 && __isNonNilObject(aString)) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5066
	    f = _FontVal(aFontId);
995
2f2c0b2bff1a check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents: 994
diff changeset
  5067
	    if (! f) goto fail;
2f2c0b2bff1a check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents: 994
diff changeset
  5068
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5069
	    i1 = __intVal(index1) - 1;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5070
	    cls = __qClass(aString);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5071
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5072
	    if (i1 >= 0) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5073
		i2 = __intVal(index2) - 1;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5074
		if (i2 < i1) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5075
		    RETURN (self);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5076
		}
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5077
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5078
		cp = (char *) _stringVal(aString);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5079
		l = i2 - i1 + 1;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5080
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5081
		if ((cls == @global(String)) || (cls == @global(Symbol))) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5082
		    n = _stringSize(aString);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5083
		    if (i2 < n) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5084
			cp += i1;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5085
			BEGIN_INTERRUPTSBLOCKED
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5086
			len = XTextWidth(f, cp, l);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5087
			END_INTERRUPTSBLOCKED
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5088
			RETURN ( __MKSMALLINT(len) );
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5089
		    }
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5090
		}
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5091
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5092
		nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5093
		cp += nInstBytes;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5094
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5095
		if (__isBytes(aString)) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5096
		    n = __byteArraySize(aString) - nInstBytes;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5097
		    if (i2 < n) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5098
			cp += i1;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5099
			BEGIN_INTERRUPTSBLOCKED
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5100
			len = XTextWidth(f, cp, l);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5101
			END_INTERRUPTSBLOCKED
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5102
			RETURN ( __MKSMALLINT(len) );
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5103
		    }
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5104
		}
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5105
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5106
		/* TWOBYTESTRINGS */
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5107
		if (__isWords(aString)) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5108
		    n = (__byteArraySize(aString) - nInstBytes) / 2;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5109
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5110
		    if (i2 < n) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5111
			union {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5112
			    char b[2];
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5113
			    unsigned short s;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5114
			} u;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5115
			int i;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5116
			XChar2b *cp2 = (XChar2b *)0;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5117
			int mustFree = 0;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5118
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5119
			cp += (i1 * 2);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5120
			if (l > 1000) l = 1000;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5121
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5122
			/*
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5123
			 * ST/X TwoByteStrings store the asciiValue in native byteOrder;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5124
			 * X expects them MSB first
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5125
			 * convert as required
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5126
			 */
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5127
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5128
			u.s = 0x1234;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5129
			if (u.b[0] != 0x12) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5130
			    if (l <= NLOCALBUFFER) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5131
				cp2 = xlatebuffer;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5132
			    } else {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5133
				cp2 = (XChar2b *)(malloc(l * 2));
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5134
				mustFree = 1;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5135
			    }
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5136
			    for (i=0; i<l; i++) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5137
				cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5138
				cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5139
			    }
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5140
			    cp = (char *) cp2;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5141
			}
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5142
			BEGIN_INTERRUPTSBLOCKED
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5143
			len = XTextWidth16(f, (XChar2b *)cp, l);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5144
			END_INTERRUPTSBLOCKED
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5145
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5146
			if (mustFree) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5147
			    free(cp2);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5148
			}
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5149
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5150
			RETURN ( __MKSMALLINT(len) );
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5151
		    }
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5152
		}
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5153
	    }
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5154
	}
486
0c35ed67797d oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents: 481
diff changeset
  5155
    }
0c35ed67797d oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents: 481
diff changeset
  5156
#undef NLOCALBUFFER
995
2f2c0b2bff1a check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents: 994
diff changeset
  5157
fail: ;
402
f5a53e2a868d check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents: 397
diff changeset
  5158
%}.
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5159
    self primitiveFailed.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5160
    ^ nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5161
!
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
widthOf:aString inFont:aFontId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5164
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
    XFontStruct *f;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5168
    char *cp;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5169
    int len, n;
447
9a58924e921b dont hardcode TwoByteString - use __isWords to check for doubleByteStringDraw
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5170
    OBJ cls;
486
0c35ed67797d oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents: 481
diff changeset
  5171
#   define NLOCALBUFFER 200
0c35ed67797d oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents: 481
diff changeset
  5172
    XChar2b xlatebuffer[NLOCALBUFFER];
481
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  5173
    int nInstBytes;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5174
402
f5a53e2a868d check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents: 397
diff changeset
  5175
    if (ISCONNECTED) {
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5176
	if (__isExternalAddress(aFontId)
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5177
	 && __isNonNilObject(aString)) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5178
	    f = _FontVal(aFontId);
995
2f2c0b2bff1a check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents: 994
diff changeset
  5179
	    if (! f) goto fail;
2f2c0b2bff1a check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents: 994
diff changeset
  5180
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5181
	    cls = __qClass(aString);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5182
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5183
	    cp = (char *)_stringVal(aString);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5184
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5185
	    if ((cls == @global(String)) || (cls == @global(Symbol))) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5186
		n = _stringSize(aString);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5187
		BEGIN_INTERRUPTSBLOCKED
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5188
		len = XTextWidth(f, cp, n);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5189
		END_INTERRUPTSBLOCKED
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5190
		RETURN ( __MKSMALLINT(len) );
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5191
	    }
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5192
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5193
	    nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5194
	    cp += nInstBytes;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5195
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5196
	    if (__isBytes(aString)) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5197
		n = __byteArraySize(aString) - nInstBytes;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5198
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5199
		BEGIN_INTERRUPTSBLOCKED
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5200
		len = XTextWidth(f, cp, n);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5201
		END_INTERRUPTSBLOCKED
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5202
		RETURN ( __MKSMALLINT(len) );
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5203
	    }
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5204
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5205
	    /* TWOBYTESTRINGS */
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5206
	    if (__isWords(aString)) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5207
		union {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5208
		    char b[2];
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5209
		    unsigned short s;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5210
		} u;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5211
		int i;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5212
		XChar2b *cp2;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5213
		int mustFree = 0;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5214
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5215
		n = (__byteArraySize(aString) - nInstBytes) / 2;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5216
		if (n > 1000) n = 1000;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5217
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5218
		/*
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5219
		 * ST/X TwoByteStrings store the asciiValue in native byteOrder;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5220
		 * X expects them MSB first
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5221
		 * convert as required
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5222
		 */
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5223
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5224
		u.s = 0x1234;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5225
		if (u.b[0] != 0x12) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5226
		    if (n <= NLOCALBUFFER) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5227
			cp2 = xlatebuffer;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5228
		    } else {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5229
			cp2 = (XChar2b *)(malloc(n * 2));
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5230
			mustFree = 1;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5231
		    }
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5232
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5233
		    for (i=0; i<n; i++) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5234
			cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5235
			cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5236
		    }
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5237
		    cp = (char *) cp2;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5238
		}
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5239
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5240
		BEGIN_INTERRUPTSBLOCKED
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5241
		len = XTextWidth16(f, (XChar2b *)cp, n);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5242
		END_INTERRUPTSBLOCKED
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5243
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5244
		if (mustFree) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5245
		    free(cp2);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5246
		}
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5247
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5248
		RETURN ( __MKSMALLINT(len) );
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5249
	    }
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5250
	}
486
0c35ed67797d oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents: 481
diff changeset
  5251
    }
0c35ed67797d oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents: 481
diff changeset
  5252
#undef NLOCALBUFFER
995
2f2c0b2bff1a check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents: 994
diff changeset
  5253
  fail: ;
402
f5a53e2a868d check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents: 397
diff changeset
  5254
%}.
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5255
    self primitiveFailed.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5256
    ^ nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5257
! !
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5258
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5259
!XWorkstation methodsFor:'grabbing '!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5260
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5261
allowEvents:mode
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5262
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5263
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5264
    int _mode, ok = 1;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5265
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5266
    if (mode == @symbol(asyncPointer))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5267
	_mode = AsyncPointer;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5268
    else if (mode == @symbol(syncPointer))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5269
	_mode = SyncPointer;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5270
    else if (mode == @symbol(asyncKeyboard))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5271
	_mode = AsyncKeyboard;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5272
    else if (mode == @symbol(syncKeyboard))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5273
	_mode = SyncKeyboard;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5274
    else if (mode == @symbol(syncBoth))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5275
	_mode = SyncBoth;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5276
    else if (mode == @symbol(asyncBoth))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5277
	_mode = AsyncBoth;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5278
    else if (mode == @symbol(replayPointer))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5279
	_mode = ReplayPointer;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5280
    else if (mode == @symbol(replayKeyboard))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5281
	_mode = ReplayKeyboard;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5282
    else
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5283
	ok = 0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5284
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5285
    if (ok) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5286
	BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5287
	XAllowEvents(myDpy, _mode, CurrentTime);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5288
	END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5289
	RETURN (self);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5290
    }
481
62f1be5db8aa also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  5291
%}.
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5292
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5293
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5294
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5295
grabKeyboardIn:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5296
    "grab the keyboard"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5297
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5298
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5299
    int result, ok;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5300
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5301
    if (__isExternalAddress(aWindowId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5302
	BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5303
	result = XGrabKeyboard(myDpy,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5304
			       _WindowVal(aWindowId),
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5305
			       True /* False */,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5306
			       GrabModeAsync,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5307
			       GrabModeAsync,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5308
			       CurrentTime);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5309
	END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5310
	ok = 0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5311
	switch(result) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5312
	    case AlreadyGrabbed: 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5313
		printf("XWORKSTAT: grab keyboard: AlreadyGrabbed\n");
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
	    case GrabNotViewable: 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5316
		printf("XWORKSTAT: grab keyboard: GrabNotViewable\n");
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5317
		break;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5318
	    case GrabInvalidTime: 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5319
		printf("XWORKSTAT: grab keyboard: InvalidTime\n");
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5320
		break;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5321
	    case GrabFrozen: 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5322
		printf("XWORKSTAT: grab keyboard: Frozen\n");
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5323
		break;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5324
	    default:
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5325
		ok = 1;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5326
		break;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5327
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5328
	if (! ok) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5329
	    XUngrabKeyboard(myDpy, CurrentTime);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5330
	    RETURN (false);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5331
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5332
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5333
	RETURN ( true );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5334
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5335
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5336
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5337
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5338
!
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
grabPointerIn:aWindowId withCursor:aCursorId pointerMode:pMode keyboardMode:kMode confineTo:confineId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5341
    "grap the pointer - return true if ok"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5342
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5343
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5344
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5345
    int result, ok;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5346
    Window confineWin;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5347
    Cursor curs;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5348
    int pointer_mode, keyboard_mode;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5349
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5350
    if (__isExternalAddress(aWindowId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5351
	if (__isExternalAddress(confineId)) 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5352
	    confineWin = _WindowVal(confineId);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5353
	else
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5354
	    confineWin = (Window) None;
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
	if (__isExternalAddress(aCursorId)) 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5357
	    curs = _CursorVal(aCursorId);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5358
	else
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5359
	    curs = (Cursor) None;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5360
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5361
	if (pMode == @symbol(sync))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5362
	    pointer_mode = GrabModeSync;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5363
	else
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5364
	    pointer_mode = GrabModeAsync;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5365
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5366
	if (kMode == @symbol(sync))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5367
	    keyboard_mode = GrabModeSync;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5368
	else
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5369
	    keyboard_mode = GrabModeAsync;
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
	BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5372
	result = XGrabPointer(myDpy,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5373
			      _WindowVal(aWindowId), 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5374
			      False, 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5375
			      ButtonPressMask | ButtonMotionMask | ButtonReleaseMask,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5376
			      pointer_mode, keyboard_mode,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5377
			      confineWin,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5378
			      curs,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5379
			      CurrentTime);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5380
	END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5381
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5382
	ok = 0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5383
	switch (result) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5384
	    case AlreadyGrabbed: 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5385
		printf("XWORKSTAT: grab pointer: AlreadyGrabbed\n");
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5386
		break;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5387
	    case GrabNotViewable: 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5388
		printf("XWORKSTAT: grab pointer: GrabNotViewable\n");
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5389
		break;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5390
	    case GrabInvalidTime: 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5391
		printf("XWORKSTAT: grab pointer: InvalidTime\n");
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5392
		break;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5393
	    case GrabFrozen: 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5394
		printf("XWORKSTAT: grab pointer: Frozen\n");
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5395
		break;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5396
	    default:
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5397
		ok = 1;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5398
		break;
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
	if (! ok) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5402
	    XUngrabPointer(myDpy, CurrentTime);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5403
	    RETURN (false);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5404
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5405
	RETURN ( true );
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
%}
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
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5410
!
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
ungrabKeyboard
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5413
    "release the keyboard"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5414
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5415
%{  /* NOCONTEXT */
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
    if (ISCONNECTED) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5418
	BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5419
	XUngrabKeyboard(myDpy, CurrentTime);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5420
	XSync(myDpy, 0);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5421
	END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5422
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5423
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5424
    activeKeyboardGrab := 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
ungrabPointer
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5428
    "release the pointer"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5429
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5430
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5431
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5432
    if (ISCONNECTED) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5433
	BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5434
	XUngrabPointer(myDpy, CurrentTime);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5435
	XSync(myDpy, 0);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5436
	END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5437
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5438
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5439
    activePointerGrab := nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5440
! !
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5441
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5442
!XWorkstation methodsFor:'graphic context stuff'!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5443
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5444
noClipIn:aGCId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5445
    "disable clipping rectangle"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5446
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5447
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5448
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5449
    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
  5450
    GC gc;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5451
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5452
    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
  5453
	gc = _GCVal(aGCId);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5454
	gcv.clip_mask = None;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5455
	XChangeGC(myDpy, gc, GCClipMask, &gcv);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5456
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5457
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5458
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5459
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5460
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5461
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5462
setBackground:bgColorIndex in:aGCId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5463
    "set background color to be drawn with"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5464
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5465
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5466
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5467
    if (__isExternalAddress(aGCId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5468
     && __isSmallInteger(bgColorIndex)) {
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  5469
	XSetBackground(myDpy, _GCVal(aGCId), __intVal(bgColorIndex));
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5470
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5471
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5472
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5473
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5474
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5475
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5476
setBitmapMask:aBitmapId in:aGCId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5477
    "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
  5478
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5479
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5480
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5481
    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
  5482
    GC gc;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5483
    Pixmap bitmap;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5484
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5485
    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
  5486
	gc = _GCVal(aGCId);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5487
	if (__isExternalAddress(aBitmapId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5488
	    bitmap = _PixmapVal(aBitmapId);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5489
	    XSetStipple(dpy, gc, bitmap);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5490
	    XSetFillStyle(dpy, gc, FillOpaqueStippled);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5491
	    RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5492
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5493
	if (aBitmapId == nil) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5494
	    XSetFillStyle(dpy, gc, FillSolid);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5495
	    RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5496
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5497
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5498
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5499
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5500
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5501
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5502
setClipByChildren:aBool in:aGCId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5503
    "enable/disable drawing into child views"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5504
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5505
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5506
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5507
    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
  5508
    GC gc;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5509
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5510
    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
  5511
	gc = _GCVal(aGCId);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5512
	if (aBool == true)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5513
	    gcv.subwindow_mode = ClipByChildren;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5514
	else
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5515
	    gcv.subwindow_mode = IncludeInferiors;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5516
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5517
	XChangeGC(myDpy, gc, GCSubwindowMode, &gcv);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5518
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5519
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5520
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5521
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5522
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5523
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5524
setClipX:clipX y:clipY width:clipWidth height:clipHeight in:aGCId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5525
    "clip to a rectangle"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5526
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5527
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5528
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5529
    XRectangle r;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5530
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5531
    if (__isExternalAddress(aGCId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5532
     && __bothSmallInteger(clipX, clipY)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5533
     && __bothSmallInteger(clipWidth, clipHeight)) {
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  5534
	r.x = __intVal(clipX);
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  5535
	r.y = __intVal(clipY);
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  5536
	r.width = __intVal(clipWidth);
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  5537
	r.height = __intVal(clipHeight);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5538
	XSetClipRectangles(myDpy, _GCVal(aGCId), 0, 0, &r, 1, Unsorted);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5539
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5540
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5541
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5542
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5543
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5544
788
23b4d0a26e3c added setDashes: ...
Claus Gittinger <cg@exept.de>
parents: 780
diff changeset
  5545
setDashes:dashList dashOffset:offset in:aGCId
23b4d0a26e3c added setDashes: ...
Claus Gittinger <cg@exept.de>
parents: 780
diff changeset
  5546
    "set line attributes"
23b4d0a26e3c added setDashes: ...
Claus Gittinger <cg@exept.de>
parents: 780
diff changeset
  5547
23b4d0a26e3c added setDashes: ...
Claus Gittinger <cg@exept.de>
parents: 780
diff changeset
  5548
%{  /* NOCONTEXT */
23b4d0a26e3c added setDashes: ...
Claus Gittinger <cg@exept.de>
parents: 780
diff changeset
  5549
23b4d0a26e3c added setDashes: ...
Claus Gittinger <cg@exept.de>
parents: 780
diff changeset
  5550
    if (__isExternalAddress(aGCId)
23b4d0a26e3c added setDashes: ...
Claus Gittinger <cg@exept.de>
parents: 780
diff changeset
  5551
     && __isSmallInteger(offset)
23b4d0a26e3c added setDashes: ...
Claus Gittinger <cg@exept.de>
parents: 780
diff changeset
  5552
     && __isByteArray(dashList)) {
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5553
	XSetDashes(myDpy, _GCVal(aGCId), 
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5554
		   __intVal(offset),
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5555
		   __ByteArrayInstPtr(dashList)->ba_element,
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5556
		   __byteArraySize(dashList));
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  5557
	RETURN ( self );
788
23b4d0a26e3c added setDashes: ...
Claus Gittinger <cg@exept.de>
parents: 780
diff changeset
  5558
    }
23b4d0a26e3c added setDashes: ...
Claus Gittinger <cg@exept.de>
parents: 780
diff changeset
  5559
bad: ;
23b4d0a26e3c added setDashes: ...
Claus Gittinger <cg@exept.de>
parents: 780
diff changeset
  5560
%}.
23b4d0a26e3c added setDashes: ...
Claus Gittinger <cg@exept.de>
parents: 780
diff changeset
  5561
    "
23b4d0a26e3c added setDashes: ...
Claus Gittinger <cg@exept.de>
parents: 780
diff changeset
  5562
     either aGCId is invalid,
23b4d0a26e3c added setDashes: ...
Claus Gittinger <cg@exept.de>
parents: 780
diff changeset
  5563
     and/or dashList is not a byteArray
23b4d0a26e3c added setDashes: ...
Claus Gittinger <cg@exept.de>
parents: 780
diff changeset
  5564
     and/or offset is not a smallInteger
23b4d0a26e3c added setDashes: ...
Claus Gittinger <cg@exept.de>
parents: 780
diff changeset
  5565
    "
23b4d0a26e3c added setDashes: ...
Claus Gittinger <cg@exept.de>
parents: 780
diff changeset
  5566
    self primitiveFailed
23b4d0a26e3c added setDashes: ...
Claus Gittinger <cg@exept.de>
parents: 780
diff changeset
  5567
!
23b4d0a26e3c added setDashes: ...
Claus Gittinger <cg@exept.de>
parents: 780
diff changeset
  5568
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5569
setFont:aFontId in:aGCId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5570
    "set font to be drawn in"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5571
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5572
%{  /* NOCONTEXT */
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
    XFontStruct *f;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5575
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5576
    if (__isExternalAddress(aFontId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5577
     && __isExternalAddress(aGCId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5578
	f = (XFontStruct *) _FontVal(aFontId);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5579
	XSetFont(myDpy, _GCVal(aGCId), f->fid);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5580
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5581
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5582
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5583
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5584
     aGCId and/or aFontId are invalid
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5585
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5586
    self primitiveFailed
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
setForeground:fgColorIndex background:bgColorIndex in:aGCId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5590
    "set foreground and background colors to be drawn with"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5591
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5592
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5593
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5594
    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
  5595
    GC gc;
295
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 (__bothSmallInteger(fgColorIndex, bgColorIndex)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5598
     && __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
  5599
	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
  5600
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  5601
	XSetForeground(dpy, gc, __intVal(fgColorIndex));
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  5602
	XSetBackground(dpy, gc, __intVal(bgColorIndex));
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5603
	RETURN ( self );
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
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5607
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5608
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5609
setForeground:fgColor background:bgColor mask:aBitmapId in:aGCId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5610
    "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
  5611
     solid (if aBitmapId is nil)"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5612
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5613
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5614
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5615
    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
  5616
    GC gc;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5617
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5618
    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
  5619
	gc = _GCVal(aGCId);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5620
	if (__isSmallInteger(fgColor))
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  5621
	    XSetForeground(dpy, gc, __intVal(fgColor));
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5622
	if (__isSmallInteger(bgColor))
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  5623
	    XSetBackground(dpy, gc, __intVal(bgColor));
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5624
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5625
	if (__isExternalAddress(aBitmapId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5626
	    XSetStipple(dpy, gc, _PixmapVal(aBitmapId));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5627
	    XSetFillStyle(dpy, gc, FillOpaqueStippled);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5628
	    RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5629
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5630
	if (aBitmapId == nil) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5631
	    XSetFillStyle(dpy, gc, FillSolid);
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
    }
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
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5637
!
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
setForeground:fgColor background:bgColor mask:aBitmapId lineWidth:lw in:aGCId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5640
    "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
  5641
     solid (if aBitmapId is nil); also set lineWidth"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5642
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5643
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5644
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5645
    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
  5646
    GC gc;
295
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
    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
  5649
	gc = _GCVal(aGCId);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5650
	if (__isSmallInteger(lw)) {
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  5651
	    XSetLineAttributes(dpy, gc, __intVal(lw),
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5652
				    LineSolid, CapNotLast, JoinMiter);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5653
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5654
	if (__isSmallInteger(fgColor))
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  5655
	    XSetForeground(dpy, gc, __intVal(fgColor));
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5656
	if (__isSmallInteger(bgColor))
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  5657
	    XSetBackground(dpy, gc, __intVal(bgColor));
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5658
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5659
	if (__isExternalAddress(aBitmapId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5660
	    XSetStipple(dpy, gc, _PixmapVal(aBitmapId));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5661
	    XSetFillStyle(dpy, gc, FillOpaqueStippled);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5662
	    RETURN ( self );
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
	if (aBitmapId == nil) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5665
	    XSetFillStyle(dpy, gc, FillSolid);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5666
	    RETURN ( self );
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
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5669
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5670
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5671
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5672
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5673
setForeground:fgColorIndex in:aGCId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5674
    "set foreground color to be drawn with"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5675
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5676
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5677
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5678
    if (__isExternalAddress(aGCId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5679
     && __isSmallInteger(fgColorIndex)) {
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  5680
	XSetForeground(myDpy, _GCVal(aGCId), __intVal(fgColorIndex));
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5681
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5682
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5683
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5684
    self primitiveFailed
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
setFunction:aFunctionSymbol in:aGCId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5688
    "set alu function to be drawn with"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5689
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5690
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5691
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  5692
    GC gc;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5693
    int fun = -1;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5694
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5695
    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
  5696
	gc = _GCVal(aGCId);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5697
	if (aFunctionSymbol == @symbol(copy)) fun = GXcopy;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5698
	else if (aFunctionSymbol == @symbol(copyInverted)) fun = GXcopyInverted;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5699
	else if (aFunctionSymbol == @symbol(xor)) fun = GXxor;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5700
	else if (aFunctionSymbol == @symbol(and)) fun = GXand;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5701
	else if (aFunctionSymbol == @symbol(andReverse)) fun = GXandReverse;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5702
	else if (aFunctionSymbol == @symbol(andInverted)) fun = GXandInverted;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5703
	else if (aFunctionSymbol == @symbol(or)) fun = GXor;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5704
	else if (aFunctionSymbol == @symbol(orReverse)) fun = GXorReverse;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5705
	else if (aFunctionSymbol == @symbol(orInverted)) fun = GXorInverted;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5706
	if (fun != -1) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5707
	    XSetFunction(myDpy, gc, fun);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5708
	    RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5709
	}
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
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5712
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5713
     either aGCId is not an integer, or an invalid symbol
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5714
     was passed ... valid functions are #copy, #copyInverted, #xor, #and, #andReverse,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5715
     #andInverted, #or, #orReverse, #orInverted. See Xlib documentation for more details.
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
    self primitiveFailed
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
setGraphicsExposures:aBoolean in:aGCId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5721
    "set or clear the graphics exposures flag"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5722
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5723
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5724
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5725
    if (__isExternalAddress(aGCId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5726
	XSetGraphicsExposures(myDpy, _GCVal(aGCId), (aBoolean==true)?1:0);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5727
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5728
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5729
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5730
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5731
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5732
!
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
setLineWidth:aNumber style:lineStyle cap:capStyle join:joinStyle in:aGCId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5735
    "set line attributes"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5736
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5737
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5738
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5739
    int x_style, x_cap, x_join;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5740
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5741
    if (__isExternalAddress(aGCId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5742
     && __isSmallInteger(aNumber)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5743
	if (lineStyle == @symbol(solid)) x_style = LineSolid;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5744
	else if (lineStyle == @symbol(dashed)) x_style = LineOnOffDash;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5745
	else if (lineStyle == @symbol(doubleDashed)) x_style = LineDoubleDash;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5746
	else  goto bad;
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
	if (capStyle == @symbol(notLast)) x_cap = CapNotLast;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5749
	else if (capStyle == @symbol(butt)) x_cap = CapButt;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5750
	else if (capStyle == @symbol(round)) x_cap  = CapRound;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5751
	else if (capStyle == @symbol(projecting)) x_cap  = CapProjecting;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5752
	else  goto bad;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5753
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5754
	if (joinStyle == @symbol(miter)) x_join = JoinMiter;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5755
	else if (joinStyle == @symbol(bevel)) x_join = JoinBevel;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5756
	else if (joinStyle == @symbol(round)) x_join  = JoinRound;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5757
	else  goto bad;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5758
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5759
	XSetLineAttributes(myDpy,
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  5760
			   _GCVal(aGCId), __intVal(aNumber),
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5761
			   x_style, x_cap, x_join);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5762
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5763
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5764
bad: ;
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
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5767
     either aGCId is invalid,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5768
     and/or lineStyle is none of #solid, #dashed, #doubleDashed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5769
     and/or capStyle is none of #notLast, #butt, #round, #projecting
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5770
     and/or joinStyle is none of #miter, #bevel, #round
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5771
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5772
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5773
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5774
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5775
setMaskOriginX:orgX y:orgY in:aGCid
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5776
    "set the mask origin"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5777
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5778
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5779
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5780
    if (__bothSmallInteger(orgX, orgY) && __isExternalAddress(aGCid)) {
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  5781
	XSetTSOrigin(myDpy, _GCVal(aGCid), __intVal(orgX), __intVal(orgY));
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5782
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5783
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5784
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5785
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5786
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5787
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5788
setPixmapMask:aPixmapId in:aGCId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5789
    "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
  5790
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5791
%{  /* NOCONTEXT */
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
    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
  5794
    GC gc;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5795
    Pixmap pixmap;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5796
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5797
    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
  5798
	gc = _GCVal(aGCId);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5799
	if (__isExternalAddress(aPixmapId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5800
	    pixmap = _PixmapVal(aPixmapId);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5801
	    XSetTile(dpy, gc, pixmap);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5802
	    XSetFillStyle(dpy, gc, FillTiled);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5803
	    RETURN ( self );
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
	if (aPixmapId == nil) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5806
	    XSetFillStyle(dpy, gc, FillSolid);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5807
	    RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5808
	}
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
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5811
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5812
! !
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
!XWorkstation methodsFor:'initialize / release'!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5815
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5816
close
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5817
    "close down the connection to the X-server"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5818
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5819
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5820
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5821
    if (ISCONNECTED) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5822
	BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5823
	XCloseDisplay(myDpy);
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  5824
	__INST(displayId) = nil;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5825
	END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5826
    }
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
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5830
initializeDefaultValues
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5831
    buttonTranslation := ButtonTranslation.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5832
    multiClickTimeDelta := MultiClickTimeDelta.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5833
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5834
    self initializeModifierMappings
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5835
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5836
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5837
initializeEventBuffer
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5838
    |sz|
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
%{
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  5841
    sz = __MKSMALLINT(sizeof(XEvent) + 100);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5842
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5843
    eventBuffer isNil ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5844
	eventBuffer := ByteArray new:sz.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5845
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5846
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5847
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5848
initializeFor:aDisplayName
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5849
    "initialize the receiver for a connection to an X-Server;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5850
     the argument, aDisplayName may be nil (for the default server from
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5851
     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
  5852
     as hostname:number"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5853
334
8c851e8a0b05 access comandline args via access method
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  5854
    |dpyName index arguments|
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5855
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5856
    dpyName := aDisplayName.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5857
    dpyName isNil ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5858
	"look for a '-display xxx' argument"
334
8c851e8a0b05 access comandline args via access method
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  5859
	(arguments := Smalltalk commandLineArguments) notNil ifTrue:[
8c851e8a0b05 access comandline args via access method
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  5860
	    index := arguments indexOf:'-display'.
8c851e8a0b05 access comandline args via access method
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  5861
	    (index between:1 and:(arguments size - 1)) ifTrue:[
8c851e8a0b05 access comandline args via access method
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  5862
		dpyName := arguments at:index+1
295
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
	]
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5865
    ].
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
    int scr;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5868
    Display *dpy;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5869
    Visual *visual;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5870
    XVisualInfo viproto;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5871
    XVisualInfo *vip;                   /* retured info */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5872
    int maxRGBDepth;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5873
    int rgbRedMask, rgbGreenMask, rgbBlueMask;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5874
    int rgbVisualID;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5875
    int nvi, i;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5876
    int shapeEventBase, shapeErrorBase;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5877
    int shmEventBase, shmErrorBase;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5878
    int faxEventBase, faxErrorBase;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5879
    char *type, *nm;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5880
    int dummy;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5881
    OBJ dpyID;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5882
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  5883
    if (__INST(displayId) != nil) {
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5884
	/*
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5885
	 * already connected - you bad guy try to
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5886
	 * trick me manually ?
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5887
	 */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5888
	RETURN ( self );
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
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5891
    BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5892
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5893
    if (__isString(dpyName))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5894
	nm = (char *)_stringVal(dpyName);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5895
    else {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5896
	dpyName = __MKSTRING((char *)getenv("DISPLAY") COMMA_CON);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5897
	nm = NULL;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5898
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5899
    dpy = XOpenDisplay(nm);
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 (dpy) {
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  5902
	__INST(displayId) = dpyID = __MKOBJ(dpy); __STORE(self, dpyID);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5903
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5904
#ifdef SUPERDEBUG
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5905
	XSynchronize(dpy, 1);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5906
#endif
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5907
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5908
	XSetErrorHandler(__XErrorHandler__);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5909
    }
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
    END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5912
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5913
    displayId isNil ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5914
	'XWORKSTATION: cannot connect to Display.' errorPrintNL.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5915
	^ nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5916
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5917
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5918
    dispatching := false.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5919
    dispatchingExpose := false.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5920
    isSlow := false.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5921
    shiftDown := false.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5922
    ctrlDown := false.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5923
    metaDown := false.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5924
    altDown := false.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5925
    motionEventCompression := true.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5926
    buttonsPressed := 0.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5927
    displayName := dpyName.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5928
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5929
    protocolsAtom := nil.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5930
    deleteWindowAtom := nil.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5931
    saveYourselfAtom := nil.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5932
    quitAppAtom := nil.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5933
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5934
    self initializeScreenProperties.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5935
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5936
    self initializeDefaultValues.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5937
    self initializeEventBuffer.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5938
    self initializeSpecialFlags.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5939
    self initializeKeyboardMap.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5940
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5941
    ObjectMemory registerErrorInterruptHandler:self class forID:#DisplayError.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5942
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5943
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5944
initializeModifierMappings
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5945
    |map mod|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5946
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5947
"/    altModifiers := #(Alt_L Alt_R).
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5948
"/    metaModifiers := #(Meta_L Meta_R).
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5949
"/    ctrlModifiers := #(Control_L Control_R).
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5950
"/    shiftModifiers := #(Shift_L Shift_R).
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5951
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5952
    shiftModifiers := ctrlModifiers := altModifiers := metaModifiers := nil.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5953
    altModifierMask := metaModifierMask := nil.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5954
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5955
    map := self modifierMapping.
342
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5956
    map isNil ifTrue:[
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5957
	"/
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5958
	"/ mhmh - a crippled Xlib which does not provide modifier mappings
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5959
	"/ setup some reasonable default. If that is not sufficient,
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5960
	"/ you have to change things from your display.rc file.
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5961
	"/
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5962
	altModifierMask := self modifier1Mask.
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5963
	metaModifierMask := self modifier2Mask.
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5964
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5965
	shiftModifiers := #(Shift_L Shift_R Shift).
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5966
	ctrlModifiers := #(Control_L Control_R Control).
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5967
	metaModifiers := #(Alt_L Meta_L Meta_R Meta).
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5968
	altModifiers := #(Alt_R Alt).
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5969
    ] ifFalse:[
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5970
	altModifierMask := 0.
374
17c544cc1fad commentary
Claus Gittinger <cg@exept.de>
parents: 366
diff changeset
  5971
	metaModifierMask := 0.
17c544cc1fad commentary
Claus Gittinger <cg@exept.de>
parents: 366
diff changeset
  5972
17c544cc1fad commentary
Claus Gittinger <cg@exept.de>
parents: 366
diff changeset
  5973
	mod := map at:1.
17c544cc1fad commentary
Claus Gittinger <cg@exept.de>
parents: 366
diff changeset
  5974
	mod notNil ifTrue:[
342
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5975
	    shiftModifiers := mod collect:[ :key | self stringFromKeycode:key ].
374
17c544cc1fad commentary
Claus Gittinger <cg@exept.de>
parents: 366
diff changeset
  5976
	].
17c544cc1fad commentary
Claus Gittinger <cg@exept.de>
parents: 366
diff changeset
  5977
	mod := map at:3.
17c544cc1fad commentary
Claus Gittinger <cg@exept.de>
parents: 366
diff changeset
  5978
	mod notNil ifTrue:[
342
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5979
	    ctrlModifiers  := mod collect:[ :key | self stringFromKeycode:key ].
374
17c544cc1fad commentary
Claus Gittinger <cg@exept.de>
parents: 366
diff changeset
  5980
	].
17c544cc1fad commentary
Claus Gittinger <cg@exept.de>
parents: 366
diff changeset
  5981
	mod := map at:4.
17c544cc1fad commentary
Claus Gittinger <cg@exept.de>
parents: 366
diff changeset
  5982
	mod notNil ifTrue:[
342
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5983
	    metaModifiers  := mod collect:[ :key | self stringFromKeycode:key ].    
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5984
	    metaModifierMask := 1 bitShift:(4-1).
374
17c544cc1fad commentary
Claus Gittinger <cg@exept.de>
parents: 366
diff changeset
  5985
	].
17c544cc1fad commentary
Claus Gittinger <cg@exept.de>
parents: 366
diff changeset
  5986
	mod := map at:5.
17c544cc1fad commentary
Claus Gittinger <cg@exept.de>
parents: 366
diff changeset
  5987
	mod notNil ifTrue:[
342
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5988
	    altModifiers   := mod collect:[ :key | self stringFromKeycode:key ].    
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5989
	    altModifierMask := 1 bitShift:(5-1).
a52a4e45a294 more on modifiers
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  5990
	]
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5991
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5992
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5993
    "Modified: 1.12.1995 / 23:44:40 / stefan"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5994
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5995
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5996
initializeScreenProperties
815
1e659479b292 call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  5997
    super initializeScreenProperties.
1e659479b292 call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  5998
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  5999
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6000
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6001
    Display *dpy = myDpy;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6002
    int scr;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6003
    Visual *visual;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6004
    XVisualInfo viproto;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6005
    XVisualInfo *vip;                   /* retured info */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6006
    int maxRGBDepth;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6007
    int rgbRedMask, rgbGreenMask, rgbBlueMask;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6008
    int rgbVisualID;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6009
    int nvi, i;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6010
    int shapeEventBase, shapeErrorBase;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6011
    int shmEventBase, shmErrorBase;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6012
    int faxEventBase, faxErrorBase;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6013
    char *type, *nm;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6014
    int dummy;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6015
    int mask, shift, nBits;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6016
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6017
    if (ISCONNECTED) {
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6018
	__INST(altModifierMask) = __MKSMALLINT(Mod2Mask);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6019
	__INST(metaModifierMask) = __MKSMALLINT(Mod1Mask);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6020
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6021
	BEGIN_INTERRUPTSBLOCKED
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6022
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6023
	__INST(screen) = __MKSMALLINT(scr = DefaultScreen(dpy));
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6024
	__INST(depth) = __MKSMALLINT(DisplayPlanes(dpy, scr));
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6025
	__INST(ncells) = __MKSMALLINT(DisplayCells(dpy, scr));
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6026
	__INST(width) = __MKSMALLINT(DisplayWidth(dpy, scr));
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6027
	__INST(height) = __MKSMALLINT(DisplayHeight(dpy, scr));
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6028
	__INST(widthMM) = __MKSMALLINT(DisplayWidthMM(dpy, scr));
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6029
	__INST(heightMM) = __MKSMALLINT(DisplayHeightMM(dpy, scr));
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6030
	__INST(blackpixel) = __MKSMALLINT(BlackPixel(dpy, scr));
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6031
	__INST(whitepixel) = __MKSMALLINT(WhitePixel(dpy, scr));
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6032
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6033
#ifdef SHAPE
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6034
	if (XShapeQueryExtension(dpy, &shapeEventBase, &shapeErrorBase))
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6035
	    __INST(hasShapeExtension) = true;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6036
	else
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6037
#endif
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6038
	  __INST(hasShapeExtension) = false;
295
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
#ifdef SHM
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6041
	if (XShmQueryExtension(dpy, &shmEventBase, &shmErrorBase))
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6042
	    __INST(hasShmExtension) = true;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6043
	else
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6044
#endif
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6045
	  __INST(hasShmExtension) = false;
295
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
#ifdef DPS
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6048
	if (XQueryExtension(dpy, "DPSExtension", &dummy, &dummy, &dummy))
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6049
	    __INST(hasDPSExtension) = true;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6050
	else
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6051
#endif
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6052
	  __INST(hasDPSExtension) = false;
295
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
#ifdef XVIDEO
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6055
	if (XQueryExtension(dpy, "XVideo", &dummy, &dummy, &dummy))
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6056
	    __INST(hasXVideoExtension) = true;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6057
	else
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6058
#endif
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6059
	  __INST(hasXVideoExtension) = false;
295
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
#ifdef MBUF
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6062
	if (XQueryExtension(dpy, "Multi-Buffering", &dummy, &dummy, &dummy))
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6063
	    __INST(hasMbufExtension) = true;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6064
	else
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6065
#endif
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6066
	  __INST(hasMbufExtension) = false;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6067
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6068
#ifdef PEX5
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6069
	if (XQueryExtension(dpy, PEX_NAME_STRING, &dummy, &dummy, &dummy))
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6070
	    __INST(hasPEXExtension) = true;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6071
	else
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6072
#endif
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6073
	  __INST(hasPEXExtension) = false;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6074
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6075
#ifdef XIE
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6076
	if (XQueryExtension(dpy, xieExtName, &dummy, &dummy, &dummy))
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6077
	    __INST(hasImageExtension) = true;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6078
	else
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6079
#endif
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6080
	  __INST(hasImageExtension) = false;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6081
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6082
#ifdef XI
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6083
	if (XQueryExtension(dpy, "XInputExtension", &dummy, &dummy, &dummy))
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6084
	    __INST(hasInputExtension) = true;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6085
	else
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6086
#endif
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6087
	  __INST(hasInputExtension) = false;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6088
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6089
	/*
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6090
	 * look for RGB visual
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6091
	 */
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6092
	nvi = 0;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6093
	viproto.screen = scr;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6094
	vip = XGetVisualInfo (dpy, VisualScreenMask, &viproto, &nvi);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6095
	maxRGBDepth = 0;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6096
	for (i = 0; i < nvi; i++) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6097
	    switch (vip[i].class) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6098
		case TrueColor:
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6099
		    if (vip[i].depth > maxRGBDepth) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6100
			maxRGBDepth = vip[i].depth;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6101
			rgbRedMask = vip[i].red_mask;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6102
			rgbGreenMask = vip[i].green_mask;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6103
			rgbBlueMask = vip[i].blue_mask;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6104
			rgbVisualID = vip[i].visualid;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6105
		    }
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6106
		    break;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6107
	    }
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6108
	}
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6109
	if (vip) XFree ((char *) vip);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6110
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6111
	if (maxRGBDepth) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6112
	    __INST(rgbVisual) = __MKOBJ(rgbVisualID); __STORESELF(rgbVisual);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6113
	}
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6114
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6115
	visual = DefaultVisualOfScreen(DefaultScreenOfDisplay(dpy));
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6116
	__INST(monitorType) = @symbol(unknown);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6117
	__INST(hasColors) = true;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6118
	__INST(hasGreyscales) = true;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6119
	switch (visual->class) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6120
	    case StaticGray:
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6121
		__INST(visualType) = @symbol(StaticGray);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6122
		__INST(hasColors) = false;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6123
		__INST(monitorType) = @symbol(monochrome);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6124
		break;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6125
	    case GrayScale:
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6126
		__INST(visualType) = @symbol(GrayScale);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6127
		__INST(hasColors) = false;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6128
		__INST(monitorType) = @symbol(monochrome);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6129
		break;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6130
	    case StaticColor:
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6131
		__INST(visualType) = @symbol(StaticColor);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6132
		break;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6133
	    case PseudoColor:
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6134
		__INST(visualType) = @symbol(PseudoColor);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6135
		break;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6136
	    case TrueColor:
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6137
		__INST(visualType) = @symbol(TrueColor);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6138
		break;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6139
	    case DirectColor:
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6140
		__INST(visualType) = @symbol(DirectColor);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6141
		break;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6142
	}
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6143
	if (DisplayCells(dpy, scr) == 2) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6144
	    __INST(hasColors) = false;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6145
	    __INST(hasGreyscales) = false;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6146
	    __INST(monitorType) = @symbol(monochrome);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6147
	}
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6148
	__INST(bitsPerRGB) = __MKSMALLINT(visual->bits_per_rgb);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6149
	__INST(redMask)   = __MKSMALLINT(visual->red_mask);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6150
	__INST(greenMask) = __MKSMALLINT(visual->green_mask);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6151
	__INST(blueMask)  = __MKSMALLINT(visual->blue_mask);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6152
	switch (visual->class) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6153
	    case TrueColor:
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6154
		/* extract number of bits and shift counts */
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6155
		mask = visual->red_mask;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6156
		shift = 0;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6157
		while (mask && ((mask & 1) == 0)) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6158
		    mask >>= 1;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6159
		    shift++;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6160
		}
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6161
		__INST(redShift) = __MKSMALLINT(shift);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6162
		nBits = 0;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6163
		while (mask) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6164
		    mask >>= 1;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6165
		    nBits++;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6166
		}
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6167
		__INST(bitsRed) = __MKSMALLINT(nBits);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6168
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6169
		mask = visual->green_mask;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6170
		shift = 0;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6171
		while (mask && ((mask & 1) == 0)) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6172
		    mask >>= 1;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6173
		    shift++;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6174
		}
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6175
		__INST(greenShift) = __MKSMALLINT(shift);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6176
		nBits = 0;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6177
		while (mask) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6178
		    mask >>= 1;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6179
		    nBits++;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6180
		}
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6181
		__INST(bitsGreen) = __MKSMALLINT(nBits);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6182
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6183
		mask = visual->blue_mask;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6184
		shift = 0;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6185
		while (mask && ((mask & 1) == 0)) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6186
		    mask >>= 1;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6187
		    shift++;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6188
		}
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6189
		__INST(blueShift) = __MKSMALLINT(shift);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6190
		nBits = 0;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6191
		while (mask) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6192
		    mask >>= 1;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6193
		    nBits++;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6194
		}
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6195
		__INST(bitsBlue) = __MKSMALLINT(nBits);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6196
		break;
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6197
	}
295
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
#ifndef XA_PRIMARY
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6200
	__INST(primaryAtom) = __MKATOMOBJ( XInternAtom(dpy, "PRIMARY", True) );
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6201
#else
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6202
	__INST(primaryAtom) = __MKATOMOBJ( XA_PRIMARY );
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6203
#endif
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6204
#ifndef XA_SECONDARY
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6205
	__INST(secondaryAtom) = __MKATOMOBJ( XInternAtom(dpy, "SECONDARY", True) );
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6206
#else
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6207
	__INST(secondaryAtom) = __MKATOMOBJ( XA_SECONDARY );
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6208
#endif
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6209
#ifndef XA_CUT_BUFFER0
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6210
	__INST(cutBuffer0Atom) = __MKATOMOBJ( XInternAtom(dpy, "CUT_BUFFER0", True) );
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6211
#else
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6212
	__INST(cutBuffer0Atom) = __MKATOMOBJ( XA_CUT_BUFFER0 );
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6213
#endif
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6214
#ifndef XA_STRING
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6215
	__INST(stringAtom) = __MKATOMOBJ( XInternAtom(dpy, "STRING", True) );
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6216
#else
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6217
	__INST(stringAtom) = __MKATOMOBJ( XA_STRING );
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6218
#endif
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6219
#ifndef XA_LENGTH
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6220
	__INST(lengthAtom) = __MKATOMOBJ( XInternAtom(dpy, "LENGTH", True) );
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6221
#else
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6222
	__INST(lengthAtom) = __MKATOMOBJ( XA_LENGTH );
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6223
#endif
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6224
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6225
	END_INTERRUPTSBLOCKED
815
1e659479b292 call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  6226
    }
1e659479b292 call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  6227
%}.
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6228
!
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
initializeSpecialFlags
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6231
    "perform additional special server implementation flags"
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
    "/
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6234
    "/ assume we have it ... (should check)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6235
    "/
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6236
    hasSaveUnder := true.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6237
    ignoreBackingStore := false.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6238
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6239
    (self serverVendor = 'X11/NeWS') ifTrue:[
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
	"/ 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
  6242
	"/ which does not correctly handle saveUnder
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6243
	"/
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6244
	hasSaveUnder := false.
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
reinitialize
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6249
    virtualRootId := rootId := nil.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6250
    super reinitialize.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6251
    dispatchingExpose := nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6252
! !
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6253
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6254
!XWorkstation methodsFor:'keyboard mapping'!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6255
540
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6256
altModifierMask
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6257
    "return the mask (in motionEvents) for the alt-key modifier.
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6258
     Notice: ST/X may use the left ALT key as CMD/Meta key,
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6259
     therefore return a variable here, which can be changed during startup."
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6260
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6261
    ^ altModifierMask
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6262
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6263
    "Created: 23.3.1996 / 12:43:22 / cg"
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6264
    "Modified: 23.3.1996 / 12:44:56 / cg"
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6265
!
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6266
341
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6267
altModifierMask:aSmallInteger
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6268
    "define which key takes the role of an alt-key.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6269
     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
  6270
     most keyboards. However, there may be exceptions to this,
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6271
     and the setting can be changed with:
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6272
	Display altModifierMask:(Display modifier2Mask)
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6273
     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
  6274
    "
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6275
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6276
    altModifierMask := aSmallInteger
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6277
!
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6278
540
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6279
metaModifierMask
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6280
    "return the mask (in motionEvents) for the meta-key modifier.
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6281
     Notice: ST/X may use the left ALT key as CMD/Meta key,
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6282
     therefore return a variable here, which can be changed during startup."
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6283
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6284
    ^ metaModifierMask
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6285
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6286
    "Created: 23.3.1996 / 12:43:39 / cg"
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6287
    "Modified: 23.3.1996 / 12:45:09 / cg"
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6288
!
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6289
341
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6290
metaModifierMask:aSmallInteger
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6291
    "define which key takes the role of a meta key.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6292
     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
  6293
     most keyboards (if present at all).
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6294
     However, there may be exceptions to this, and the setting can
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6295
     be changed with:
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6296
	Display metaModifierMask:(Display modifier1Mask)
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6297
     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
  6298
     As reported, some Xservers place the Meta-key onto NumLock,
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6299
     and having NumLock enabled makes ST/X think, that meta is pressed
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6300
     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
  6301
     the mask to 0.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6302
    "
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6303
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6304
    metaModifierMask := aSmallInteger
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6305
!
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6306
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6307
modifier1Mask
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6308
    "return the Xlib mask bit for the 1st modifier key.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6309
     See comment in altModifierMask: / metaModifierMask: for what
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6310
     this could be used."
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6311
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6312
%{  /* NOCONTEXT */
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6313
    RETURN (__MKSMALLINT(Mod1Mask));
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6314
%}
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6315
!
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6316
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6317
modifier2Mask
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6318
    "return the Xlib mask bit for the 2nd modifier key.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6319
     See comment in altModifierMask: / metaModifierMask: for what
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6320
     this could be used."
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6321
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6322
%{  /* NOCONTEXT */
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6323
    RETURN (__MKSMALLINT(Mod2Mask));
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6324
%}
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6325
!
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6326
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6327
modifierMapping
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6328
    "Get the Modifier Mapping.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6329
     We return an array of arrays of keycodes"
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6330
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6331
    |modifierKeyMap maxKeyPerMod ret nextKey|
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6332
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6333
%{
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6334
    Display *dpy = myDpy;
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6335
    XModifierKeymap *modmap;
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6336
    OBJ __BYTEARRAY_UNINITIALIZED_NEW_INT();
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6337
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6338
    if (ISCONNECTED) {
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6339
	if ((modmap = XGetModifierMapping(myDpy)) != 0) {
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6340
	   maxKeyPerMod = __MKSMALLINT(modmap->max_keypermod);
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6341
	   modifierKeyMap = __BYTEARRAY_UNINITIALIZED_NEW_INT(modmap->max_keypermod * 8);
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6342
	   if (modifierKeyMap != nil) {
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6343
		maxKeyPerMod = __MKSMALLINT(modmap->max_keypermod);
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6344
		memcpy((char *)__ByteArrayInstPtr(modifierKeyMap)->ba_element, 
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6345
		       (char *)modmap->modifiermap, modmap->max_keypermod * 8);
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6346
	   }
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6347
	   XFreeModifiermap(modmap);
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6348
	}
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6349
    }
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6350
%}.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6351
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6352
    modifierKeyMap isNil ifTrue:[^ nil].
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6353
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6354
    ret := Array new:8.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6355
    nextKey := 1.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6356
    1 to:8 do:[ :i |
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6357
	(modifierKeyMap at:nextKey) ~= 0 ifTrue:[
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6358
	    |mod|
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6359
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6360
	    mod := OrderedCollection new:maxKeyPerMod.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6361
	    modifierKeyMap from:nextKey to:(nextKey+maxKeyPerMod-1) do:[ :key |
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6362
		key ~= 0 ifTrue:[
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6363
		    mod add:key
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6364
		].
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6365
	    ].
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6366
	    ret at:i put:mod.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6367
	].
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6368
	nextKey := nextKey+maxKeyPerMod.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6369
    ].
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6370
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6371
    ^ ret
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6372
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6373
    "
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6374
	Display modifierMapping
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6375
    "
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6376
!
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6377
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6378
stringFromKeycode:code
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6379
    "Get a KeySymbol (a smalltalk symbol) from the keycode."
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6380
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6381
    |str|
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6382
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6383
%{
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6384
    Display *dpy = myDpy;
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6385
    KeySym keysym;
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6386
    char *keystring;
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6387
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6388
    if (ISCONNECTED && __isSmallInteger(code)) {
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6389
	if ((keysym = XKeycodeToKeysym(myDpy, __intVal(code), 0)) != NoSymbol &&
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6390
	    (keystring = XKeysymToString(keysym)) != 0) 
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6391
	    str = __MKSTRING(keystring);
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6392
    }
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6393
%}.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6394
    ^ str
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6395
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6396
    "
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6397
	Display stringFromKeycode:28
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6398
    "
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6399
!
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6400
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6401
translateKey:untranslatedKey
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6402
    "Return the key translated via the translation table.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6403
     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
  6404
     which gets further processed in the superclasses translation method."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6405
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6406
    |key|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6407
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6408
    (key := untranslatedKey) isString ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6409
	key := RawKeysymTranslation at:key ifAbsent:key.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6410
	key := key asSymbol.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6411
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6412
    ^ super translateKey:key 
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
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6415
!XWorkstation methodsFor:'misc'!
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
beep
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6418
    "output an audible beep or bell"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6419
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6420
    self beep:50
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6421
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6422
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6423
beep:volumeInPercent
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6424
    "output an audible beep"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6425
%{
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6426
    int volume;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6427
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6428
    if (__isSmallInteger(volumeInPercent) && ISCONNECTED) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6429
	/* stupid: X wants -100 .. 100 and calls this percent */
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  6430
	volume = __intVal(volumeInPercent) * 2 - 100;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6431
	if (volume < -100) volume = -100;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6432
	else if (volume > 100) volume = 100;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6433
	BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6434
	XBell(myDpy, volume);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6435
	END_INTERRUPTSBLOCKED
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
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6438
!
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
buffered
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6441
    "buffer drawing - do not send it immediately to the display.
374
17c544cc1fad commentary
Claus Gittinger <cg@exept.de>
parents: 366
diff changeset
  6442
     This is the default anyway.
17c544cc1fad commentary
Claus Gittinger <cg@exept.de>
parents: 366
diff changeset
  6443
     See #unBuffered for additional info."
295
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
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6446
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6447
    if (ISCONNECTED) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6448
	BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6449
	XSynchronize(myDpy, 0);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6450
	END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6451
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6452
%}
374
17c544cc1fad commentary
Claus Gittinger <cg@exept.de>
parents: 366
diff changeset
  6453
    "
17c544cc1fad commentary
Claus Gittinger <cg@exept.de>
parents: 366
diff changeset
  6454
     Display buffered
17c544cc1fad commentary
Claus Gittinger <cg@exept.de>
parents: 366
diff changeset
  6455
    "
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6456
!
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
flush
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6459
    "send all buffered drawing to the display.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6460
     This may be required to make certain, that all previous operations
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6461
     are really sent to the display before continuing. For example,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6462
     after a cursor-change with a followup long computation.
374
17c544cc1fad commentary
Claus Gittinger <cg@exept.de>
parents: 366
diff changeset
  6463
     (otherwise, the cursor change request may still be in the output buffer)
17c544cc1fad commentary
Claus Gittinger <cg@exept.de>
parents: 366
diff changeset
  6464
     See also #sync, which even waits until the request has been processed."
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6465
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6466
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6467
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6468
    if (ISCONNECTED) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6469
	BEGIN_INTERRUPTSBLOCKED
310
6ed27eebc243 stefans event queue changes
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
  6470
	XFlush(myDpy);
6ed27eebc243 stefans event queue changes
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
  6471
	END_INTERRUPTSBLOCKED
6ed27eebc243 stefans event queue changes
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
  6472
    }
6ed27eebc243 stefans event queue changes
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
  6473
%}
6ed27eebc243 stefans event queue changes
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
  6474
!
6ed27eebc243 stefans event queue changes
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
  6475
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6476
flushDpsContext:aDPSContext
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
#ifdef DPS
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6480
    if (__isExternalAddress(aDPSContext)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6481
	BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6482
	DPSFlushContext(MKDPSCONTEXT(aDPSContext));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6483
	END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6484
	RETURN ( self );
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
#endif
374
17c544cc1fad commentary
Claus Gittinger <cg@exept.de>
parents: 366
diff changeset
  6487
%}.
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6488
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6489
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6490
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6491
refreshKeyboardMapping:eB
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6492
%{
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6493
    XMappingEvent *ev;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6494
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6495
    if (__isByteArray(eB)) {
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  6496
	ev = (XMappingEvent *)(__ByteArrayInstPtr(eB)->ba_element);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6497
	XRefreshKeyboardMapping(ev);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6498
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6499
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6500
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6501
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6502
setInputFocusTo:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6503
"/    self setInputFocusTo:aWindowId revertTo:#parent
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6504
    self setInputFocusTo:aWindowId revertTo:#root
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6505
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6506
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6507
setInputFocusTo:aWindowId revertTo:revertSymbol
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6508
    "set the focus to the view as defined by aWindowId.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6509
     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
  6510
     input until a new focus is set.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6511
     RevertSymbol specifies what should happen if the view becomes invisible;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6512
     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
  6513
     given to the parent view, the root view or no view."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6514
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6515
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6516
    int arg;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6517
    Window focusWindow;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6518
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6519
    if (ISCONNECTED) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6520
	if (__isExternalAddress(aWindowId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6521
	    focusWindow = _WindowVal(aWindowId);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6522
	} else {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6523
	    focusWindow = None;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6524
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6525
	if (revertSymbol == @symbol(parent))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6526
	    arg = RevertToParent;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6527
	else if (revertSymbol == @symbol(root))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6528
	    arg = RevertToPointerRoot;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6529
	else 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6530
	    arg = RevertToNone;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6531
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6532
	BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6533
	XSetInputFocus(myDpy, focusWindow, arg, CurrentTime);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6534
	END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6535
	RETURN ( self );
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
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6539
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6540
341
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6541
sync
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6542
    "send all buffered drawing to the display AND wait until the display
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6543
     has finished drawing it.
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6544
     This is almost never needed, except if you are about to read previously
374
17c544cc1fad commentary
Claus Gittinger <cg@exept.de>
parents: 366
diff changeset
  6545
     drawn pixels back from the display screen, or you want to wait for a beep
17c544cc1fad commentary
Claus Gittinger <cg@exept.de>
parents: 366
diff changeset
  6546
     to be finished. See also #flush."
341
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6547
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6548
%{  /* NOCONTEXT */
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6549
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6550
    if (ISCONNECTED) {
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6551
	BEGIN_INTERRUPTSBLOCKED
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6552
	XSync(myDpy, 0);
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6553
	END_INTERRUPTSBLOCKED
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6554
    }
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6555
%}
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6556
!
47ac178c3924 modifiermappings - again
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  6557
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6558
unBuffered
374
17c544cc1fad commentary
Claus Gittinger <cg@exept.de>
parents: 366
diff changeset
  6559
    "make all drawing be sent immediately to the display.
17c544cc1fad commentary
Claus Gittinger <cg@exept.de>
parents: 366
diff changeset
  6560
     This makes all graphics synchronous and turns off any buffering
17c544cc1fad commentary
Claus Gittinger <cg@exept.de>
parents: 366
diff changeset
  6561
     (i.e. each individual draw-request is sent immediately without 
17c544cc1fad commentary
Claus Gittinger <cg@exept.de>
parents: 366
diff changeset
  6562
      packing multiple requests into a larger message buffer).
17c544cc1fad commentary
Claus Gittinger <cg@exept.de>
parents: 366
diff changeset
  6563
     Be prepared, that this slows down graphics considerably.
17c544cc1fad commentary
Claus Gittinger <cg@exept.de>
parents: 366
diff changeset
  6564
     However, it allows display errors to be handled immediately and
17c544cc1fad commentary
Claus Gittinger <cg@exept.de>
parents: 366
diff changeset
  6565
     may be useful if you get Xdisplay errors and want to find the request
17c544cc1fad commentary
Claus Gittinger <cg@exept.de>
parents: 366
diff changeset
  6566
     which was responsiblefor it. See also #buffered."
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6567
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6568
%{  /* NOCONTEXT */
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 (ISCONNECTED) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6571
	BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6572
	XSynchronize(myDpy, 1);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6573
	END_INTERRUPTSBLOCKED
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
    "Display unbuffered"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6577
! !
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6578
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6579
!XWorkstation methodsFor:'pointer queries '!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6580
540
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6581
anyButtonStateMask
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6582
    "return an integer for masking out any button from a
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6583
     buttonStates value."
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6584
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6585
    "/ should use ``Display buttonXMotionMask bitOr:....''
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6586
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6587
    ^ 256 + 512 + 1024
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6588
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6589
    "Modified: 23.3.1996 / 12:41:33 / cg"
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6590
    "Created: 23.3.1996 / 12:46:35 / cg"
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6591
!
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6592
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6593
buttonStates
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6594
    "return an integer representing the state of the pointer buttons;
540
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6595
     a one-bit in positions 0.. represent a pressed button.
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6596
     See the button1Mask/button2Mask/button3Mask,
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6597
     shiftMask/controlMask and modifierMask methods for the meaning of the bits."
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6598
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6599
%{  /* NOCONTEXT*/
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6600
    Display *dpy = myDpy;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6601
    Window w;
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  6602
    int screen = __intVal(__INST(screen));
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6603
    Window rootRet, childRet;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6604
    int rootX, rootY, winX, winY;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6605
    unsigned int mask;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6606
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6607
    BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6608
#ifdef VIRTUAL_ROOT
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6609
    w = getRootWindow(myDpy, screen);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6610
#else
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6611
    w = RootWindow(dpy, screen);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6612
#endif
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6613
    XQueryPointer(dpy, w, &rootRet, &childRet,
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6614
			  &rootX, &rootY,
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6615
			  &winX, &winY,
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6616
			  &mask);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6617
    END_INTERRUPTSBLOCKED
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  6618
    RETURN (__MKSMALLINT(mask));
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6619
%}
540
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6620
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6621
    "
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6622
     Display buttonStates     
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6623
    "
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6624
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6625
    "is the control-key pressed ?
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6626
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6627
     Display buttonStates bitTest:(Display controlMask)    
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6628
    "
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6629
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6630
    "is the alt/meta-key pressed ?
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6631
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6632
     Display buttonStates bitTest:(Display altModifierMask)    
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6633
     Display buttonStates bitTest:(Display metaModifierMask)    
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6634
    "
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6635
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6636
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6637
leftButtonStateMask
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6638
    "return an integer for masking out the left button from a
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6639
     buttonStates value"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6640
540
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6641
    "/ should use ``Display button1MotionMask''
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6642
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6643
    ^ 256
540
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6644
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6645
    "Modified: 23.3.1996 / 12:41:33 / cg"
295
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
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6648
middleButtonStateMask
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6649
    "return an integer for masking out the middle button from a
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6650
     buttonStates value"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6651
540
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6652
    "/ should use ``Display button2MotionMask''
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6653
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6654
    ^ 512
540
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6655
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6656
    "Modified: 23.3.1996 / 12:41:43 / cg"
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6657
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6658
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6659
pointerPosition
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6660
    "return the current pointer position in root-window coordinates"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6661
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6662
    |xpos ypos|
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
    Display *dpy = myDpy;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6666
    Window w;
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  6667
    int screen = __intVal(__INST(screen));
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6668
    Window rootRet, childRet;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6669
    int rootX, rootY, winX, winY;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6670
    unsigned int mask;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6671
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6672
    BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6673
#ifdef VIRTUAL_ROOT
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6674
    w = getRootWindow(myDpy, screen);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6675
#else
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6676
    w = RootWindow(dpy, screen);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6677
#endif
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6678
    XQueryPointer(dpy, w, &rootRet, &childRet,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6679
			  &rootX, &rootY,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6680
			  &winX, &winY,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6681
			  &mask);
315
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  6682
    xpos = __MKSMALLINT(rootX);
2abc494f0c45 _-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  6683
    ypos = __MKSMALLINT(rootY);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6684
    END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6685
%}
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
    ^ xpos @ ypos
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6688
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6689
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6690
rightButtonStateMask
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6691
    "return an integer for masking out the right button from a
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6692
     buttonStates value"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6693
540
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6694
    "/ should use ``Display button3MotionMask''
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6695
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6696
    ^ 1024
540
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6697
c954c490c8be stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
  6698
    "Modified: 23.3.1996 / 12:41:52 / cg"
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6699
!
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
rootPositionOfLastEvent
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6702
    "return the position in root-window coordinates
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6703
     of the last button, key or pointer event"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6704
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6705
    ^ eventRootX @ eventRootY
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6706
! !
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6707
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6708
!XWorkstation methodsFor:'resources'!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6709
487
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6710
atomIDOf:aStringOrSymbol
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6711
    "return an Atoms ID; dont create if not already present.
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6712
     This is highly X specific and only for local use (with selections)."
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6713
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6714
    ^ self atomIDOf:aStringOrSymbol create:false
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6715
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6716
    "
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6717
     Display atomIDOf:'FACE_NAME'      
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6718
     Display atomIDOf:'FULL_NAME' 
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6719
    "
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6720
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6721
    "Modified: 2.3.1996 / 15:09:29 / cg"
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6722
!
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6723
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6724
atomIDOf:aStringOrSymbol create:create
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6725
    "return an Atoms ID; if create is true, create it if not already present.
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6726
     This is highly X specific and only for local use (with selections)."
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6727
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6728
%{  /* NOCONTEXT */
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6729
    Atom prop;
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6730
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6731
    if (ISCONNECTED) {
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6732
	if (__isString(aStringOrSymbol)
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6733
	 || __isSymbol(aStringOrSymbol)) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6734
	    prop = XInternAtom(myDpy, _stringVal(aStringOrSymbol), 
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6735
				      (create == true) ? False : True);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6736
	    if (prop == None) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6737
		RETURN (nil);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6738
	    }
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6739
	    RETURN ( __MKATOMOBJ(prop) );
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6740
	}
487
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6741
    }
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6742
%}.
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6743
    self primitiveFailed.
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6744
    ^ nil
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6745
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6746
    "
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6747
     Display atomIDOf:'VT_SELECTION' create:false
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6748
     Display atomIDOf:'CUT_BUFFER0' create:false
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6749
     Display atomIDOf:'STRING' create:false
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6750
     Display atomIDOf:'PRIMARY' create:false
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6751
     Display atomIDOfPRIMARY
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6752
    "
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6753
!
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6754
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6755
atomIDOfCUTBUFFER0
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6756
    "return the CUTBUFFER0 AtomID.
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6757
     This is highly X specific and only for local use (with selections)."
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6758
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6759
    ^ cutBuffer0Atom
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6760
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6761
    "Modified: 2.3.1996 / 15:10:36 / cg"
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6762
!
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6763
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6764
atomIDOfLENGTH
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6765
    "return the LENGTH AtomID.
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6766
     This is highly X specific and only for local use (with selections)."
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6767
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6768
    ^ lengthAtom
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6769
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6770
    "Modified: 2.3.1996 / 15:10:41 / cg"
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6771
!
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6772
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6773
atomIDOfPRIMARY
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6774
    "return the PRIMARY AtomID.
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6775
     This is highly X specific and only for local use (with selections)."
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6776
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6777
    ^ primaryAtom
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6778
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6779
    "Modified: 2.3.1996 / 15:10:49 / cg"
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6780
!
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6781
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6782
atomIDOfSECONDARY
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6783
    "return the SECONDARY AtomID.
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6784
     This is highly X specific and only for local use (with selections)."
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6785
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6786
    ^ secondaryAtom
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6787
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6788
    "Modified: 2.3.1996 / 15:10:59 / cg"
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6789
!
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6790
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6791
atomIDOfSTRING
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6792
    "return the STRING AtomID.
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6793
     This is highly X specific and only for local use (with selections)."
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6794
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6795
    ^ stringAtom
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6796
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6797
    "Modified: 2.3.1996 / 15:11:08 / cg"
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6798
!
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6799
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6800
atomName:anAtomID
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6801
    "given an AtomID, return its name.
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6802
     This is highly X specific and only for local use (with selections)."
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6803
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6804
%{  /* NOCONTEXT */ 
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6805
    OBJ str;
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6806
    char *name;
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6807
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6808
    if (ISCONNECTED) {
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6809
	if (__isAtomID(anAtomID)) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6810
	    name = XGetAtomName(myDpy, _AtomVal(anAtomID));
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6811
	    if (name == 0) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6812
		RETURN (nil);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6813
	    }
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6814
	    str = __MKSTRING(name COMMA_CON);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6815
	    XFree(name);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6816
	    RETURN ( str );
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6817
	}
487
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6818
    }
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6819
%}.
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6820
    self primitiveFailed.
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6821
    ^ nil
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6822
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6823
    "
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6824
     Display atomName:1 
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6825
     Display atomName:130  '_DEC_DEVICE_FONTNAMES'
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6826
     Display atomName:132  'FONTNAME_REGISTRY'
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6827
     Display atomName:135 'FOUNDRY' 
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6828
     Display atomName:150  'CHARSET_REGISTRY'
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6829
     Display atomName:151  'ISO8859'
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6830
     Display atomName:152 'CHARSET_ENCODING'
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6831
     Display atomName:154 
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6832
    "
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6833
!
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6834
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6835
getResource:name class:cls
487
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6836
    "access the displays resource database for a default value
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6837
     of name in a resource class.
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6838
     This is highly X specific and  currently not used.
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6839
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6840
     Notice: 
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6841
	we do not plan to use X's resources for ST/X's defaults,
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6842
	styles or resources. This would make porting of applications
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6843
	to different platforms much more difficult (Windows has no resource
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6844
	database). If you stay within ST/X's resource files, these can be
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6845
	easily transported to other platforms.
487
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6846
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6847
     This method is provided for special applications which want to access
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6848
     existing X resources and are not planned to be ever ported to other
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6849
     platforms."
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6850
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6851
%{
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6852
    char *rslt;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6853
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6854
    if ((__isString(name) || __isSymbol(name))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6855
     && (__isString(cls) || __isSymbol(cls))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6856
     && ISCONNECTED) {
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6857
	BEGIN_INTERRUPTSBLOCKED
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6858
	rslt = XGetDefault(myDpy, (char *)_stringVal(cls),
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6859
				  (char *)_stringVal(name));
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6860
	END_INTERRUPTSBLOCKED
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6861
	RETURN (rslt ? __MKSTRING(rslt COMMA_CON) : nil );
487
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6862
    }
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6863
%}.
295
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
    ^ nil
487
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6866
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6867
    "if your ~/.Xdefaults contains an entry such as:
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6868
	OpenWindows.Beep:       notices
487
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6869
     the following returns 'notices'.
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6870
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6871
	 Display getResource:'Beep' class:'OpenWindows'   
487
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6872
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6873
     if your ~/.Xdefaults contains an entry such as:
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6874
	*.beNiceToColormap:       false
487
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6875
     the following return 'false'.
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6876
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6877
	 Display getResource:'beNiceToColormap' class:'any'  
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6878
	 Display getResource:'beNiceToColormap' class:''  
487
f6ac7231749e category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  6879
    "
295
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
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6882
!XWorkstation methodsFor:'retrieving pixels'!
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
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
  6885
    "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
  6886
     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
  6887
     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
  6888
     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
  6889
     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
  6890
397
094b8604ea72 return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents: 395
diff changeset
  6891
    |rawInfo info|
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6892
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6893
    ((w <= 0) or:[h <= 0]) ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6894
	self primitiveFailed.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6895
	^ nil
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
397
094b8604ea72 return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents: 395
diff changeset
  6898
    rawInfo := Array new:8.
094b8604ea72 return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents: 395
diff changeset
  6899
		  "1 -> bit order"
094b8604ea72 return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents: 395
diff changeset
  6900
		  "2 -> depth"
094b8604ea72 return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents: 395
diff changeset
  6901
		  "3 -> bytes_per_line"
094b8604ea72 return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents: 395
diff changeset
  6902
		  "4 -> byte_order"
094b8604ea72 return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents: 395
diff changeset
  6903
		  "5 -> format"
094b8604ea72 return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents: 395
diff changeset
  6904
		  "6 -> bitmap_unit"
094b8604ea72 return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents: 395
diff changeset
  6905
		  "7 -> bitmap_pad"
094b8604ea72 return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents: 395
diff changeset
  6906
		  "8 -> bits_per_pixel"
295
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
    "/ 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
  6909
    "/ unlimitedStack (some implementations use alloca and require huge amounts
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6910
    "/ of temporary stack space
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6911
397
094b8604ea72 return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents: 395
diff changeset
  6912
    (self primGetBitsFrom:aDrawableId x:srcx y:srcy width:w height:h into:imageBits infoInto:rawInfo) ifTrue:[
094b8604ea72 return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents: 395
diff changeset
  6913
	info := IdentityDictionary new.
094b8604ea72 return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents: 395
diff changeset
  6914
	info at:#bitOrder put:(rawInfo at:1).
094b8604ea72 return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents: 395
diff changeset
  6915
	info at:#depth put:(rawInfo at:2).
094b8604ea72 return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents: 395
diff changeset
  6916
	info at:#bytesPerLine put:(rawInfo at:3).
094b8604ea72 return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents: 395
diff changeset
  6917
	info at:#byteOrder put:(rawInfo at:4).
094b8604ea72 return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents: 395
diff changeset
  6918
	info at:#format put:(rawInfo at:5).
094b8604ea72 return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents: 395
diff changeset
  6919
	info at:#bitmapUnit put:(rawInfo at:6).
094b8604ea72 return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents: 395
diff changeset
  6920
	info at:#bitmapPad put:(rawInfo at:7).
094b8604ea72 return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents: 395
diff changeset
  6921
	info at:#bitsPerPixel put:(rawInfo at:8).
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6922
	^ info
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6923
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6924
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6925
     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
  6926
     or is too small to hold the bits
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6927
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6928
    ^ self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6929
!
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
getPixelX:x y:y from:aDrawableId
790
05ea637c94c3 care for null return from XGetImage
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
  6932
    "return the pixel value at x/y; coordinates start at 0/0 for the upper left.
05ea637c94c3 care for null return from XGetImage
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
  6933
     Nil is returned for invalid coordinates or if any other problem arises."
295
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
%{  /* UNLIMITEDSTACK NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6936
303
f2021d90f12d dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  6937
    Window win;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6938
    XImage *img;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6939
    int ret;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6940
    int xpos, ypos;
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
    if (__isExternalAddress(aDrawableId) && __bothSmallInteger(x, y)) {
850
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6943
	win = _WindowVal(aDrawableId);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6944
	xpos = __intVal(x);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6945
	ypos = __intVal(y);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6946
	if ((xpos < 0) || (ypos < 0)) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6947
	    RETURN ( __MKSMALLINT(0) );
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6948
	}
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6949
	img = XGetImage(myDpy, win, xpos, ypos, 1, 1, (unsigned)~0, ZPixmap);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6950
	if (img != 0) {
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6951
	    ret = XGetPixel(img, 0, 0);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6952
	    XDestroyImage(img);
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6953
	    RETURN (  __MKSMALLINT(ret) );
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
  6954
	}
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6955
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6956
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6957
    ^ nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6958
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6959
397
094b8604ea72 return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents: 395
diff changeset
  6960
primGetBitsFrom:aDrawableId x:srcx y:srcy width:w height:h into:imageBits infoInto:info
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6961
    "since XGetImage may allocate huge amount of stack space 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6962
     (some implementations use alloca), this must run with unlimited stack."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6963
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6964
%{  /* UNLIMITEDSTACK */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6965
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6966
    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
  6967
    Window win;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6968
    XImage *image = (XImage *)0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6969
    int pad, bytes_per_line, numBytes;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6970
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6971
    if (__isExternalAddress(aDrawableId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6972
     && __bothSmallInteger(srcx, srcy)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6973
     && __bothSmallInteger(w, h)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6974
     && __isArray(info)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6975
     && __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
  6976
	win = _WindowVal(aDrawableId);
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  6977
	image = XGetImage(dpy, win, __intVal(srcx), __intVal(srcy),
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  6978
				    __intVal(w), __intVal(h),
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6979
				    (unsigned)AllPlanes, ZPixmap);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6980
378
5d3c20a3bf7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 377
diff changeset
  6981
	if (! image) {
5d3c20a3bf7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 377
diff changeset
  6982
	    RETURN ( false );
5d3c20a3bf7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 377
diff changeset
  6983
	}
5d3c20a3bf7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 377
diff changeset
  6984
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6985
	pad = image->bitmap_pad;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6986
#ifdef SUPERDEBUG
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6987
	printf("pad:%d depth:%d\n", image->bitmap_pad, image->depth);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6988
#endif
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6989
	switch (image->depth) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6990
	    case 1:
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6991
	    case 2:
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6992
	    case 4:
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6993
	    case 8:
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6994
	    case 16:
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6995
	    case 24:
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6996
	    case 32:
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6997
		numBytes = image->bytes_per_line * image->height;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6998
		break;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  6999
	    default:
397
094b8604ea72 return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents: 395
diff changeset
  7000
		/* unsupported depth ? */
094b8604ea72 return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents: 395
diff changeset
  7001
		printf("possibly unsupported depth:%d in primGetBits\n", image->depth);
094b8604ea72 return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents: 395
diff changeset
  7002
		numBytes = image->bytes_per_line * image->height;
094b8604ea72 return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents: 395
diff changeset
  7003
		break;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7004
	}
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
#ifdef SUPERDEBUG
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  7007
	printf("bytes need:%d bytes given:%d\n", numBytes, __byteArraySize(imageBits));
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7008
#endif
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7009
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  7010
	if (numBytes > __byteArraySize(imageBits)) {
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7011
	    /* imageBits too small */
378
5d3c20a3bf7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 377
diff changeset
  7012
	    printf("provided byteArray too small\n");
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7013
	    goto fail;
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
	if (image->bitmap_bit_order == MSBFirst)
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  7016
	    __ArrayInstPtr(info)->a_element[0] = @symbol(msbFirst);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7017
	else
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  7018
	    __ArrayInstPtr(info)->a_element[0] = @symbol(lsbFirst);
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  7019
	__ArrayInstPtr(info)->a_element[1] = __MKSMALLINT(image->depth);
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  7020
	__ArrayInstPtr(info)->a_element[2] = __MKSMALLINT(image->bytes_per_line);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7021
	if (image->byte_order == MSBFirst)
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  7022
	    __ArrayInstPtr(info)->a_element[3] = @symbol(msbFirst);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7023
	else
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  7024
	    __ArrayInstPtr(info)->a_element[3] = @symbol(lsbFirst);
397
094b8604ea72 return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents: 395
diff changeset
  7025
	if (image->format == XYBitmap)
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  7026
	    __ArrayInstPtr(info)->a_element[4] = @symbol(XYBitmap);
397
094b8604ea72 return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents: 395
diff changeset
  7027
	else if (image->format == XYPixmap)
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  7028
	    __ArrayInstPtr(info)->a_element[4] = @symbol(XYPixmap);
397
094b8604ea72 return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents: 395
diff changeset
  7029
	else if (image->format == ZPixmap)
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  7030
	    __ArrayInstPtr(info)->a_element[4] = @symbol(ZPixmap);
480
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  7031
        
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  7032
	__ArrayInstPtr(info)->a_element[5] = __MKSMALLINT(image->bitmap_unit);
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  7033
	__ArrayInstPtr(info)->a_element[6] = __MKSMALLINT(image->bitmap_pad);
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  7034
	__ArrayInstPtr(info)->a_element[7] = __MKSMALLINT(image->bits_per_pixel);
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  7035
	bcopy(image->data, __ByteArrayInstPtr(imageBits)->ba_element, numBytes);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7036
	XDestroyImage(image);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7037
	RETURN ( true );
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
fail: 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7040
    if (image) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7041
	XDestroyImage(image);
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
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7044
    ^ false
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
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7047
!XWorkstation methodsFor:'selections'!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7048
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7049
getObjectProperty:propertyID from:aWindowID
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7050
    "get an object property; return object or nil"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7051
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7052
    self getProperty:propertyID from:aWindowID into:[:type :value |
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7053
	type == stringAtom ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7054
	    ^ value
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7055
	].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7056
	(value isMemberOf:ByteArray) ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7057
	    ^ (Object readBinaryFrom:(ReadStream on:value) onError:[nil])
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7058
	]
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
    ^ nil
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
getProperty:propertyID from:aWindowID into:aTwoArgBlock
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7064
    "get a property, evaluate aTwoArgBlock with typeID and value"
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
    |val typeID cls|
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
    cls := ByteArray.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7069
%{
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7070
    Display *dpy = myDpy;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7071
    Window window;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7072
    Atom property;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7073
    char *cp, *cp2;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7074
    Atom actual_type;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7075
    int actual_format,i;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7076
    unsigned long nitems, bytes_after, nread;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7077
    unsigned char *data;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7078
    int ok = 1;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7079
#   define PROP_SIZE    2048
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7080
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7081
    if (__isAtomID(propertyID)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7082
	property = _AtomVal(propertyID);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7083
	if (__isExternalAddress(aWindowID)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7084
	    window = _WindowVal(aWindowID);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7085
	} else {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7086
	    window = DefaultRootWindow(dpy);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7087
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7088
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7089
	nread = 0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7090
	cp = 0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7091
/*
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7092
	fprintf(stderr, "getProperty: ");
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7093
 */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7094
	do {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7095
	    if (XGetWindowProperty(dpy,window,property,nread/4,PROP_SIZE,False,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7096
				   AnyPropertyType,&actual_type,&actual_format,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7097
				   &nitems,&bytes_after,(unsigned char **)&data)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7098
		!= Success) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7099
		    ok = 0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7100
		    break;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7101
	    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7102
	    typeID = __MKATOMOBJ(actual_type);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7103
	    if (! cp) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7104
		cp = cp2 = (char *)malloc(nitems+1);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7105
	    } else {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7106
		cp = (char *)realloc(cp, nread + nitems + 1);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7107
		cp2 = cp + nread;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7108
	    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7109
	    if (! cp) goto fail;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7110
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7111
	    nread += nitems;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7112
	    bcopy(data, cp2, nitems);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7113
	    XFree(data);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7114
/*
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7115
	    fprintf(stderr, "<nitems:%d bytes_after:%d>", nitems, bytes_after);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7116
 */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7117
	} while (bytes_after > 0);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7118
/*
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7119
	fprintf(stderr, "\n");
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7120
 */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7121
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7122
	if (ok) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7123
	    if (actual_type == XA_STRING) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7124
		cp[nread] = '\0';
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7125
		val = __MKSTRING_L(cp, nread COMMA_CON);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7126
	    } else {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7127
		val = __new(nread + OHDR_SIZE);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7128
		val->o_class = cls;
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  7129
		bcopy(cp, __ByteArrayInstPtr(val)->ba_element, nread);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7130
	    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7131
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7132
	if (cp)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7133
	    free(cp);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7134
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7135
fail: ;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7136
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7137
    typeID isNil ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7138
	^ false
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7139
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7140
    aTwoArgBlock value:typeID value:val.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7141
    ^ true
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7142
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7143
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7144
getSelectionFor:drawableId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7145
    "get the object selection -  either immediate, or asynchronous.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7146
     Returns nil, if async request is on its way"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7147
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7148
    |selProp sel|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7149
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7150
    (self getSelectionOwnerOf:primaryAtom) isNil ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7151
	"no primary selection - use cut buffer"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7152
	sel := self getObjectProperty:cutBuffer0Atom from:nil.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7153
	^ sel
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7154
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7155
    selProp := self atomIDOf:'ST_SELECTION' create:true.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7156
    self requestObjectSelection:primaryAtom property:selProp for:drawableId.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7157
    ^ nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7158
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7159
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7160
getSelectionOwnerOf:selectionAtomID
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7161
    "get the owner of a selection"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7162
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7163
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7164
    Display *dpy = myDpy;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7165
    Atom selection;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7166
    Window window;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7167
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7168
    if (__isAtomID(selectionAtomID) && ISCONNECTED) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7169
	window = XGetSelectionOwner(dpy, _AtomVal(selectionAtomID));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7170
	RETURN ((window == None) ? nil : __MKOBJ(window));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7171
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7172
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7173
     self primitiveFailed.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7174
    ^ nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7175
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7176
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7177
getTextProperty:propertyID from:aWindowID
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7178
    "get a text property; return string or nil"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7179
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7180
    self getProperty:propertyID from:aWindowID into:[:type :value |
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7181
	type == stringAtom ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7182
	    ^ value
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7183
	]
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7184
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7185
    ^ nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7186
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7187
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7188
getTextSelectionFor:drawableId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7189
    "get the text selection -  either immediate, or asynchronous.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7190
     Returns nil, if async request is on its way"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7191
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7192
    |selProp sel|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7193
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7194
    (self getSelectionOwnerOf:primaryAtom) isNil ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7195
	"no primary selection - use cut buffer"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7196
	sel := self getTextProperty:cutBuffer0Atom from:nil.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7197
	^ sel
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7198
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7199
    selProp := self atomIDOf:'VT_SELECTION' create:true.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7200
    self requestTextSelection:primaryAtom property:selProp for:drawableId.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7201
    ^ nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7202
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7203
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7204
requestObjectSelection:selectionID property:propertyID for:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7205
    "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
  7206
     will later receive a SelectionNotify event for it."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7207
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7208
    ^ self requestSelection:selectionID 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7209
		   property:propertyID 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7210
		   type:(self atomIDOf:'ST_OBJECT' create:true) 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7211
		   for:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7212
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7213
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7214
requestSelection:selectionID property:propertyID type:typeID for:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7215
    "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
  7216
     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
  7217
     with the selections value)."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7218
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7219
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7220
    Display *dpy = myDpy;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7221
    Atom sel_prop;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7222
    char *cp;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7223
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7224
    if (__isExternalAddress(aWindowId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7225
     && ISCONNECTED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7226
     && __isSmallInteger(typeID)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7227
     && __isAtomID(selectionID)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7228
	if (XGetSelectionOwner(dpy, _AtomVal(selectionID)) == None) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7229
	    /*
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7230
	     * no owner of primary selection
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7231
	     */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7232
	    RETURN (false);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7233
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7234
	/*
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7235
	 * PRIMARY selection
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7236
	 */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7237
	XConvertSelection(dpy, _AtomVal(selectionID), _AtomVal(typeID), 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7238
			       _AtomVal(propertyID), _WindowVal(aWindowId), CurrentTime);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7239
	RETURN (true);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7240
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7241
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7242
    self primitiveFailed.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7243
    ^ false
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7244
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7245
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7246
     Display requestSelection:(Display atomIDOf:'PRIMARY')
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7247
		     property:(Display atomIDOf:'VT_SELECTION')
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7248
			  for:0
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7249
    "
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7250
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7251
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7252
requestTextSelection:selectionID property:propertyID for:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7253
    "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
  7254
     will later receive a SelectionNotify event for it."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7255
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7256
    ^ self requestSelection:selectionID 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7257
		   property:propertyID 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7258
		       type:stringAtom 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7259
			for:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7260
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7261
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7262
sendSelection:something property:propertyID target:targetID from:windowID to:requestorID
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7263
    "send aString back from a SelectionRequest"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7264
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7265
    self 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7266
	sendSelection:something 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7267
	selection:primaryAtom
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7268
	property:propertyID 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7269
	target:targetID 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7270
	from:windowID 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7271
	to:requestorID
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7272
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7273
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7274
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
  7275
    "send aString back from a SelectionRequest"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7276
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7277
    self 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7278
	setProperty:propertyID 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7279
	type:targetID 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7280
	value:something 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7281
	for:requestorID.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7282
    self 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7283
	sendSelectionNotifySelection:selectionID 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7284
	property:propertyID 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7285
	target:targetID 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7286
	from:requestorID 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7287
	to:requestorID.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7288
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7289
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7290
sendSelectionNotifySelection:selectionID property:propertyID target:targetID from:windowID to:requestorID
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7291
    "send a selectionNotify back from a SelectionRequest"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7292
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7293
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7294
    Display *dpy = myDpy;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7296
    if (__isAtomID(propertyID)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7297
     && __isExternalAddress(requestorID)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7298
     && ISCONNECTED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7299
     && __isAtomID(targetID)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7300
     && __isAtomID(selectionID)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7301
	XEvent ev;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7302
	Window requestor = _WindowVal(requestorID);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7303
	Atom property = _AtomVal(propertyID);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7304
	Atom target = _AtomVal(targetID);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7305
	Atom selection = _AtomVal(selectionID);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7306
	Status result;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7307
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7308
	ev.xselection.type = SelectionNotify;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7309
	ev.xselection.selection = selection;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7310
	ev.xselection.target = target;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7311
	if (__isExternalAddress(windowID))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7312
	    ev.xselection.requestor = _WindowVal(windowID);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7313
	else
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7314
	    ev.xselection.requestor = DefaultRootWindow(dpy);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7315
	ev.xselection.time = CurrentTime;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7316
	if (property == None)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7317
	    ev.xselection.property = target;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7318
	else
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7319
	    ev.xselection.property = property;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7320
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7321
	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
  7322
		ev.xselection.selection,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7323
		ev.xselection.property,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7324
		ev.xselection.target,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7325
		ev.xselection.requestor,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7326
		requestor));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7327
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7328
	result = XSendEvent(dpy, requestor, False, 0 , &ev);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7329
	if ((result == BadValue) || (result == BadWindow)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7330
	    DPRINTF(("bad status\n"));
382
92200ee9f558 added sendKey/sendButtonEvent
ah
parents: 378
diff changeset
  7331
	    RETURN (false);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7332
	}
382
92200ee9f558 added sendKey/sendButtonEvent
ah
parents: 378
diff changeset
  7333
	RETURN (true)
92200ee9f558 added sendKey/sendButtonEvent
ah
parents: 378
diff changeset
  7334
    }
92200ee9f558 added sendKey/sendButtonEvent
ah
parents: 378
diff changeset
  7335
%}.
92200ee9f558 added sendKey/sendButtonEvent
ah
parents: 378
diff changeset
  7336
    self primitiveFailed.
92200ee9f558 added sendKey/sendButtonEvent
ah
parents: 378
diff changeset
  7337
    ^ false
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7338
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7339
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7340
setLengthProperty:propertyID value:aNumber for:aWindowID
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7341
    ^ self setProperty:propertyID type:(self atomIDOfLENGTH) value:aNumber for:aWindowID
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7342
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7343
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7344
setObjectProperty:propertyID value:anObject for:aWindowID
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7345
    |s|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7346
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7347
    (anObject isMemberOf:String) ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7348
	^ self setTextProperty:propertyID value:anObject for:aWindowID
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7349
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7350
    s := WriteStream on:(ByteArray new:200).
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7351
    anObject storeBinaryOn:s.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7352
    ^ self 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7353
	setProperty:propertyID 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7354
	type:(self atomIDOf:'ST_OBJECT' create:true) 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7355
	value:(s contents) 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7356
	for:aWindowID
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7357
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7358
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7359
setProperty:propertyID type:typeID value:anObject for:aWindowID
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7360
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7361
%{  /* UNLIMITEDSTACK */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7362
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7363
    Display *dpy = myDpy;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7364
    Atom prop, type;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7365
    Window window;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7366
    unsigned int value;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7367
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7368
    if (__isAtomID(propertyID)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7369
     && __isAtomID(typeID) 
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7370
     && ISCONNECTED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7371
     && (__isString(anObject) 
480
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  7372
	 || __isSmallInteger(anObject) 
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  7373
	 || __isSymbol(anObject) 
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  7374
	 || __isByteArray(anObject)
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  7375
	 || __isWords(anObject))) { 
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  7376
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  7377
	prop = _AtomVal(propertyID);
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  7378
	type = _AtomVal(typeID);
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  7379
	if (__isExternalAddress(aWindowID)) {
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  7380
	    window = _WindowVal(aWindowID);
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  7381
	} else {
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  7382
	    window = DefaultRootWindow(dpy);
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  7383
	}
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  7384
	if (__isSmallInteger(anObject)) {
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  7385
	    value = __intVal(anObject);
480
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  7386
	    XChangeProperty(dpy, window, prop, type, 32,
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  7387
			    PropModeReplace,
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  7388
			    (unsigned char *)(&value), sizeof(unsigned int));
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  7389
	} else {
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  7390
	    if (__isByteArray(anObject)) {
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  7391
		XChangeProperty(dpy, window, prop, type, 8,
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  7392
				PropModeReplace,
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  7393
				__ByteArrayInstPtr(anObject)->ba_element,
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  7394
				__byteArraySize(anObject));
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  7395
	    } else {
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  7396
		/* string or symbol or wordArray-like (16bit-string) object */
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  7397
		if (__isWords(__qClass(anObject))) {
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  7398
		    XChangeProperty(dpy, window, prop, XA_STRING, 16,
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  7399
				    PropModeReplace,
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  7400
				    __stringVal(anObject),
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  7401
				    __wordArraySize(anObject));
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  7402
		} else {
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  7403
		    XChangeProperty(dpy, window, prop, XA_STRING, 8,
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  7404
				    PropModeReplace,
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  7405
				    __stringVal(anObject),
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  7406
				    strlen(__stringVal(anObject)));
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  7407
		}
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  7408
	    }
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  7409
	}
07ab9bbaea5f create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
  7410
	RETURN (true);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7411
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7412
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7413
    ^ false
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7414
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7415
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7416
setSelection:anObject owner:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7417
    "set the object selection, and make aWindowId be the owner.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7418
     This can be used by other Smalltalk(X) applications only."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7419
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7420
    (self setSelectionOwner:aWindowId of:primaryAtom) ifFalse:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7421
	^ false
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7422
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7423
"/    ^ self setObjectProperty:cutBuffer0Atom value:anObject for:nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7424
    ^ true
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7425
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7426
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7427
setSelectionOwner:aWindowId of:selectionID
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7428
    "set the owner of a selection; return false if failed"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7429
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7430
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7431
    Display *dpy = myDpy;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7432
    Window win;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7433
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7434
    if (__isExternalAddress(aWindowId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7435
     && __isAtomID(selectionID)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7436
     && ISCONNECTED) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7437
	win = _WindowVal(aWindowId);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7438
	XSetSelectionOwner(dpy, _AtomVal(selectionID), win, CurrentTime);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7439
	if (XGetSelectionOwner(dpy, _AtomVal(selectionID)) != win) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7440
	    RETURN (false);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7441
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7442
	RETURN (true);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7443
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7444
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7445
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7446
    self primitiveFailed.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7447
    ^ nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7448
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7449
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7450
setTextProperty:propertyID value:aString for:aWindowID
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7451
    ^ self setProperty:propertyID type:(self atomIDOfSTRING) value:aString for:aWindowID
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7452
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7453
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7454
setTextSelection:aString owner:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7455
    "set the text selection, and make aWindowId be the owner.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7456
     This can be used by any other X application."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7457
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7458
    (self setSelectionOwner:aWindowId of:primaryAtom) ifFalse:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7459
	'ownerchange failed' errorPrintNL.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7460
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7461
    ^ self setTextProperty:cutBuffer0Atom value:aString for:nil
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7462
! !
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7463
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7464
!XWorkstation methodsFor:'window stuff'!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7465
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7466
clearRectangleX:x y:y width:width height:height in:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7467
    "clear a rectangular area to viewbackground"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7468
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7469
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7470
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7471
    int w, h;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7472
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7473
    if (__isExternalAddress(aWindowId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7474
     && __bothSmallInteger(x, y)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7475
     && __bothSmallInteger(width, height)) {
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  7476
	w = __intVal(width);
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  7477
	h = __intVal(height);
1018
87ef43206c10 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  7478
	/*
87ef43206c10 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  7479
	 * need this check here: some servers simply dump core with bad args
87ef43206c10 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  7480
	 */
87ef43206c10 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  7481
	if ((w >= 0) && (h >= 0)) {
87ef43206c10 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  7482
	    XClearArea(myDpy, _WindowVal(aWindowId), __intVal(x), __intVal(y), w, h, 0);
87ef43206c10 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  7483
	}
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7484
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7485
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7486
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7487
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7488
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7489
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7490
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7491
clearWindow:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7492
    "clear a window to viewbackground"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7493
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7494
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7495
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7496
    if (__isExternalAddress(aWindowId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7497
	XClearWindow(myDpy, _WindowVal(aWindowId));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7498
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7499
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7500
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7501
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7502
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7503
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7504
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7505
configureWindow:aWindowId sibling:siblingId stackMode:modeSymbol
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7506
    "configure stacking operation of aWindowId w.r.t siblingId"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7507
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7508
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7509
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7510
    XWindowChanges chg;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7511
    int mask = CWSibling | CWStackMode;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7512
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7513
    if (__isExternalAddress(aWindowId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7514
     && __isExternalAddress(siblingId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7515
	if (modeSymbol == @symbol(above)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7516
	    chg.stack_mode = Above;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7517
	} else if (modeSymbol == @symbol(below)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7518
	    chg.stack_mode = Below;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7519
	} else if (modeSymbol == @symbol(topIf)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7520
	    chg.stack_mode = TopIf;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7521
	} else if (modeSymbol == @symbol(bottomIf)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7522
	    chg.stack_mode = BottomIf;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7523
	} else if (modeSymbol == @symbol(opposite)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7524
	    chg.stack_mode = Opposite;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7525
	} else {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7526
	    mask = CWSibling;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7527
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7528
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7529
	chg.sibling = _WindowVal(siblingId);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7530
	XConfigureWindow(myDpy, _WindowVal(aWindowId),
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7531
				mask, &chg);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7532
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7533
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7534
bad: ;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7535
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7536
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7537
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7538
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7539
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7540
lowerWindow:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7541
    "bring a window to back"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7542
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7543
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7544
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7545
    if (__isExternalAddress(aWindowId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7546
	XLowerWindow(myDpy, _WindowVal(aWindowId));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7547
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7548
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7549
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7550
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7551
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7552
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7553
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7554
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
  7555
    "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
  7556
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7557
    |wicon wiconId wiconView wiconViewId wlabel|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7558
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7559
    aBoolean ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7560
	wicon := aView icon.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7561
	wicon notNil ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7562
	    wiconId := wicon id
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7563
	].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7564
	wiconView := aView iconView.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7565
	wiconView notNil ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7566
	    wiconViewId := wiconView id
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7567
	].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7568
	wlabel := aView label.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7569
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7570
%{  
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7571
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7572
    XWMHints wmhints;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7573
    XSizeHints szhints;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7574
    Display *dpy = myDpy;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7575
    Window win;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7576
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7577
    if (__isExternalAddress(aWindowId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7578
	win = _WindowVal(aWindowId);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7579
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7580
	szhints.flags = 0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7581
	if (__bothSmallInteger(xPos, yPos)) {
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  7582
	    szhints.x = __intVal(xPos);
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  7583
	    szhints.y = __intVal(yPos);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7584
	    szhints.flags |= USPosition;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7585
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7586
	if (__bothSmallInteger(w, h)) {
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  7587
	    szhints.width = __intVal(w);
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  7588
	    szhints.height = __intVal(h);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7589
	    szhints.flags |= USSize;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7590
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7591
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7592
	if (aBoolean == true) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7593
	    char *windowName;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7594
	    Pixmap iconBitmap = (Pixmap)0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7595
	    Window iconWindow;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7596
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7597
	    if (__isExternalAddress(wiconId))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7598
		iconBitmap = _PixmapVal(wiconId);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7599
	    else
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7600
		iconBitmap = (Pixmap)0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7601
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7602
	    if (__isExternalAddress(wiconViewId))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7603
		iconWindow = _WindowVal(wiconViewId);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7604
	    else
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7605
		iconWindow = (Window)0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7606
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7607
	    if (__isString(wlabel) || __isSymbol(wlabel))
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7608
		windowName = (char *)_stringVal(wlabel);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7609
	    else
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7610
		windowName = "";
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7611
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7612
	    if (iconBitmap || windowName) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7613
		XSetStandardProperties(dpy, win,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7614
					windowName, windowName,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7615
					iconBitmap,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7616
					0, 0, &szhints);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7617
	    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7618
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7619
	    wmhints.flags = 0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7620
	    if (iconBitmap) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7621
		wmhints.flags |= IconPixmapHint;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7622
		wmhints.icon_pixmap = iconBitmap;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7623
	    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7624
	    if (iconWindow) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7625
		wmhints.flags |= IconWindowHint;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7626
		wmhints.icon_window = iconWindow;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7627
	    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7628
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7629
	    wmhints.initial_state = IconicState;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7630
	    wmhints.flags |= StateHint;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7631
	    XSetWMHints(dpy, win, &wmhints);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7632
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7633
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7634
	if (szhints.flags) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7635
	    XSetNormalHints(dpy, win, &szhints);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7636
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7637
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7638
	XMapWindow(dpy, win);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7639
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7640
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7641
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7642
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7643
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7644
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7645
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7646
mapWindow:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7647
    "make a window visible"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7648
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7649
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7650
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7651
    if (__isExternalAddress(aWindowId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7652
	XMapWindow(myDpy, _WindowVal(aWindowId));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7653
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7654
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7655
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7656
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7657
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7658
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7659
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7660
moveResizeWindow:aWindowId x:x y:y width:w height:h
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7661
    "move and resize a window"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7662
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7663
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7664
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7665
    int newWidth, newHeight;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7666
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7667
    if (__isExternalAddress(aWindowId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7668
     && __bothSmallInteger(w, h)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7669
     && __bothSmallInteger(x, y)) {
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  7670
	newWidth = __intVal(w);
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  7671
	newHeight = __intVal(h);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7672
	if (newWidth < 1) newWidth = 1;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7673
	if (newHeight < 1) newHeight = 1;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7674
	XMoveResizeWindow(myDpy, _WindowVal(aWindowId),
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  7675
			      __intVal(x), __intVal(y),
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7676
			      newWidth, newHeight);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7677
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7678
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7679
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7680
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7681
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7682
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7683
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7684
moveWindow:aWindowId x:x y:y
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7685
    "move a window"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7686
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7687
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7688
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7689
    if (__isExternalAddress(aWindowId) && __bothSmallInteger(x, y)) {
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  7690
	XMoveWindow(myDpy, _WindowVal(aWindowId), __intVal(x), __intVal(y));
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7691
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7692
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7693
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7694
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7695
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7696
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7697
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7698
raiseWindow:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7699
    "bring a window to front"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7700
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7701
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7702
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7703
    if (__isExternalAddress(aWindowId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7704
	XRaiseWindow(myDpy, _WindowVal(aWindowId));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7705
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7706
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7707
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7708
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7709
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7710
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7711
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7712
resizeWindow:aWindowId width:w height:h
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7713
    "resize a window"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7714
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7715
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7716
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7717
    int newWidth, newHeight;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7718
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7719
    if (__isExternalAddress(aWindowId) && __bothSmallInteger(w, h)) {
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  7720
	newWidth = __intVal(w);
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  7721
	newHeight = __intVal(h);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7722
	if (newWidth < 1) newWidth = 1;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7723
	if (newHeight < 1) newHeight = 1;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7724
	XResizeWindow(myDpy, _WindowVal(aWindowId), newWidth, newHeight);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7725
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7726
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7727
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7728
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7729
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7730
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7731
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7732
setBackingStore:how in:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7733
    "turn on/off backing-store for a window"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7734
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7735
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7736
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7737
    XSetWindowAttributes wa;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7738
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7739
    if (__isExternalAddress(aWindowId)) {
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  7740
	if (__INST(ignoreBackingStore) != true) {
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7741
	    if (how == @symbol(always)) wa.backing_store = Always;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7742
	    else if (how == @symbol(whenMapped)) wa.backing_store = WhenMapped;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7743
	    else if (how == true) wa.backing_store = Always;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7744
	    else wa.backing_store = 0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7745
	    BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7746
	    XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWBackingStore, &wa);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7747
	    END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7748
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7749
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7750
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7751
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7752
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7753
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7754
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7755
setBitGravity:how in:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7756
    "set bit gravity for a window"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7757
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7758
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7759
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7760
    XSetWindowAttributes wa;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7761
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7762
    if (__isExternalAddress(aWindowId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7763
	if (how == @symbol(NorthWest)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7764
	    wa.bit_gravity = NorthWestGravity;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7765
	} else if (how == @symbol(NorthEast)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7766
	    wa.bit_gravity = NorthEastGravity;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7767
	} else if (how == @symbol(SouthWest)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7768
	    wa.bit_gravity = SouthWestGravity;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7769
	} else if (how == @symbol(SouthEast)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7770
	    wa.bit_gravity = SouthEastGravity;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7771
	} else if (how == @symbol(Center)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7772
	    wa.bit_gravity = CenterGravity;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7773
	} else if (how == @symbol(North)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7774
	    wa.bit_gravity = NorthGravity;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7775
	} else if (how == @symbol(South)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7776
	    wa.bit_gravity = SouthGravity;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7777
	} else if (how == @symbol(West)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7778
	    wa.bit_gravity = WestGravity;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7779
	} else if (how == @symbol(East)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7780
	    wa.bit_gravity = EastGravity;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7781
	} else {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7782
	    wa.bit_gravity = NorthWestGravity;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7783
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7784
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7785
	BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7786
	XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWBitGravity, &wa);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7787
	END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7788
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7789
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7790
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7791
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7792
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7793
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7794
setCursor:aCursorId in:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7795
    "define a windows cursor"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7796
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7797
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7798
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7799
    Display *dpy = myDpy;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7800
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7801
    if (__isExternalAddress(aWindowId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7802
     && __isExternalAddress(aCursorId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7803
	XDefineCursor(dpy, _WindowVal(aWindowId), _CursorVal(aCursorId));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7804
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7805
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7806
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7807
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7808
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7809
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7810
setIconName:aString in:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7811
    "define a windows iconname"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7812
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7813
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7814
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7815
    if (__isExternalAddress(aWindowId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7816
     && (__isString(aString) || __isSymbol(aString))) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7817
	XSetIconName(myDpy, _WindowVal(aWindowId), (char *)_stringVal(aString));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7818
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7819
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7820
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7821
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7822
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7823
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7824
setSaveUnder:yesOrNo in:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7825
    "turn on/off save-under for a window"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7826
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7827
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7828
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7829
    XSetWindowAttributes wa;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7830
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7831
    if (__isExternalAddress(aWindowId)) {
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  7832
	if (__INST(hasSaveUnder) == true) {
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7833
	    wa.save_under = (yesOrNo == true) ? 1 : 0;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7834
	    XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWSaveUnder, &wa);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7835
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7836
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7837
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7838
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7839
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7840
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7841
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7842
setTransient:aWindowId for:aMainWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7843
    "set aWindowId to be a transient of aMainWindow"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7844
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7845
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7846
353
5be3ae3c8838 sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
  7847
    if (__isExternalAddress(aWindowId)) {
5be3ae3c8838 sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
  7848
	Window w;
5be3ae3c8838 sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
  7849
5be3ae3c8838 sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
  7850
	if ((aMainWindowId == nil) || (aMainWindowId == __MKSMALLINT(0))) {
5be3ae3c8838 sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
  7851
	    w = (Window) 0;
5be3ae3c8838 sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
  7852
	} else {
374
17c544cc1fad commentary
Claus Gittinger <cg@exept.de>
parents: 366
diff changeset
  7853
	    if (__isExternalAddress(aMainWindowId)) {
353
5be3ae3c8838 sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
  7854
		w = _WindowVal(aMainWindowId);
5be3ae3c8838 sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
  7855
	    } else {
5be3ae3c8838 sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
  7856
		goto getOutOfHere;
5be3ae3c8838 sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
  7857
	    }
5be3ae3c8838 sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
  7858
	}
5be3ae3c8838 sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
  7859
	XSetTransientForHint(myDpy, _WindowVal(aWindowId), w);
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7860
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7861
    }
353
5be3ae3c8838 sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
  7862
 getOutOfHere: ;
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7863
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7864
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7865
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7866
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7867
setWindowBackground:aColorIndex in:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7868
    "set the windows background color. This is the color with which
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7869
     the view is filled whenever exposed. Do not confuse this with
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7870
     the background drawing color, which is used with opaque drawing."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7871
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7872
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7873
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7874
    if (__isExternalAddress(aWindowId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7875
     && __isSmallInteger(aColorIndex)) {
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  7876
	XSetWindowBackground(myDpy, _WindowVal(aWindowId), __intVal(aColorIndex));
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7877
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7878
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7879
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7880
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7881
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7882
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7883
setWindowBackgroundPixmap:aPixmapId in:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7884
    "set the windows background pattern to be a form.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7885
     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
  7886
     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
  7887
     with opaque drawing."
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7888
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7889
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7890
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7891
    if (__isExternalAddress(aWindowId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7892
     && __isExternalAddress(aPixmapId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7893
	XSetWindowBackgroundPixmap(myDpy, _WindowVal(aWindowId), _PixmapVal(aPixmapId));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7894
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7895
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7896
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7897
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7898
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7899
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7900
setWindowBorderColor:aColorIndex in:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7901
    "set the windows border color"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7902
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7903
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7904
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7905
    if (__isExternalAddress(aWindowId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7906
     && __isSmallInteger(aColorIndex)) {
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  7907
	XSetWindowBorder(myDpy, _WindowVal(aWindowId), __intVal(aColorIndex));
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7908
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7909
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7910
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7911
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7912
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7913
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7914
setWindowBorderPixmap:aPixmapId in:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7915
    "set the windows border pattern"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7916
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7917
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7918
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7919
    if (__isExternalAddress(aWindowId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7920
     && __isExternalAddress(aPixmapId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7921
	XSetWindowBorderPixmap(myDpy, _WindowVal(aWindowId), _PixmapVal(aPixmapId));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7922
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7923
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7924
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7925
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7926
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7927
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7928
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7929
setWindowBorderShape:aPixmapId in:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7930
    "set the windows border shape"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7931
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7932
    hasShapeExtension ifFalse:[^ self].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7933
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7934
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7935
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7936
#ifdef SHAPE
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7937
    if (__isExternalAddress(aWindowId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7938
     && __isExternalAddress(aPixmapId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7939
	XShapeCombineMask(myDpy, _WindowVal(aWindowId), ShapeBounding,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7940
			  0, 0, _PixmapVal(aPixmapId), ShapeSet);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7941
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7942
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7943
#endif
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7944
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7945
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7946
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7947
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7948
setWindowBorderWidth:aNumber in:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7949
    "set the windows border width"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7950
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7951
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7952
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7953
    if (__isExternalAddress(aWindowId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7954
     && __isSmallInteger(aNumber)) {
555
2705be333c5f underscore macro cleanup
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
  7955
	XSetWindowBorderWidth(myDpy, _WindowVal(aWindowId), __intVal(aNumber));
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7956
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7957
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7958
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7959
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7960
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7961
857
df5125310d86 New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents: 850
diff changeset
  7962
setWindowClass:wClass name:wName in:aWindowId
df5125310d86 New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents: 850
diff changeset
  7963
    "define class and name of a window.
df5125310d86 New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents: 850
diff changeset
  7964
     This may be used by the window manager to
df5125310d86 New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents: 850
diff changeset
  7965
     select client specific resources."
df5125310d86 New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents: 850
diff changeset
  7966
df5125310d86 New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents: 850
diff changeset
  7967
%{
df5125310d86 New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents: 850
diff changeset
  7968
    if (__isExternalAddress(aWindowId)) {
963
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  7969
	XClassHint classhint;
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  7970
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  7971
	classhint.res_class = classhint.res_name = 0;
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  7972
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  7973
	if (__isString(wClass) || __isSymbol(wClass)) {
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  7974
	    classhint.res_class = (char *)_stringVal(wClass);
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  7975
	} else if (wClass != nil)
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  7976
	    goto error;
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  7977
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  7978
	if (__isString(wName) || __isSymbol(wName)) {
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  7979
	    classhint.res_name = (char *)_stringVal(wName);
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  7980
	} else if (wName != nil)
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  7981
	    goto error;
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  7982
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  7983
	XSetClassHint(myDpy, _WindowVal(aWindowId), &classhint);
45ebbbb40f38 simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  7984
	RETURN ( self );
857
df5125310d86 New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents: 850
diff changeset
  7985
error:;
df5125310d86 New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents: 850
diff changeset
  7986
    }
df5125310d86 New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents: 850
diff changeset
  7987
%}.
df5125310d86 New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents: 850
diff changeset
  7988
    self primitiveFailed
df5125310d86 New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents: 850
diff changeset
  7989
!
df5125310d86 New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents: 850
diff changeset
  7990
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7991
setWindowGravity:how in:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7992
    "set window gravity for a window"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7993
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7994
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7995
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7996
    XSetWindowAttributes wa;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7997
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7998
    if (__isExternalAddress(aWindowId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  7999
	if (how == @symbol(NorthWest)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8000
	    wa.win_gravity = NorthWestGravity;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8001
	} else if (how == @symbol(NorthEast)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8002
	    wa.win_gravity = NorthEastGravity;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8003
	} else if (how == @symbol(SouthWest)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8004
	    wa.win_gravity = SouthWestGravity;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8005
	} else if (how == @symbol(SouthEast)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8006
	    wa.win_gravity = SouthEastGravity;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8007
	} else if (how == @symbol(Center)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8008
	    wa.win_gravity = CenterGravity;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8009
	} else if (how == @symbol(North)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8010
	    wa.win_gravity = NorthGravity;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8011
	} else if (how == @symbol(South)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8012
	    wa.win_gravity = SouthGravity;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8013
	} else if (how == @symbol(West)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8014
	    wa.win_gravity = WestGravity;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8015
	} else if (how == @symbol(East)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8016
	    wa.win_gravity = EastGravity;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8017
	} else {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8018
	    wa.win_gravity = NorthWestGravity;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8019
	}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8020
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8021
	BEGIN_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8022
	XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWWinGravity, &wa);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8023
	END_INTERRUPTSBLOCKED
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8024
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8025
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8026
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8027
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8028
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8029
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8030
setWindowIcon:aForm in:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8031
    "define a bitmap to be used as icon"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8032
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8033
    |iconId|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8034
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8035
    aForm notNil ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8036
	iconId := aForm id
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8037
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8038
%{
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8039
    if (__isExternalAddress(iconId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8040
     && __isExternalAddress(aWindowId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8041
	XWMHints hints;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8042
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8043
	hints.icon_pixmap = _PixmapVal(iconId);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8044
	hints.flags = IconPixmapHint;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8045
	XSetWMHints(myDpy, _WindowVal(aWindowId), &hints);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8046
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8047
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8048
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8049
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8050
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8051
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8052
setWindowIconWindow:aView in:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8053
    "define a window to be used as icon"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8054
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8055
    |iconWindowId|
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8056
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8057
    aView notNil ifTrue:[
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8058
	iconWindowId := aView id
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8059
    ].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8060
%{
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8061
    if (__isExternalAddress(iconWindowId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8062
     && __isExternalAddress(aWindowId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8063
	XWMHints wmhints;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8064
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8065
	wmhints.icon_window = _WindowVal(iconWindowId);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8066
	wmhints.flags = IconWindowHint;
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8067
	XSetWMHints(myDpy, _WindowVal(aWindowId), &wmhints);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8068
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8069
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8070
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8071
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8072
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8073
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8074
setWindowName:aString in:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8075
    "define a windows name"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8076
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8077
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8078
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8079
    if (__isExternalAddress(aWindowId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8080
     && (__isString(aString) || __isSymbol(aString))) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8081
	XStoreName(myDpy, _WindowVal(aWindowId), (char *)_stringVal(aString));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8082
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8083
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8084
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8085
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8086
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8087
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8088
setWindowShape:aPixmapId in:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8089
    "set the windows shape"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8090
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8091
    hasShapeExtension ifFalse:[^ self].
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8092
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8093
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8094
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8095
#ifdef SHAPE
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8096
    if (__isExternalAddress(aWindowId)
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8097
     && __isExternalAddress(aPixmapId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8098
	XShapeCombineMask(myDpy, _WindowVal(aWindowId), ShapeClip,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8099
			  0, 0,
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8100
			  _PixmapVal(aPixmapId), ShapeSet);
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8101
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8102
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8103
#endif
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8104
%}.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8105
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8106
!
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8107
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8108
unmapWindow:aWindowId
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8109
    "make a window invisible"
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8110
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8111
%{  /* NOCONTEXT */
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8112
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8113
    if (__isExternalAddress(aWindowId)) {
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8114
	XUnmapWindow(myDpy, _WindowVal(aWindowId));
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8115
	RETURN ( self );
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8116
    }
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8117
%}
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8118
.
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8119
    self primitiveFailed
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8120
! !
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8121
898
677e010d0cf8 exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents: 892
diff changeset
  8122
!XWorkstation  class methodsFor:'documentation'!
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8123
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8124
version
1049
59cc92776676 oops - free XGetAtomName string after use
Claus Gittinger <cg@exept.de>
parents: 1047
diff changeset
  8125
    ^ '$Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.171 1996-09-11 20:12:39 cg Exp $'
295
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8126
! !
08cd959204c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  8127
XWorkstation initialize!