annotate Gui/wm/ws.c @ 5013:52c008dd6e93

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