annotate Gui/wm/ws.c @ 4283:44752bb9b6c0

Typo
author nick
date Sun, 20 Jan 2002 17:06:45 +0000
parents 38df49b91824
children a97f908988ed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
2 // --------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
3 // AutoSpace Window System for Linux/Win32 v0.85
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
4 // Writed by pontscho/fresh!mindworkz
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
5 // --------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
6
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
7 #include <X11/Xlib.h>
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
8 #include <X11/Xproto.h>
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
9 #include <X11/Xutil.h>
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
10 #include <X11/keysym.h>
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
11 #include <X11/Xatom.h>
2081
efcab819ac24 gcc3 warning fixed
arpi
parents: 2045
diff changeset
12
efcab819ac24 gcc3 warning fixed
arpi
parents: 2045
diff changeset
13 #include <stdio.h>
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
14 #include <stdlib.h>
2081
efcab819ac24 gcc3 warning fixed
arpi
parents: 2045
diff changeset
15 #include <string.h>
efcab819ac24 gcc3 warning fixed
arpi
parents: 2045
diff changeset
16 #include <unistd.h>
efcab819ac24 gcc3 warning fixed
arpi
parents: 2045
diff changeset
17 #include <errno.h>
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
18
2733
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
19 #include <inttypes.h>
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
20
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
21 #include "ws.h"
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
22 #include "wsconv.h"
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
23 #include "../../config.h"
2733
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
24 #include "../../postproc/rgb2rgb.h"
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
25
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
26 #include <X11/extensions/XShm.h>
2476
a6c5a537f30a a few warning fixes (missing #include's)
pl
parents: 2081
diff changeset
27 #ifdef HAVE_XSHAPE
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
28 #include <X11/extensions/shape.h>
2476
a6c5a537f30a a few warning fixes (missing #include's)
pl
parents: 2081
diff changeset
29 #endif
a6c5a537f30a a few warning fixes (missing #include's)
pl
parents: 2081
diff changeset
30
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
31 #include <sys/ipc.h>
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
32 #include <sys/shm.h>
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
33
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
34 typedef struct
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
35 {
3054
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
36 unsigned long flags;
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
37 unsigned long functions;
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
38 unsigned long decorations;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
39 long input_mode;
3054
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
40 unsigned long status;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
41 } MotifWmHints;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
42
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
43 Atom wsMotifHints;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
44
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
45 unsigned int wsMaxX = 0; // Screen width.
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
46 unsigned int wsMaxY = 0; // Screen height.
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
47
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
48 Display * wsDisplay;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
49 int wsScreen;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
50 Window wsRootWin;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
51 XEvent wsEvent;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
52 int wsWindowDepth;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
53 GC wsHGC;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
54 MotifWmHints wsMotifWmHints;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
55 Atom wsTextProperlyAtom = None;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
56
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
57 int wsDepthOnScreen = 0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
58 int wsRedMask = 0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
59 int wsGreenMask = 0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
60 int wsBlueMask = 0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
61 int wsOutMask = 0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
62
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
63 int wsTrue = True;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
64
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
65 wsTWindow * wsWindowList[5] = { NULL,NULL,NULL,NULL,NULL };
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
66 int wsWLCount = 0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
67
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
68 unsigned long wsKeyTable[512];
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
69
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
70 int wsUseXShm = 1;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
71 int wsUseXShape = 1;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
72
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
73 int XShmGetEventBase( Display* );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
74 inline int wsSearch( Window win );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
75
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
76 #define MWM_HINTS_FUNCTIONS (1L << 0)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
77 #define MWM_HINTS_DECORATIONS (1L << 1)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
78 #define MWM_HINTS_INPUT_MODE (1L << 2)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
79 #define MWM_HINTS_STATUS (1L << 3)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
80
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
81 #define MWM_FUNC_ALL (1L << 0)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
82 #define MWM_FUNC_RESIZE (1L << 1)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
83 #define MWM_FUNC_MOVE (1L << 2)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
84 #define MWM_FUNC_MINIMIZE (1L << 3)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
85 #define MWM_FUNC_MAXIMIZE (1L << 4)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
86 #define MWM_FUNC_CLOSE (1L << 5)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
87
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
88 #define MWM_DECOR_ALL (1L << 0)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
89 #define MWM_DECOR_BORDER (1L << 1)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
90 #define MWM_DECOR_RESIZEH (1L << 2)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
91 #define MWM_DECOR_TITLE (1L << 3)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
92 #define MWM_DECOR_MENU (1L << 4)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
93 #define MWM_DECOR_MINIMIZE (1L << 5)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
94 #define MWM_DECOR_MAXIMIZE (1L << 6)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
95
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
96 #define MWM_INPUT_MODELESS 0
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
97 #define MWM_INPUT_PRIMARY_APPLICATION_MODAL 1
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
98 #define MWM_INPUT_SYSTEM_MODAL 2
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
99 #define MWM_INPUT_FULL_APPLICATION_MODAL 3
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
100 #define MWM_INPUT_APPLICATION_MODAL MWM_INPUT_PRIMARY_APPLICATION_MODAL
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
101
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
102 #define MWM_TEAROFF_WINDOW (1L<<0)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
103
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
104 void wsWindowDecoration( wsTWindow * win,long d )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
105 {
3054
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
106 MotifWmHints *hints = &wsMotifWmHints;
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
107 Atom type;
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
108 int format;
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
109 unsigned long nitems;
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
110 unsigned long bytes_after;
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
111
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
112 wsMotifHints=XInternAtom( wsDisplay,"_MOTIF_WM_HINTS",0 );
3054
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
113 if ( wsMotifHints == None ) return;
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
114
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
115 #if 1
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
116 memset( &wsMotifWmHints,0,sizeof( MotifWmHints ) );
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
117 wsMotifWmHints.flags=( d?0:MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS );
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
118 wsMotifWmHints.functions=( d?0:MWM_FUNC_MOVE | MWM_FUNC_CLOSE | MWM_FUNC_MINIMIZE | MWM_FUNC_MAXIMIZE | MWM_FUNC_RESIZE );
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
119 wsMotifWmHints.decorations=( d?MWM_DECOR_ALL:0 );
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
120 XChangeProperty( wsDisplay,win->WindowID,wsMotifHints,wsMotifHints,32,
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
121 PropModeReplace,(unsigned char *)&wsMotifWmHints,5 );
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
122 #else
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
123 XGetWindowProperty( wsDisplay,win->WindowID,
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
124 wsMotifHints,0,5,
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
125 False,AnyPropertyType,&type,&format,&nitems,
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
126 &bytes_after,(unsigned char **)&hints );
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
127
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
128 if ( type != None )
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
129 {
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
130 fprintf( stderr,"[ws] set valid mwm hints.\n" );
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
131 hints->flags=MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS;
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
132 if ( d )
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
133 {
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
134 hints->functions|=( MWM_FUNC_MOVE | MWM_FUNC_CLOSE | MWM_FUNC_MINIMIZE | MWM_FUNC_MAXIMIZE | MWM_FUNC_RESIZE );
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
135 hints->decorations|=MWM_DECOR_ALL;
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
136 }
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
137 else
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
138 {
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
139 hints->functions|=~( MWM_FUNC_MOVE | MWM_FUNC_CLOSE | MWM_FUNC_MINIMIZE | MWM_FUNC_MAXIMIZE | MWM_FUNC_RESIZE );
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
140 hints->decorations|=~MWM_DECOR_ALL;
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
141 }
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
142 }
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
143 else
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
144 {
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
145 fprintf( stderr,"[ws] set my mwm hints.\n" );
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
146 memset( &wsMotifWmHints,0,sizeof( MotifWmHints ) );
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
147 hints=&wsMotifWmHints;
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
148 hints->flags=( d?MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS:0 );
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
149 hints->functions=( d?MWM_FUNC_MOVE | MWM_FUNC_CLOSE | MWM_FUNC_MINIMIZE | MWM_FUNC_MAXIMIZE | MWM_FUNC_RESIZE:0 );
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
150 hints->decorations=( d?MWM_DECOR_ALL:0 );
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
151 }
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
152
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
153 XChangeProperty( wsDisplay,win->WindowID,wsMotifHints,wsMotifHints,32,
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
154 PropModeReplace,&wsMotifWmHints,5 );
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
155 if ( hints != &wsMotifWmHints ) XFree( hints );
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
156 #endif
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
157 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
158
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
159 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
160 // Init X Window System.
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
161 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
162
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
163 int wsIOErrorHandler( Display * dpy )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
164 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
165 fprintf( stderr,"[ws] io error in display.\n" );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
166 exit( 0 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
167 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
168
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
169 int wsErrorHandler( Display * dpy,XErrorEvent * Event )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
170 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
171 char type[128];
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
172 XGetErrorText( wsDisplay,Event->error_code,type,128 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
173 fprintf(stderr,"[ws] Error in display.\n");
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
174 fprintf(stderr,"[ws] Error code: %d ( %s )\n",Event->error_code,type );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
175 fprintf(stderr,"[ws] Request code: %d\n",Event->request_code );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
176 fprintf(stderr,"[ws] Minor code: %d\n",Event->minor_code );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
177 exit( 0 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
178 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
179
1723
5e4214a7540e GUI stuff. now seeking works, and xmga renders to video window
arpi
parents: 1709
diff changeset
180 void wsXInit( void* mDisplay )
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
181 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
182 int eventbase;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
183 int errorbase;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
184
1723
5e4214a7540e GUI stuff. now seeking works, and xmga renders to video window
arpi
parents: 1709
diff changeset
185 if(mDisplay){
5e4214a7540e GUI stuff. now seeking works, and xmga renders to video window
arpi
parents: 1709
diff changeset
186 wsDisplay=mDisplay;
5e4214a7540e GUI stuff. now seeking works, and xmga renders to video window
arpi
parents: 1709
diff changeset
187 } else {
5e4214a7540e GUI stuff. now seeking works, and xmga renders to video window
arpi
parents: 1709
diff changeset
188 char * DisplayName = ":0.0";
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
189 if ( getenv( "DISPLAY" ) ) DisplayName=getenv( "DISPLAY" );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
190 wsDisplay=XOpenDisplay( DisplayName );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
191 if ( !wsDisplay )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
192 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
193 fprintf( stderr,"[ws] couldn't open the display !\n" );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
194 exit( 0 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
195 }
1723
5e4214a7540e GUI stuff. now seeking works, and xmga renders to video window
arpi
parents: 1709
diff changeset
196 }
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
197
1838
4984bd55518e add lgb's localhost detect
pontscho
parents: 1823
diff changeset
198 { /* on remote display XShm will be disabled - LGB */
4984bd55518e add lgb's localhost detect
pontscho
parents: 1823
diff changeset
199 char *dispname=DisplayString(wsDisplay);
4984bd55518e add lgb's localhost detect
pontscho
parents: 1823
diff changeset
200 int localdisp=1;
4984bd55518e add lgb's localhost detect
pontscho
parents: 1823
diff changeset
201 if (dispname&&*dispname!=':') {
4984bd55518e add lgb's localhost detect
pontscho
parents: 1823
diff changeset
202 localdisp=0;
4984bd55518e add lgb's localhost detect
pontscho
parents: 1823
diff changeset
203 wsUseXShm=0;
4984bd55518e add lgb's localhost detect
pontscho
parents: 1823
diff changeset
204 }
4984bd55518e add lgb's localhost detect
pontscho
parents: 1823
diff changeset
205 fprintf(stderr,"[ws] Display name: %s => %s display.\n",dispname,localdisp?"local":"REMOTE");
4984bd55518e add lgb's localhost detect
pontscho
parents: 1823
diff changeset
206 if (!localdisp) fprintf(stderr,"[ws] Remote display, disabling XMITSHM\n");
4984bd55518e add lgb's localhost detect
pontscho
parents: 1823
diff changeset
207 }
4984bd55518e add lgb's localhost detect
pontscho
parents: 1823
diff changeset
208
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
209 if ( !XShmQueryExtension( wsDisplay ) )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
210 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
211 fprintf( stderr,"[ws] sorry, your system is not supported X shared memory extension.\n" );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
212 wsUseXShm=0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
213 }
1699
7ddc63b84f1f DGA2 ifdefs, new mainloop/timer stuff
arpi
parents: 1693
diff changeset
214 #ifdef HAVE_XSHAPE
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
215 if ( !XShapeQueryExtension( wsDisplay,&eventbase,&errorbase ) )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
216 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
217 fprintf( stderr,"[ws] sorry, your system is not supported XShape extension.\n" );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
218 wsUseXShape=0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
219 }
1699
7ddc63b84f1f DGA2 ifdefs, new mainloop/timer stuff
arpi
parents: 1693
diff changeset
220 #else
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
221 wsUseXShape=0;
1699
7ddc63b84f1f DGA2 ifdefs, new mainloop/timer stuff
arpi
parents: 1693
diff changeset
222 #endif
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
223
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
224 XSynchronize( wsDisplay,True );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
225
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
226 wsScreen=DefaultScreen( wsDisplay );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
227 wsRootWin=RootWindow( wsDisplay,wsScreen );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
228 wsMaxX=DisplayWidth( wsDisplay,wsScreen );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
229 wsMaxY=DisplayHeight( wsDisplay,wsScreen );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
230
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
231 wsGetDepthOnScreen();
1699
7ddc63b84f1f DGA2 ifdefs, new mainloop/timer stuff
arpi
parents: 1693
diff changeset
232 #ifdef DEBUG
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
233 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
234 int minor,major,shp;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
235 fprintf( stderr,"[ws] Screen depth: %d\n",wsDepthOnScreen );
2029
41ed89701ece fix fucking icewm fullscreen bug.
pontscho
parents: 1860
diff changeset
236 fprintf( stderr,"[ws] size: %dx%d\n",wsMaxX,wsMaxY );
41ed89701ece fix fucking icewm fullscreen bug.
pontscho
parents: 1860
diff changeset
237 fprintf( stderr,"[ws] red mask: 0x%x\n",wsRedMask );
41ed89701ece fix fucking icewm fullscreen bug.
pontscho
parents: 1860
diff changeset
238 fprintf( stderr,"[ws] green mask: 0x%x\n",wsGreenMask );
41ed89701ece fix fucking icewm fullscreen bug.
pontscho
parents: 1860
diff changeset
239 fprintf( stderr,"[ws] blue mask: 0x%x\n",wsBlueMask );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
240 if ( wsUseXShm )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
241 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
242 XShmQueryVersion( wsDisplay,&major,&minor,&shp );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
243 fprintf( stderr,"[ws] XShm version is %d.%d\n",major,minor );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
244 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
245 #ifdef HAVE_XSHAPE
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
246 if ( wsUseXShape )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
247 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
248 XShapeQueryVersion( wsDisplay,&major,&minor );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
249 fprintf( stderr,"[ws] XShape version is %d.%d\n",major,minor );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
250 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
251 #endif
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
252 }
1699
7ddc63b84f1f DGA2 ifdefs, new mainloop/timer stuff
arpi
parents: 1693
diff changeset
253 #endif
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
254 initConverter();
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
255 wsOutMask=wsGetOutMask();
2733
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
256 #ifdef DEBUG
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
257 fprintf( stderr,"[ws] Initialized converter: " );
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
258 #endif
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
259 switch ( wsOutMask )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
260 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
261 case wsRGB32:
2733
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
262 #ifdef DEBUG
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
263 fprintf( stderr,"rgb32 to rgb32\n" );
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
264 #endif
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
265 wsConvFunc=BGR8880_to_RGB8880_c;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
266 break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
267 case wsBGR32:
2733
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
268 #ifdef DEBUG
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
269 fprintf( stderr,"rgb32 to bgr32\n" );
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
270 #endif
2782
b52d3e6ff4ab app michale's rgb32tobgr32
pontscho
parents: 2733
diff changeset
271 // wsConvFunc=BGR8880_to_BGR8880_c;
b52d3e6ff4ab app michale's rgb32tobgr32
pontscho
parents: 2733
diff changeset
272 wsConvFunc=rgb32tobgr32;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
273 break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
274 case wsRGB24:
2733
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
275 #ifdef DEBUG
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
276 fprintf( stderr,"rgb32 to rgb24\n" );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
277 #endif
2733
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
278 wsConvFunc=rgb32to24;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
279 break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
280 case wsBGR24:
2733
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
281 #ifdef DEBUG
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
282 fprintf( stderr,"rgb32 to bgr24\n" );
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
283 #endif
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
284 wsConvFunc=BGR8880_to_BGR888_c;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
285 break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
286 case wsRGB16:
2733
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
287 #ifdef DEBUG
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
288 fprintf( stderr,"rgb32 to rgb16\n" );
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
289 #endif
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
290 wsConvFunc=rgb32to16;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
291 break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
292 case wsBGR16:
2733
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
293 #ifdef DEBUG
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
294 fprintf( stderr,"rgb32 to bgr16\n" );
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
295 #endif
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
296 wsConvFunc=BGR8880_to_BGR565_c;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
297 break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
298 case wsRGB15:
2733
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
299 #ifdef DEBUG
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
300 fprintf( stderr,"rgb32 to rgb15\n" );
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
301 #endif
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
302 wsConvFunc=rgb32to15;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
303 break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
304 case wsBGR15:
2733
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
305 #ifdef DEBUG
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
306 fprintf( stderr,"rgb32 to bgr15\n" );
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
307 #endif
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
308 wsConvFunc=BGR8880_to_BGR555_c;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
309 break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
310 }
2981
4db0210755eb hm. kurva hibakezeles
pontscho
parents: 2854
diff changeset
311 // XSetIOErrorHandler( wsIOErrorHandler );
4db0210755eb hm. kurva hibakezeles
pontscho
parents: 2854
diff changeset
312 // XSetErrorHandler( wsErrorHandler );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
313 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
314
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
315 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
316 // Create window.
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
317 // X,Y : window position
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
318 // wX,wY : size of window
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
319 // bW : border width
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
320 // cV : visible mouse cursor on window
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
321 // D : visible frame, title, etc.
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
322 // sR : screen ratio
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
323 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
324
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
325 XClassHint wsClassHint;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
326 XTextProperty wsTextProperty;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
327 Window LeaderWindow;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
328
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
329 void wsCreateWindow( wsTWindow * win,int X,int Y,int wX,int hY,int bW,int cV,unsigned char D,char * label )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
330 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
331 win->Property=D;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
332 if ( D & wsShowFrame ) win->Decorations=1;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
333 wsHGC=DefaultGC( wsDisplay,wsScreen );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
334 // The window position and size.
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
335 switch ( X )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
336 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
337 case -1: win->X=( wsMaxX / 2 ) - ( wX / 2 ); break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
338 case -2: win->X=wsMaxX - wX - 1; break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
339 default: win->X=X; break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
340 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
341 switch ( Y )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
342 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
343 case -1: win->Y=( wsMaxY / 2 ) - ( hY / 2 ); break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
344 case -2: win->Y=wsMaxY - hY - 1; break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
345 default: win->Y=Y; break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
346 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
347 win->Width=wX;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
348 win->Height=hY;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
349 win->OldX=win->X;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
350 win->OldY=win->Y;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
351 win->OldWidth=win->Width;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
352 win->OldHeight=win->Height;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
353
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
354 // Border size for window.
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
355 win->BorderWidth=bW;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
356 // Hide Mouse Cursor
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
357 win->wsCursor=None;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
358 win->wsMouseEventType=cV;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
359 win->wsCursorData[0]=0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
360 win->wsCursorPixmap=XCreateBitmapFromData( wsDisplay,wsRootWin,win->wsCursorData,1,1 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
361 if ( !(cV & wsShowMouseCursor) ) win->wsCursor=XCreatePixmapCursor( wsDisplay,win->wsCursorPixmap,win->wsCursorPixmap,&win->wsColor,&win->wsColor,0,0 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
362
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
363 XGetWindowAttributes( wsDisplay,wsRootWin,&win->Attribs );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
364 if ( win->Attribs.depth < 15 )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
365 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
366 fprintf( stderr,"[ws] sorry, this color depth is not enough.\n" );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
367 exit( 0 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
368 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
369 XMatchVisualInfo( wsDisplay,wsScreen,win->Attribs.depth,TrueColor,&win->VisualInfo );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
370
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
371 // ---
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
372 win->AtomLeaderClient=XInternAtom( wsDisplay,"WM_CLIENT_LEADER",False );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
373 win->AtomDeleteWindow=XInternAtom( wsDisplay,"WM_DELETE_WINDOW",False );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
374 win->AtomTakeFocus=XInternAtom( wsDisplay,"WM_TAKE_FOCUS",False );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
375 win->AtomRolle=XInternAtom( wsDisplay,"WM_WINDOW_ROLE",False );
2851
b64fa5d25142 add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents: 2782
diff changeset
376 win->AtomWMSizeHint=XInternAtom( wsDisplay,"WM_SIZE_HINT",False );
b64fa5d25142 add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents: 2782
diff changeset
377 win->AtomWMNormalHint=XInternAtom( wsDisplay,"WM_NORMAL_HINT",False );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
378 win->AtomProtocols=XInternAtom( wsDisplay,"WM_PROTOCOLS",False );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
379 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
380 char buf[32]; int i;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
381 sprintf( buf,"_%s_REMOTE",label );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
382 for( i=0;i<strlen( buf );i++ )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
383 if ( ( buf[i] >= 'a' )&&( buf[i] <= 'z' ) ) buf[i]=buf[i] - 32;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
384 for( i=0;i<strlen( buf );i++ )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
385 if ( buf[i] == ' ' ) buf[i]='_';
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
386 fprintf( stderr,"[ws] atomname: %s\n",buf );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
387 win->AtomRemote=XInternAtom( wsDisplay,buf,False );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
388 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
389 win->AtomsProtocols[0]=win->AtomDeleteWindow;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
390 win->AtomsProtocols[1]=win->AtomTakeFocus;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
391 win->AtomsProtocols[2]=win->AtomRolle;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
392 // ---
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
393
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
394 // win->WindowAttrib.background_pixel=BlackPixel( wsDisplay,wsScreen );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
395 // win->WindowAttrib.border_pixel=BlackPixel( wsDisplay,wsScreen );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
396 win->WindowAttrib.background_pixel=BlackPixel( wsDisplay,wsScreen );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
397 win->WindowAttrib.border_pixel=WhitePixel( wsDisplay,wsScreen );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
398 win->WindowAttrib.colormap=XCreateColormap( wsDisplay,wsRootWin,win->VisualInfo.visual,AllocNone );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
399 win->WindowAttrib.event_mask=StructureNotifyMask | FocusChangeMask |
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
400 //SubstructureRedirectMask |
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
401 //SubstructureNotifyMask |
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
402 //ResizeRedirectMask |
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
403 //GCGraphicsExposures |
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
404 ExposureMask | PropertyChangeMask |
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
405 EnterWindowMask | LeaveWindowMask |
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
406 VisibilityChangeMask |
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
407 KeyPressMask | KeyReleaseMask;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
408 if ( ( cV & wsHandleMouseButton ) ) win->WindowAttrib.event_mask|=ButtonPressMask | ButtonReleaseMask;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
409 if ( ( cV & wsHandleMouseMove ) ) win->WindowAttrib.event_mask|=PointerMotionMask;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
410 win->WindowAttrib.cursor=win->wsCursor;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
411 win->WindowAttrib.override_redirect=False;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
412 if ( D & wsOverredirect ) win->WindowAttrib.override_redirect=True;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
413
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
414 // win->WindowAttrib.save_under=True;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
415 // win->WindowAttrib.do_not_propagate_mask = True;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
416
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
417 win->WindowMask=CWBackPixel | CWBorderPixel |
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
418 CWColormap | CWEventMask | CWCursor |
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
419 CWX | CWY | CWWidth | CWHeight |
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
420 CWOverrideRedirect;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
421
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
422 win->WindowID=XCreateWindow( wsDisplay,
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
423 (win->Parent != 0?win->Parent:wsRootWin),
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
424 win->X,win->Y,win->Width,win->Height,win->BorderWidth,
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
425 win->VisualInfo.depth,
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
426 InputOutput,
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
427 win->VisualInfo.visual,
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
428 win->WindowMask,&win->WindowAttrib );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
429
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
430 wsClassHint.res_name=label;
2029
41ed89701ece fix fucking icewm fullscreen bug.
pontscho
parents: 1860
diff changeset
431 wsClassHint.res_class="MPlayer";
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
432 XSetClassHint( wsDisplay,win->WindowID,&wsClassHint );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
433
2851
b64fa5d25142 add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents: 2782
diff changeset
434 win->SizeHint.flags=PPosition | PSize | PResizeInc | PWinGravity; // | PBaseSize
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
435 win->SizeHint.x=win->X;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
436 win->SizeHint.y=win->Y;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
437 win->SizeHint.width=win->Width;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
438 win->SizeHint.height=win->Height;
1860
c65abbc91c5c fix mwm bug's. faszom (C), and remove mixer.*
pontscho
parents: 1858
diff changeset
439 if ( D & wsMinSize )
c65abbc91c5c fix mwm bug's. faszom (C), and remove mixer.*
pontscho
parents: 1858
diff changeset
440 {
c65abbc91c5c fix mwm bug's. faszom (C), and remove mixer.*
pontscho
parents: 1858
diff changeset
441 win->SizeHint.flags|=PMinSize;
c65abbc91c5c fix mwm bug's. faszom (C), and remove mixer.*
pontscho
parents: 1858
diff changeset
442 win->SizeHint.min_width=win->Width;
c65abbc91c5c fix mwm bug's. faszom (C), and remove mixer.*
pontscho
parents: 1858
diff changeset
443 win->SizeHint.min_height=win->Height;
c65abbc91c5c fix mwm bug's. faszom (C), and remove mixer.*
pontscho
parents: 1858
diff changeset
444 }
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
445 if ( D & wsMaxSize )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
446 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
447 win->SizeHint.flags|=PMaxSize;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
448 win->SizeHint.max_width=win->Width;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
449 win->SizeHint.max_height=win->Height;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
450 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
451 win->SizeHint.height_inc=1;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
452 win->SizeHint.width_inc=1;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
453 // win->SizeHint.base_width=win->Width;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
454 // win->SizeHint.base_height=win->Height;
2851
b64fa5d25142 add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents: 2782
diff changeset
455 win->SizeHint.win_gravity=StaticGravity;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
456 XSetWMNormalHints( wsDisplay,win->WindowID,&win->SizeHint );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
457
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
458 win->WMHints.flags=InputHint | StateHint;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
459 win->WMHints.input=True;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
460 win->WMHints.initial_state=NormalState;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
461 XSetWMHints( wsDisplay,win->WindowID,&win->WMHints );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
462
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
463 wsWindowDecoration( win,win->Decorations );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
464 XStoreName( wsDisplay,win->WindowID,label );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
465 XmbSetWMProperties( wsDisplay,win->WindowID,label,label,NULL,0,NULL,NULL,NULL );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
466
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
467 XSetWMProtocols( wsDisplay,win->WindowID,win->AtomsProtocols,3 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
468 XChangeProperty( wsDisplay,win->WindowID,
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
469 win->AtomLeaderClient,
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
470 XA_WINDOW,32,PropModeReplace,
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
471 (unsigned char *)&LeaderWindow,1 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
472
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
473 wsTextProperty.value=label;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
474 wsTextProperty.encoding=XA_STRING;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
475 wsTextProperty.format=8;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
476 wsTextProperty.nitems=strlen( label );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
477 XSetWMIconName( wsDisplay,win->WindowID,&wsTextProperty );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
478
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
479 XChangeProperty( wsDisplay,win->WindowID,
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
480 win->AtomRemote,XA_STRING,
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
481 8,PropModeReplace,
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
482 "REALIZED",8 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
483
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
484 // win->Font=XLoadQueryFont( wsDisplay,"-adobe-helvetica-bold-r-normal--14-140-75-75-p-77-iso8859-1" );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
485 // -adobe-times-medium-r-normal--14-140-75-75-p-77-iso8859-1" );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
486 // -misc-fixed-bold-r-normal--13-120-75-75-C-80-iso8859-1" );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
487 // -misc-fixed-bold-r-normal--15-140-75-75-C-90-iso8859-1" );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
488 // -misc-fixed-medium-r-normal--15-140-75-75-C-90-iso8859-1" );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
489 // -adobe-times-medium-r-normal--24-240-75-75-p-124-iso8859-1" );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
490 // -adobe-helvetica-medium-r-normal--10-100-75-75-p-56-iso8859-1" );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
491 // -*-helvetica-bold-o-normal--14-*-*-*-p-*-iso8859-1" );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
492 // if ( !win->Font ) win->Font=XLoadQueryFont( wsDisplay,"fixed" );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
493 // if ( !win->Font )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
494 // {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
495 // fprintf( stderr,"[main] could not load font.\n" );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
496 // exit( 0 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
497 // }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
498 // win->FontHeight=win->Font->ascent + win->Font->descent;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
499 //
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
500 // #ifdef DEBUG
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
501 // fprintf( stderr,"[ws] font height: %d\n",win->FontHeight );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
502 // #endif
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
503
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
504 // win->wGCV.font=win->Font->fid;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
505 // win->wGCV.foreground=wsBlack;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
506 // win->wGCV.background=wsBlack;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
507
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
508 win->wGC=XCreateGC( wsDisplay,win->WindowID,
1814
9c674dc76ff3 add wsSetForegroundRGB
pontscho
parents: 1810
diff changeset
509 GCForeground | GCBackground,
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
510 &win->wGCV );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
511
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
512 win->Visible=0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
513 win->Focused=0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
514 win->Mapped=0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
515 win->Rolled=0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
516 if ( D & wsShowWindow ) XMapWindow( wsDisplay,win->WindowID );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
517
1858
88a88d0a3f94 fix skin changing, xv fullscreen redraw bug, etc.
pontscho
parents: 1853
diff changeset
518 wsCreateImage( win,win->Width,win->Height );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
519 // --- End of creating --------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
520
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
521 wsWindowList[wsWLCount++]=win;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
522
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
523 XFlush( wsDisplay );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
524 XSync( wsDisplay,False );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
525
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
526 win->ReDraw=NULL;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
527 win->ReSize=NULL;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
528 win->Idle=NULL;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
529 win->MouseHandler=NULL;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
530 win->KeyHandler=NULL;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
531 #ifdef DEBUG
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
532 fprintf( stderr,"[ws] window is created. ( %s ).\n",label );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
533 #endif
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
534 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
535
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
536 void wsDestroyWindow( wsTWindow * win )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
537 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
538 int l;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
539 l=wsSearch( win->WindowID );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
540 wsWindowList[l]=NULL;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
541 if ( win->wsCursor != None )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
542 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
543 XFreeCursor( wsDisplay,win->wsCursor );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
544 win->wsCursor=None;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
545 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
546 XUnmapWindow( wsDisplay,win->WindowID );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
547 wsDestroyImage( win );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
548 XDestroyWindow( wsDisplay,win->WindowID );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
549 win->ReDraw=NULL;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
550 win->ReSize=NULL;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
551 win->Idle=NULL;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
552 win->MouseHandler=NULL;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
553 win->KeyHandler=NULL;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
554 win->Visible=0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
555 win->Focused=0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
556 win->Mapped=0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
557 win->Rolled=0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
558 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
559
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
560 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
561 // Handle events.
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
562 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
563
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
564 inline int wsSearch( Window win )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
565 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
566 int i;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
567 for ( i=0;i<wsWLCount;i++ ) if ( wsWindowList[i]->WindowID == win ) return i;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
568 return -1;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
569 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
570
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
571 Bool wsEvents( Display * display,XEvent * Event,XPointer arg )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
572 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
573 KeySym keySym;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
574 unsigned long i = 0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
575 int l;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
576 int x,y;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
577 Window child_window = 0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
578
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
579 l=wsSearch( Event->xany.window );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
580 if ( l == -1 ) return !wsTrue;
1782
dce42eebfda4 win->state fix
pontscho
parents: 1779
diff changeset
581 wsWindowList[l]->State=0;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
582 switch( Event->type )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
583 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
584 case ClientMessage:
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
585 if ( Event->xclient.message_type == wsWindowList[l]->AtomProtocols )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
586 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
587 if ( Event->xclient.data.l[0] == wsWindowList[l]->AtomDeleteWindow )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
588 { wsTrue=False; break; }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
589 if ( Event->xclient.data.l[0] == wsWindowList[l]->AtomTakeFocus )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
590 { i=wsWindowFocusIn; wsWindowList[l]->Focused=wsFocused; goto expose; }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
591 if ( Event->xclient.data.l[0] == wsWindowList[l]->AtomRolle )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
592 { fprintf( stderr,"[ws] rolled.\n" ); }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
593 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
594 break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
595
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
596 // case CirculateRequest:fprintf( stderr,"[ws,r] win: 0x%x\n",(int)Event->xcirculaterequest.window ); break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
597 // case CirculateNotify: fprintf( stderr,"[ws,c] win: 0x%x\n",(int)Event->xcirculate.window ); break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
598
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
599 case MapNotify: i=wsWindowMapped; wsWindowList[l]->Mapped=wsMapped; goto expose;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
600 case UnmapNotify: i=wsWindowUnmapped; wsWindowList[l]->Mapped=wsNone; goto expose;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
601 case FocusIn:
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
602 if ( wsWindowList[l]->Focused == wsFocused ) break;
2851
b64fa5d25142 add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents: 2782
diff changeset
603 i=wsWindowFocusIn;
b64fa5d25142 add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents: 2782
diff changeset
604 wsWindowList[l]->Focused=wsFocused;
b64fa5d25142 add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents: 2782
diff changeset
605 goto expose;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
606 case FocusOut:
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
607 if ( wsWindowList[l]->Focused == wsNone ) break;
2851
b64fa5d25142 add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents: 2782
diff changeset
608 i=wsWindowFocusOut;
b64fa5d25142 add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents: 2782
diff changeset
609 wsWindowList[l]->Focused=wsNone;
b64fa5d25142 add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents: 2782
diff changeset
610 goto expose;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
611 case VisibilityNotify:
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
612 switch( Event->xvisibility.state )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
613 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
614 case VisibilityUnobscured: i=wsWindowVisible; wsWindowList[l]->Visible=wsVisible; goto expose;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
615 case VisibilityFullyObscured: i=wsWindowNotVisible; wsWindowList[l]->Visible=wsNotVisible; goto expose;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
616 case VisibilityPartiallyObscured: i=wsWindowPartialVisible; wsWindowList[l]->Visible=wsPVisible; goto expose;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
617 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
618 expose:
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
619 wsWindowList[l]->State=i;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
620 if ( wsWindowList[l]->ReDraw ) wsWindowList[l]->ReDraw( wsDisplay,Event->xany.window );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
621 break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
622
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
623 case Expose:
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
624 wsWindowList[l]->State=wsWindowExpose;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
625 if ( ( wsWindowList[l]->ReDraw )&&( !Event->xexpose.count ) ) wsWindowList[l]->ReDraw( wsDisplay,Event->xany.window );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
626 break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
627
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
628 case ConfigureNotify:
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
629 XTranslateCoordinates( wsDisplay,wsWindowList[l]->WindowID,wsRootWin,0,0,&x,&y,&child_window );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
630 if ( ( wsWindowList[l]->X != x )||( wsWindowList[l]->Y != y )||( wsWindowList[l]->Width != Event->xconfigure.width )||( wsWindowList[l]->Height != Event->xconfigure.height ) )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
631 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
632 wsWindowList[l]->X=x; wsWindowList[l]->Y=y;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
633 wsWindowList[l]->Width=Event->xconfigure.width; wsWindowList[l]->Height=Event->xconfigure.height;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
634 // fprintf( stderr,"[ws] resize: %d,%d %dx%d\n",wsWindowList[l]->X,wsWindowList[l]->Y,Event->xconfigure.width,Event->xconfigure.height );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
635 if ( wsWindowList[l]->ReSize ) wsWindowList[l]->ReSize( wsWindowList[l]->X,wsWindowList[l]->Y,wsWindowList[l]->Width,wsWindowList[l]->Height );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
636 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
637
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
638 wsWindowList[l]->Rolled=wsNone;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
639 if ( Event->xconfigure.y < 0 )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
640 { i=wsWindowRolled; wsWindowList[l]->Rolled=wsRolled; goto expose; }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
641
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
642 break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
643
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
644 case KeyPress: i=wsKeyPressed; goto keypressed;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
645 case KeyRelease: i=wsKeyReleased;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
646 keypressed:
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
647 wsWindowList[l]->Alt=0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
648 wsWindowList[l]->Shift=0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
649 wsWindowList[l]->NumLock=0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
650 wsWindowList[l]->Control=0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
651 wsWindowList[l]->CapsLock=0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
652 if ( Event->xkey.state & Mod1Mask ) wsWindowList[l]->Alt=1;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
653 if ( Event->xkey.state & Mod2Mask ) wsWindowList[l]->NumLock=1;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
654 if ( Event->xkey.state & ControlMask ) wsWindowList[l]->Control=1;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
655 if ( Event->xkey.state & ShiftMask ) wsWindowList[l]->Shift=1;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
656 if ( Event->xkey.state & LockMask ) wsWindowList[l]->CapsLock=1;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
657 keySym=XKeycodeToKeysym( wsDisplay,Event->xkey.keycode,0 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
658 if ( keySym != NoSymbol )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
659 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
660 keySym=( (keySym&0xff00) != 0?( (keySym&0x00ff) + 256 ):( keySym ) );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
661 wsKeyTable[ keySym ]=i;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
662 if ( wsWindowList[l]->KeyHandler )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
663 wsWindowList[l]->KeyHandler( Event->xkey.state,i,keySym );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
664 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
665 break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
666
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
667 case MotionNotify: i=wsMoveMouse; goto buttonreleased;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
668 case ButtonRelease: i=Event->xbutton.button + 128; goto buttonreleased;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
669 case ButtonPress: i=Event->xbutton.button; goto buttonreleased;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
670 case EnterNotify: i=wsEnterWindow; goto buttonreleased;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
671 case LeaveNotify: i=wsLeaveWindow;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
672 buttonreleased:
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
673 if ( wsWindowList[l]->MouseHandler )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
674 wsWindowList[l]->MouseHandler( i,Event->xbutton.x,Event->xbutton.y,Event->xmotion.x_root,Event->xmotion.y_root );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
675 break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
676
2851
b64fa5d25142 add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents: 2782
diff changeset
677 case GravityNotify:
b64fa5d25142 add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents: 2782
diff changeset
678 // #ifdef DEBUG
b64fa5d25142 add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents: 2782
diff changeset
679 fprintf( stderr,"[ws] window ( 0x%x ) gravity: %d,%d\n",wsWindowList[l]->WindowID,Event->xgravity.x,Event->xgravity.y );
b64fa5d25142 add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents: 2782
diff changeset
680 // #endif
b64fa5d25142 add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents: 2782
diff changeset
681 break;
b64fa5d25142 add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents: 2782
diff changeset
682
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
683 case PropertyNotify:
2851
b64fa5d25142 add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents: 2782
diff changeset
684 // break;
b64fa5d25142 add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents: 2782
diff changeset
685 // #ifdef DEBUG
2045
deb4aff05c44 fix other bugs
pontscho
parents: 2030
diff changeset
686 // fprintf(stderr,"[ws] PropertyNotify ( 0x%x ) %s ( 0x%x )\n",wsWindowList[l]->WindowID,XGetAtomName( wsDisplay,Event->xproperty.atom ),Event->xproperty.atom );
2851
b64fa5d25142 add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents: 2782
diff changeset
687 // #endif
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
688 if ( Event->xproperty.atom == wsWindowList[l]->AtomRemote )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
689 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
690 Atom type;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
691 int format;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
692 unsigned long nitems, bytesafter;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
693 unsigned char * args = NULL;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
694
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
695 // fprintf( stderr,"[ws] remote property notify.\n" );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
696 XGetWindowProperty( wsDisplay,
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
697 Event->xproperty.window,
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
698 Event->xproperty.atom,
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
699 0,( 65536 / sizeof( long ) ),
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
700 False,XA_STRING,
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
701 &type,&format,&nitems,&bytesafter,
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
702 &args );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
703 if ( ( nitems )&&( wsWindowList[l]->RemoteHandler ) )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
704 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
705 args[strlen( args ) - 1]=0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
706 wsWindowList[l]->RemoteHandler( args );
2851
b64fa5d25142 add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents: 2782
diff changeset
707 #ifdef DEBUG
b64fa5d25142 add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents: 2782
diff changeset
708 fprintf( stderr,"[ws] args: '%s'\n",args );
b64fa5d25142 add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents: 2782
diff changeset
709 #endif
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
710 args[strlen( args ) - 1]=1;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
711 XFree( args );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
712 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
713 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
714 break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
715
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
716 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
717 XFlush( wsDisplay );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
718 XSync( wsDisplay,False );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
719 return !wsTrue;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
720 // return True;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
721 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
722
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
723 Bool wsDummyEvents( Display * display,XEvent * Event,XPointer arg )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
724 { return True; }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
725
1709
a4e0211455d8 GUI integration, step 1
arpi
parents: 1701
diff changeset
726 // mplTimerHandler(0); // handle timer event
a4e0211455d8 GUI integration, step 1
arpi
parents: 1701
diff changeset
727 void wsHandleEvents(){
a4e0211455d8 GUI integration, step 1
arpi
parents: 1701
diff changeset
728 // handle pending events
a4e0211455d8 GUI integration, step 1
arpi
parents: 1701
diff changeset
729 while ( XPending(wsDisplay) ){
a4e0211455d8 GUI integration, step 1
arpi
parents: 1701
diff changeset
730 XNextEvent( wsDisplay,&wsEvent );
a4e0211455d8 GUI integration, step 1
arpi
parents: 1701
diff changeset
731 // printf("### X event: %d [%d]\n",wsEvent.type,delay);
a4e0211455d8 GUI integration, step 1
arpi
parents: 1701
diff changeset
732 wsEvents( wsDisplay,&wsEvent,NULL );
a4e0211455d8 GUI integration, step 1
arpi
parents: 1701
diff changeset
733 }
a4e0211455d8 GUI integration, step 1
arpi
parents: 1701
diff changeset
734 }
a4e0211455d8 GUI integration, step 1
arpi
parents: 1701
diff changeset
735
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
736 void wsMainLoop( void )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
737 {
1699
7ddc63b84f1f DGA2 ifdefs, new mainloop/timer stuff
arpi
parents: 1693
diff changeset
738 int delay=20;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
739 fprintf( stderr,"[ws] init threads: %d\n",XInitThreads() );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
740 XSynchronize( wsDisplay,False );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
741 XLockDisplay( wsDisplay );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
742 // XIfEvent( wsDisplay,&wsEvent,wsEvents,NULL );
1699
7ddc63b84f1f DGA2 ifdefs, new mainloop/timer stuff
arpi
parents: 1693
diff changeset
743
7ddc63b84f1f DGA2 ifdefs, new mainloop/timer stuff
arpi
parents: 1693
diff changeset
744 #if 1
7ddc63b84f1f DGA2 ifdefs, new mainloop/timer stuff
arpi
parents: 1693
diff changeset
745
7ddc63b84f1f DGA2 ifdefs, new mainloop/timer stuff
arpi
parents: 1693
diff changeset
746 while(wsTrue){
7ddc63b84f1f DGA2 ifdefs, new mainloop/timer stuff
arpi
parents: 1693
diff changeset
747 // handle pending events
7ddc63b84f1f DGA2 ifdefs, new mainloop/timer stuff
arpi
parents: 1693
diff changeset
748 while ( XPending(wsDisplay) ){
7ddc63b84f1f DGA2 ifdefs, new mainloop/timer stuff
arpi
parents: 1693
diff changeset
749 XNextEvent( wsDisplay,&wsEvent );
1701
7955814db4c7 removed delay debug printf, better 'active delay'
arpi
parents: 1699
diff changeset
750 // printf("### X event: %d [%d]\n",wsEvent.type,delay);
1699
7ddc63b84f1f DGA2 ifdefs, new mainloop/timer stuff
arpi
parents: 1693
diff changeset
751 wsEvents( wsDisplay,&wsEvent,NULL );
1701
7955814db4c7 removed delay debug printf, better 'active delay'
arpi
parents: 1699
diff changeset
752 delay=0;
1699
7ddc63b84f1f DGA2 ifdefs, new mainloop/timer stuff
arpi
parents: 1693
diff changeset
753 }
7ddc63b84f1f DGA2 ifdefs, new mainloop/timer stuff
arpi
parents: 1693
diff changeset
754 mplTimerHandler(0); // handle timer event
7ddc63b84f1f DGA2 ifdefs, new mainloop/timer stuff
arpi
parents: 1693
diff changeset
755 usleep(delay*1000); // FIXME!
1701
7955814db4c7 removed delay debug printf, better 'active delay'
arpi
parents: 1699
diff changeset
756 if(delay<10*20) delay+=20; // pump up delay up to 0.2 sec (low activity)
1699
7ddc63b84f1f DGA2 ifdefs, new mainloop/timer stuff
arpi
parents: 1693
diff changeset
757 }
7ddc63b84f1f DGA2 ifdefs, new mainloop/timer stuff
arpi
parents: 1693
diff changeset
758
7ddc63b84f1f DGA2 ifdefs, new mainloop/timer stuff
arpi
parents: 1693
diff changeset
759 #else
7ddc63b84f1f DGA2 ifdefs, new mainloop/timer stuff
arpi
parents: 1693
diff changeset
760
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
761 while( wsTrue )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
762 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
763 XIfEvent( wsDisplay,&wsEvent,wsDummyEvents,NULL );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
764 wsEvents( wsDisplay,&wsEvent,NULL );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
765 }
1699
7ddc63b84f1f DGA2 ifdefs, new mainloop/timer stuff
arpi
parents: 1693
diff changeset
766 #endif
7ddc63b84f1f DGA2 ifdefs, new mainloop/timer stuff
arpi
parents: 1693
diff changeset
767
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
768 XUnlockDisplay( wsDisplay );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
769 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
770
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
771 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
772 // Switch to fullscreen.
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
773 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
774 void wsFullScreen( wsTWindow * win )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
775 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
776 int decoration = 0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
777 XUnmapWindow( wsDisplay,win->WindowID );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
778 win->SizeHint.flags=0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
779 if ( win->isFullScreen )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
780 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
781 win->X=win->OldX;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
782 win->Y=win->OldY;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
783 win->Width=win->OldWidth;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
784 win->Height=win->OldHeight;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
785 win->isFullScreen=False;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
786 decoration=win->Decorations;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
787 wsScreenSaverOn( wsDisplay );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
788 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
789 else
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
790 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
791 win->OldX=win->X; win->OldY=win->Y;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
792 win->OldWidth=win->Width; win->OldHeight=win->Height;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
793 win->X=0; win->Y=0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
794 win->Width=wsMaxX; win->Height=wsMaxY;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
795 win->isFullScreen=True;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
796 wsScreenSaverOff( wsDisplay );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
797 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
798
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
799 win->SizeHint.flags|=PPosition | PSize;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
800 win->SizeHint.x=win->X;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
801 win->SizeHint.y=win->Y;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
802 win->SizeHint.width=win->Width;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
803 win->SizeHint.height=win->Height;
1860
c65abbc91c5c fix mwm bug's. faszom (C), and remove mixer.*
pontscho
parents: 1858
diff changeset
804 if ( win->Property & wsMaxSize )
c65abbc91c5c fix mwm bug's. faszom (C), and remove mixer.*
pontscho
parents: 1858
diff changeset
805 {
c65abbc91c5c fix mwm bug's. faszom (C), and remove mixer.*
pontscho
parents: 1858
diff changeset
806 win->SizeHint.flags|=PMaxSize;
c65abbc91c5c fix mwm bug's. faszom (C), and remove mixer.*
pontscho
parents: 1858
diff changeset
807 win->SizeHint.max_width=win->Width;
c65abbc91c5c fix mwm bug's. faszom (C), and remove mixer.*
pontscho
parents: 1858
diff changeset
808 win->SizeHint.max_height=win->Height;
c65abbc91c5c fix mwm bug's. faszom (C), and remove mixer.*
pontscho
parents: 1858
diff changeset
809 }
c65abbc91c5c fix mwm bug's. faszom (C), and remove mixer.*
pontscho
parents: 1858
diff changeset
810 if ( win->Property & wsMinSize )
c65abbc91c5c fix mwm bug's. faszom (C), and remove mixer.*
pontscho
parents: 1858
diff changeset
811 {
c65abbc91c5c fix mwm bug's. faszom (C), and remove mixer.*
pontscho
parents: 1858
diff changeset
812 win->SizeHint.flags|=PMinSize;
c65abbc91c5c fix mwm bug's. faszom (C), and remove mixer.*
pontscho
parents: 1858
diff changeset
813 win->SizeHint.min_width=win->Width;
c65abbc91c5c fix mwm bug's. faszom (C), and remove mixer.*
pontscho
parents: 1858
diff changeset
814 win->SizeHint.min_height=win->Height;
c65abbc91c5c fix mwm bug's. faszom (C), and remove mixer.*
pontscho
parents: 1858
diff changeset
815 }
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
816 XSetWMNormalHints( wsDisplay,win->WindowID,&win->SizeHint );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
817
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
818 XMoveResizeWindow( wsDisplay,win->WindowID,win->X,win->Y,win->Width,win->Height );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
819 wsWindowDecoration( win,decoration );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
820 XRaiseWindow( wsDisplay,win->WindowID );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
821 XMapWindow( wsDisplay,win->WindowID );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
822 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
823
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
824 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
825 // Redraw screen.
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
826 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
827 void wsPostRedisplay( wsTWindow * win )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
828 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
829 if ( win->ReDraw )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
830 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
831 win->ReDraw( wsDisplay,win->WindowID );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
832 XFlush( wsDisplay );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
833 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
834 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
835
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
836 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
837 // Do Exit.
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
838 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
839 void wsDoExit( void )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
840 { wsTrue=False; wsResizeWindow( wsWindowList[0],32,32 ); }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
841
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
842 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
843 // Put 'Image' to window.
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
844 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
845 void wsConvert( wsTWindow * win,unsigned char * Image,unsigned int Size )
2733
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
846 { if ( wsConvFunc ) wsConvFunc( Image,win->ImageData,win->xImage->width * win->xImage->height * 4 ); }
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
847
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
848 void wsPutImage( wsTWindow * win )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
849 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
850 if ( wsUseXShm )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
851 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
852 XShmPutImage( wsDisplay,win->WindowID,win->wGC,win->xImage,
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
853 0,0,
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
854 ( win->Width - win->xImage->width ) / 2,( win->Height - win->xImage->height ) / 2,
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
855 win->xImage->width,win->xImage->height,0 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
856 // win->Width,win->Height,0 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
857 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
858 else
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
859 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
860 XPutImage( wsDisplay,win->WindowID,win->wGC,win->xImage,
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
861 0,0,
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
862 ( win->Width - win->xImage->width ) / 2,( win->Height - win->xImage->height ) / 2,
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
863 win->xImage->width,win->xImage->height );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
864 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
865 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
866
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
867 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
868 // Move window to x, y.
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
869 // ----------------------------------------------------------------------------------------------
2854
fd44ecf77f8d move bug meg fileload bug fixed asszem.
pontscho
parents: 2851
diff changeset
870 void wsMoveWindow( wsTWindow * win,int b,int x, int y )
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
871 {
2854
fd44ecf77f8d move bug meg fileload bug fixed asszem.
pontscho
parents: 2851
diff changeset
872 if ( b )
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
873 {
2854
fd44ecf77f8d move bug meg fileload bug fixed asszem.
pontscho
parents: 2851
diff changeset
874 switch ( x )
fd44ecf77f8d move bug meg fileload bug fixed asszem.
pontscho
parents: 2851
diff changeset
875 {
fd44ecf77f8d move bug meg fileload bug fixed asszem.
pontscho
parents: 2851
diff changeset
876 case -1: win->X=( wsMaxX / 2 ) - ( win->Width / 2 ); break;
fd44ecf77f8d move bug meg fileload bug fixed asszem.
pontscho
parents: 2851
diff changeset
877 case -2: win->X=wsMaxX - win->Width; break;
fd44ecf77f8d move bug meg fileload bug fixed asszem.
pontscho
parents: 2851
diff changeset
878 default: win->X=x; break;
fd44ecf77f8d move bug meg fileload bug fixed asszem.
pontscho
parents: 2851
diff changeset
879 }
fd44ecf77f8d move bug meg fileload bug fixed asszem.
pontscho
parents: 2851
diff changeset
880 switch ( y )
fd44ecf77f8d move bug meg fileload bug fixed asszem.
pontscho
parents: 2851
diff changeset
881 {
fd44ecf77f8d move bug meg fileload bug fixed asszem.
pontscho
parents: 2851
diff changeset
882 case -1: win->Y=( wsMaxY / 2 ) - ( win->Height / 2 ); break;
fd44ecf77f8d move bug meg fileload bug fixed asszem.
pontscho
parents: 2851
diff changeset
883 case -2: win->Y=wsMaxY - win->Height; break;
fd44ecf77f8d move bug meg fileload bug fixed asszem.
pontscho
parents: 2851
diff changeset
884 default: win->Y=y; break;
fd44ecf77f8d move bug meg fileload bug fixed asszem.
pontscho
parents: 2851
diff changeset
885 }
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
886 }
2854
fd44ecf77f8d move bug meg fileload bug fixed asszem.
pontscho
parents: 2851
diff changeset
887 else { win->X=x; win->Y=y; }
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
888
2851
b64fa5d25142 add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents: 2782
diff changeset
889 win->SizeHint.flags=PPosition | PWinGravity;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
890 win->SizeHint.x=win->X;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
891 win->SizeHint.y=win->Y;
2851
b64fa5d25142 add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents: 2782
diff changeset
892 win->SizeHint.win_gravity=StaticGravity;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
893 XSetWMNormalHints( wsDisplay,win->WindowID,&win->SizeHint );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
894
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
895 XMoveWindow( wsDisplay,win->WindowID,win->X,win->Y );
1810
d44b0ce32791 fix move&resize
pontscho
parents: 1782
diff changeset
896 if ( win->ReSize ) win->ReSize( win->X,win->Y,win->Width,win->Height );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
897 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
898
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
899 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
900 // Resize window to sx, sy.
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
901 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
902 void wsResizeWindow( wsTWindow * win,int sx, int sy )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
903 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
904 win->Width=sx;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
905 win->Height=sy;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
906
2851
b64fa5d25142 add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents: 2782
diff changeset
907 win->SizeHint.flags=PSize | PWinGravity;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
908 win->SizeHint.width=win->Width;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
909 win->SizeHint.height=win->Height;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
910 if ( win->Property & wsMinSize )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
911 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
912 win->SizeHint.flags|=PMinSize;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
913 win->SizeHint.min_width=win->Width;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
914 win->SizeHint.min_height=win->Height;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
915 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
916 if ( win->Property & wsMaxSize )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
917 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
918 win->SizeHint.flags|=PMaxSize;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
919 win->SizeHint.max_width=win->Width;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
920 win->SizeHint.max_height=win->Height;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
921 }
2851
b64fa5d25142 add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents: 2782
diff changeset
922 win->SizeHint.win_gravity=StaticGravity;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
923 XSetWMNormalHints( wsDisplay,win->WindowID,&win->SizeHint );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
924 XResizeWindow( wsDisplay,win->WindowID,sx,sy );
1810
d44b0ce32791 fix move&resize
pontscho
parents: 1782
diff changeset
925 if ( win->ReSize ) win->ReSize( win->X,win->Y,win->Width,win->Height );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
926 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
927
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
928 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
929 // Iconify window.
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
930 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
931 void wsIconify( wsTWindow win )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
932 { XIconifyWindow( wsDisplay,win.WindowID,0 ); }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
933
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
934 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
935 // Move top the window.
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
936 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
937 void wsMoveTopWindow( wsTWindow * win )
2851
b64fa5d25142 add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents: 2782
diff changeset
938 {
b64fa5d25142 add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents: 2782
diff changeset
939 // XUnmapWindow( wsDisplay,win->WindowID ); XMapWindow( wsDisplay,win->WindowID );
b64fa5d25142 add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents: 2782
diff changeset
940 XRaiseWindow( wsDisplay,win->WindowID );
2045
deb4aff05c44 fix other bugs
pontscho
parents: 2030
diff changeset
941 }
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
942
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
943 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
944 // Set window background to 'color'.
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
945 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
946 void wsSetBackground( wsTWindow * win,int color )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
947 { XSetWindowBackground( wsDisplay,win->WindowID,color ); }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
948
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
949 void wsSetBackgroundRGB( wsTWindow * win,int r,int g,int b )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
950 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
951 int color = 0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
952 switch ( wsOutMask )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
953 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
954 case wsRGB32:
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
955 case wsRGB24: color=( r << 16 ) + ( g << 8 ) + b; break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
956 case wsBGR32:
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
957 case wsBGR24: color=( b << 16 ) + ( g << 8 ) + r; break;
2733
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
958 case wsRGB16: PACK_RGB16( b,g,r,color ); break;
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
959 case wsBGR16: PACK_RGB16( r,g,b,color ); break;
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
960 case wsRGB15: PACK_RGB15( b,g,r,color ); break;
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
961 case wsBGR15: PACK_RGB15( r,g,b,color ); break;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
962 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
963 XSetWindowBackground( wsDisplay,win->WindowID,color );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
964 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
965
1814
9c674dc76ff3 add wsSetForegroundRGB
pontscho
parents: 1810
diff changeset
966 void wsSetForegroundRGB( wsTWindow * win,int r,int g,int b )
9c674dc76ff3 add wsSetForegroundRGB
pontscho
parents: 1810
diff changeset
967 {
9c674dc76ff3 add wsSetForegroundRGB
pontscho
parents: 1810
diff changeset
968 int color = 0;
9c674dc76ff3 add wsSetForegroundRGB
pontscho
parents: 1810
diff changeset
969 switch ( wsOutMask )
9c674dc76ff3 add wsSetForegroundRGB
pontscho
parents: 1810
diff changeset
970 {
9c674dc76ff3 add wsSetForegroundRGB
pontscho
parents: 1810
diff changeset
971 case wsRGB32:
9c674dc76ff3 add wsSetForegroundRGB
pontscho
parents: 1810
diff changeset
972 case wsRGB24: color=( r << 16 ) + ( g << 8 ) + b; break;
9c674dc76ff3 add wsSetForegroundRGB
pontscho
parents: 1810
diff changeset
973 case wsBGR32:
9c674dc76ff3 add wsSetForegroundRGB
pontscho
parents: 1810
diff changeset
974 case wsBGR24: color=( b << 16 ) + ( g << 8 ) + r; break;
2733
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
975 case wsRGB16: PACK_RGB16( b,g,r,color ); break;
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
976 case wsBGR16: PACK_RGB16( r,g,b,color ); break;
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
977 case wsRGB15: PACK_RGB15( b,g,r,color ); break;
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
978 case wsBGR15: PACK_RGB15( r,g,b,color ); break;
1814
9c674dc76ff3 add wsSetForegroundRGB
pontscho
parents: 1810
diff changeset
979 }
9c674dc76ff3 add wsSetForegroundRGB
pontscho
parents: 1810
diff changeset
980 XSetForeground( wsDisplay,win->wGC,color );
9c674dc76ff3 add wsSetForegroundRGB
pontscho
parents: 1810
diff changeset
981 }
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
982
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
983 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
984 // Draw string at x,y with fc ( foreground color ) and bc ( background color ).
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
985 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
986 void wsDrawString( wsTWindow win,int x,int y,char * str,int fc,int bc )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
987 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
988 XSetForeground( wsDisplay,win.wGC,bc );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
989 XFillRectangle( wsDisplay,win.WindowID,win.wGC,x,y,
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
990 XTextWidth( win.Font,str,strlen( str ) ) + 20,
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
991 win.FontHeight + 2 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
992 XSetForeground( wsDisplay,win.wGC,fc );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
993 XDrawString( wsDisplay,win.WindowID,win.wGC,x + 10,y + 13,str,strlen( str ) );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
994 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
995
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
996 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
997 // Calculation string width.
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
998 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
999 int wsTextWidth( wsTWindow win,char * str )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1000 { return XTextWidth( win.Font,str,strlen( str ) ) + 20; }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1001
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1002 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1003 // Show / hide mouse cursor.
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1004 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1005 void wsVisibleMouse( wsTWindow * win,int m )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1006 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1007 switch ( m )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1008 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1009 case wsShowMouseCursor:
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1010 if ( win->wsCursor != None )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1011 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1012 XFreeCursor( wsDisplay,win->wsCursor );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1013 win->wsCursor=None;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1014 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1015 XDefineCursor( wsDisplay,win->WindowID,0 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1016 break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1017 case wsHideMouseCursor:
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1018 win->wsCursor=XCreatePixmapCursor( wsDisplay,win->wsCursorPixmap,win->wsCursorPixmap,&win->wsColor,&win->wsColor,0,0 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1019 XDefineCursor( wsDisplay,win->WindowID,win->wsCursor );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1020 break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1021 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1022 XFlush( wsDisplay );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1023 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1024
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1025 int wsGetDepthOnScreen( void )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1026 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1027 int bpp,ibpp;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1028 XImage * mXImage;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1029 XWindowAttributes attribs;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1030
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1031 mXImage=XGetImage( wsDisplay,wsRootWin,0,0,1,1,AllPlanes,ZPixmap );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1032 bpp=mXImage->bits_per_pixel;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1033
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1034 XGetWindowAttributes( wsDisplay,wsRootWin,&attribs );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1035 ibpp=attribs.depth;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1036 mXImage=XGetImage( wsDisplay,wsRootWin,0,0,1,1,AllPlanes,ZPixmap );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1037 bpp=mXImage->bits_per_pixel;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1038 if ( ( ibpp + 7 ) / 8 != ( bpp + 7 ) / 8 ) ibpp=bpp;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1039 wsDepthOnScreen=ibpp;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1040 wsRedMask=mXImage->red_mask;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1041 wsGreenMask=mXImage->green_mask;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1042 wsBlueMask=mXImage->blue_mask;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1043 XDestroyImage( mXImage );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1044 return ibpp;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1045 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1046
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1047 void wsXDone( void )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1048 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1049 XCloseDisplay( wsDisplay );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1050 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1051
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1052 void wsVisibleWindow( wsTWindow * win,int show )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1053 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1054 switch( show )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1055 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1056 case wsShowWindow: XMapWindow( wsDisplay,win->WindowID ); break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1057 case wsHideWindow: XUnmapWindow( wsDisplay,win->WindowID ); break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1058 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1059 XFlush( wsDisplay );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1060 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1061
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1062 void wsDestroyImage( wsTWindow * win )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1063 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1064 if ( win->xImage )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1065 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1066 XDestroyImage( win->xImage );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1067 if ( wsUseXShm )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1068 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1069 XShmDetach( wsDisplay,&win->Shminfo );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1070 shmdt( win->Shminfo.shmaddr );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1071 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1072 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1073 win->xImage=NULL;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1074 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1075
1858
88a88d0a3f94 fix skin changing, xv fullscreen redraw bug, etc.
pontscho
parents: 1853
diff changeset
1076 void wsCreateImage( wsTWindow * win,int Width,int Height )
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1077 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1078 int CompletionType = -1;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1079 if ( wsUseXShm )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1080 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1081 CompletionType=XShmGetEventBase( wsDisplay ) + ShmCompletion;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1082 win->xImage=XShmCreateImage( wsDisplay,win->VisualInfo.visual,
1858
88a88d0a3f94 fix skin changing, xv fullscreen redraw bug, etc.
pontscho
parents: 1853
diff changeset
1083 win->Attribs.depth,ZPixmap,NULL,&win->Shminfo,Width,Height );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1084 if ( win->xImage == NULL )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1085 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1086 fprintf( stderr,"[ws] shared memory extension error.\n" );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1087 exit( 0 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1088 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1089 // #ifdef DEBUG
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1090 // fprintf( stderr,"[ws] Screen depth: %d\n",win->xImage->bits_per_pixel );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1091 // #endif
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1092 win->Shminfo.shmid=shmget( IPC_PRIVATE,win->xImage->bytes_per_line * win->xImage->height,IPC_CREAT|0777 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1093 if ( win->Shminfo.shmid < 0 )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1094 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1095 XDestroyImage( win->xImage );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1096 fprintf( stderr,"[ws] shared memory extension error.\n" );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1097 exit( 0 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1098 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1099 win->Shminfo.shmaddr=(char *)shmat( win->Shminfo.shmid,0,0 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1100
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1101 if ( win->Shminfo.shmaddr == ((char *) -1) )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1102 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1103 XDestroyImage( win->xImage );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1104 if ( win->Shminfo.shmaddr != ((char *) -1) ) shmdt( win->Shminfo.shmaddr );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1105 fprintf( stderr,"[ws] shared memory extension error.\n" );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1106 exit( 0 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1107 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1108 win->xImage->data=win->Shminfo.shmaddr;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1109 win->Shminfo.readOnly=0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1110 XShmAttach( wsDisplay,&win->Shminfo );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1111 shmctl( win->Shminfo.shmid,IPC_RMID,0 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1112 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1113 else
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1114 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1115 win->xImage=XCreateImage( wsDisplay,win->VisualInfo.visual,win->Attribs.depth,
1858
88a88d0a3f94 fix skin changing, xv fullscreen redraw bug, etc.
pontscho
parents: 1853
diff changeset
1116 ZPixmap,0,0,Width,Height,
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1117 (wsDepthOnScreen == 3) ? 32 : wsDepthOnScreen,
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1118 0 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1119 if ( ( win->xImage->data=malloc( win->xImage->bytes_per_line * win->xImage->height ) ) == NULL )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1120 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1121 fprintf( stderr,"[ws] sorry, not enough memory for draw buffer.\n" );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1122 exit( 0 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1123 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1124 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1125 win->ImageData=(unsigned char *)win->xImage->data;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1126 win->ImageDataw=(unsigned short int *)win->xImage->data;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1127 win->ImageDatadw=(unsigned int *)win->xImage->data;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1128 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1129
1858
88a88d0a3f94 fix skin changing, xv fullscreen redraw bug, etc.
pontscho
parents: 1853
diff changeset
1130 void wsResizeImage( wsTWindow * win,int Width,int Height )
88a88d0a3f94 fix skin changing, xv fullscreen redraw bug, etc.
pontscho
parents: 1853
diff changeset
1131 { wsDestroyImage( win ); wsCreateImage( win,Width,Height ); }
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1132
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1133 int wsGetOutMask( void )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1134 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1135 if ( ( wsDepthOnScreen == 32 )&&( wsRedMask == 0xff0000 )&&( wsGreenMask == 0x00ff00 )&&( wsBlueMask == 0x0000ff ) ) return wsRGB32;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1136 if ( ( wsDepthOnScreen == 32 )&&( wsRedMask == 0x0000ff )&&( wsGreenMask == 0x00ff00 )&&( wsBlueMask == 0xff0000 ) ) return wsBGR32;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1137 if ( ( wsDepthOnScreen == 24 )&&( wsRedMask == 0xff0000 )&&( wsGreenMask == 0x00ff00 )&&( wsBlueMask == 0x0000ff ) ) return wsRGB24;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1138 if ( ( wsDepthOnScreen == 24 )&&( wsRedMask == 0x0000ff )&&( wsGreenMask == 0x00ff00 )&&( wsBlueMask == 0xff0000 ) ) return wsBGR24;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1139 if ( ( wsDepthOnScreen == 16 )&&( wsRedMask == 0xf800 )&&( wsGreenMask == 0x7e0 )&&( wsBlueMask == 0x1f ) ) return wsRGB16;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1140 if ( ( wsDepthOnScreen == 16 )&&( wsRedMask == 0x1f )&&( wsGreenMask == 0x7e0 )&&( wsBlueMask == 0xf800 ) ) return wsBGR16;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1141 if ( ( wsDepthOnScreen == 15 )&&( wsRedMask == 0x7c00 )&&( wsGreenMask == 0x3e0 )&&( wsBlueMask == 0x1f ) ) return wsRGB15;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1142 if ( ( wsDepthOnScreen == 15 )&&( wsRedMask == 0x1f )&&( wsGreenMask == 0x3e0 )&&( wsBlueMask == 0x7c00 ) ) return wsBGR15;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1143 return 0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1144 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1145
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1146 void wsSetTitle( wsTWindow * win,char * name )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1147 { XStoreName( wsDisplay,win->WindowID,name ); }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1148
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1149 void wsSetMousePosition( wsTWindow * win,int x, int y )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1150 { XWarpPointer( wsDisplay,wsRootWin,win->WindowID,0,0,0,0,x,y ); }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1151
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1152 static int dpms_disabled=0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1153 static int timeout_save=0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1154
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1155 void wsScreenSaverOn( Display *mDisplay )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1156 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1157 int nothing;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1158 if ( dpms_disabled )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1159 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1160 if ( DPMSQueryExtension( mDisplay,&nothing,&nothing ) )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1161 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1162 if ( !DPMSEnable( mDisplay ) ) fprintf( stderr,"DPMS not available ?\n" ); // restoring power saving settings
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1163 else
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1164 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1165 // DPMS does not seem to be enabled unless we call DPMSInfo
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1166 BOOL onoff;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1167 CARD16 state;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1168 DPMSInfo( mDisplay,&state,&onoff );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1169 if ( onoff ) fprintf( stderr,"Successfully enabled DPMS.\n" );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1170 else fprintf( stderr,"Could not enable DPMS.\n" );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1171 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1172 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1173 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1174
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1175 if ( timeout_save )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1176 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1177 int dummy, interval, prefer_blank, allow_exp;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1178 XGetScreenSaver( mDisplay,&dummy,&interval,&prefer_blank,&allow_exp );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1179 XSetScreenSaver( mDisplay,timeout_save,interval,prefer_blank,allow_exp );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1180 XGetScreenSaver( mDisplay,&timeout_save,&interval,&prefer_blank,&allow_exp );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1181 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1182 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1183
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1184 void wsScreenSaverOff( Display * mDisplay )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1185 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1186 int interval,prefer_blank,allow_exp,nothing;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1187
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1188 if ( DPMSQueryExtension( mDisplay,&nothing,&nothing ) )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1189 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1190 BOOL onoff;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1191 CARD16 state;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1192 DPMSInfo( mDisplay,&state,&onoff );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1193 if ( onoff )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1194 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1195 Status stat;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1196 fprintf( stderr,"Disabling DPMS.\n" );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1197 dpms_disabled=1;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1198 stat=DPMSDisable( mDisplay ); // monitor powersave off
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1199 fprintf( stderr,"stat: %d.\n",stat );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1200 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1201 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1202 XGetScreenSaver( mDisplay,&timeout_save,&interval,&prefer_blank,&allow_exp );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1203 if ( timeout_save ) XSetScreenSaver( mDisplay,0,interval,prefer_blank,allow_exp ); // turning off screensaver
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1204 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1205
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1206 void wsSetShape( wsTWindow * win,char * data )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1207 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1208 #ifdef HAVE_XSHAPE
1852
58dd326fcc4a fix xshape, mixer, fullscreen, etc
pontscho
parents: 1850
diff changeset
1209 if ( !wsUseXShape ) return;
58dd326fcc4a fix xshape, mixer, fullscreen, etc
pontscho
parents: 1850
diff changeset
1210 if ( data )
58dd326fcc4a fix xshape, mixer, fullscreen, etc
pontscho
parents: 1850
diff changeset
1211 {
58dd326fcc4a fix xshape, mixer, fullscreen, etc
pontscho
parents: 1850
diff changeset
1212 win->Mask=XCreateBitmapFromData( wsDisplay,win->WindowID,data,win->Width,win->Height );
58dd326fcc4a fix xshape, mixer, fullscreen, etc
pontscho
parents: 1850
diff changeset
1213 XShapeCombineMask( wsDisplay,win->WindowID,ShapeBounding,0,0,win->Mask,ShapeSet );
58dd326fcc4a fix xshape, mixer, fullscreen, etc
pontscho
parents: 1850
diff changeset
1214 XFreePixmap( wsDisplay,win->Mask );
58dd326fcc4a fix xshape, mixer, fullscreen, etc
pontscho
parents: 1850
diff changeset
1215 }
58dd326fcc4a fix xshape, mixer, fullscreen, etc
pontscho
parents: 1850
diff changeset
1216 else XShapeCombineMask( wsDisplay,win->WindowID,ShapeBounding,0,0,None,ShapeSet );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1217 #endif
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1218 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1219
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1220 #include "wsmkeys.h"