annotate Gui/wm/ws.c @ 11928:7d603ceb4ac1

new filter: vf_noformat. like vf_format, but in reverse. this time I committed the filter, too. :)
author joey
date Fri, 06 Feb 2004 20:44:09 +0000
parents 85e503ddf65f
children 94e66acdb706
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"
8864
b8c271750450 - sync with x11_common
pontscho
parents: 8478
diff changeset
22 #include "../../libvo/x11_common.h"
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
23 #include "ws.h"
6967
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents: 6794
diff changeset
24 #include "wsxdnd.h"
10170
2f9e8ff57e9e This could be a 10l, but the codes check later if the wsConvFunc is valid, so no sig11 if it's NULL, but at least no XShape support on PPC :) After all, finally the GUI works on my PPC!%#^^
alex
parents: 9317
diff changeset
25 #include "../../cpudetect.h"
2f9e8ff57e9e This could be a 10l, but the codes check later if the wsConvFunc is valid, so no sig11 if it's NULL, but at least no XShape support on PPC :) After all, finally the GUI works on my PPC!%#^^
alex
parents: 9317
diff changeset
26 #include "../../postproc/swscale.h"
2733
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
27 #include "../../postproc/rgb2rgb.h"
10233
35f52ad860a0 vf_scale.h & related cleanup & some small warning fix by dominik
michael
parents: 10194
diff changeset
28 #include "../../libmpcodecs/vf_scale.h"
5919
60cf2bca993f some bug fix
pontscho
parents: 5910
diff changeset
29 #include "../../mp_msg.h"
5997
b5fb9a927bf3 add WM detection, and wm specific fullscreen code. (???)
pontscho
parents: 5986
diff changeset
30 #include "../../mplayer.h"
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
31
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
32 #include <X11/extensions/XShm.h>
2476
a6c5a537f30a a few warning fixes (missing #include's)
pl
parents: 2081
diff changeset
33 #ifdef HAVE_XSHAPE
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
34 #include <X11/extensions/shape.h>
2476
a6c5a537f30a a few warning fixes (missing #include's)
pl
parents: 2081
diff changeset
35 #endif
a6c5a537f30a a few warning fixes (missing #include's)
pl
parents: 2081
diff changeset
36
10194
2608bf0037b6 From: Ben Low <ben@bdlow.net>
pontscho
parents: 10170
diff changeset
37 #ifdef HAVE_XINERAMA
2608bf0037b6 From: Ben Low <ben@bdlow.net>
pontscho
parents: 10170
diff changeset
38 #include <X11/extensions/Xinerama.h>
2608bf0037b6 From: Ben Low <ben@bdlow.net>
pontscho
parents: 10170
diff changeset
39 #endif
2608bf0037b6 From: Ben Low <ben@bdlow.net>
pontscho
parents: 10170
diff changeset
40
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
41 #include <sys/ipc.h>
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
42 #include <sys/shm.h>
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
43
8864
b8c271750450 - sync with x11_common
pontscho
parents: 8478
diff changeset
44 #undef ENABLE_DPMS
8478
7988573021e8 disable DPMS handling
pontscho
parents: 8150
diff changeset
45
10194
2608bf0037b6 From: Ben Low <ben@bdlow.net>
pontscho
parents: 10170
diff changeset
46 #ifdef HAVE_XINERAMA
2608bf0037b6 From: Ben Low <ben@bdlow.net>
pontscho
parents: 10170
diff changeset
47 extern int xinerama_screen;
2608bf0037b6 From: Ben Low <ben@bdlow.net>
pontscho
parents: 10170
diff changeset
48 #endif
2608bf0037b6 From: Ben Low <ben@bdlow.net>
pontscho
parents: 10170
diff changeset
49
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
50 typedef struct
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
51 {
3054
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
52 unsigned long flags;
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
53 unsigned long functions;
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
54 unsigned long decorations;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
55 long input_mode;
3054
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
56 unsigned long status;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
57 } MotifWmHints;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
58
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
59 Atom wsMotifHints;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
60
4465
b013d01d9968 small bugfixes, and kill other warning
pontscho
parents: 4411
diff changeset
61 int wsMaxX = 0; // Screen width.
b013d01d9968 small bugfixes, and kill other warning
pontscho
parents: 4411
diff changeset
62 int wsMaxY = 0; // Screen height.
10194
2608bf0037b6 From: Ben Low <ben@bdlow.net>
pontscho
parents: 10170
diff changeset
63 int wsOrgX = 0; // Screen origin x.
2608bf0037b6 From: Ben Low <ben@bdlow.net>
pontscho
parents: 10170
diff changeset
64 int wsOrgY = 0; // Screen origin y.
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
65
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
66 Display * wsDisplay;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
67 int wsScreen;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
68 Window wsRootWin;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
69 XEvent wsEvent;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
70 int wsWindowDepth;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
71 GC wsHGC;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
72 MotifWmHints wsMotifWmHints;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
73 Atom wsTextProperlyAtom = None;
5997
b5fb9a927bf3 add WM detection, and wm specific fullscreen code. (???)
pontscho
parents: 5986
diff changeset
74 int wsLayer = 0;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
75
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
76 int wsDepthOnScreen = 0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
77 int wsRedMask = 0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
78 int wsGreenMask = 0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
79 int wsBlueMask = 0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
80 int wsOutMask = 0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
81
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
82 int wsTrue = True;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
83
8949
d07ab8e088a9 correct skin changing
pontscho
parents: 8916
diff changeset
84 #define wsWLCount 5
d07ab8e088a9 correct skin changing
pontscho
parents: 8916
diff changeset
85 wsTWindow * wsWindowList[wsWLCount] = { NULL,NULL,NULL,NULL,NULL };
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
86
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
87 unsigned long wsKeyTable[512];
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
88
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
89 int wsUseXShm = 1;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
90 int wsUseXShape = 1;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
91
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
92 int XShmGetEventBase( Display* );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
93 inline int wsSearch( Window win );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
94
7206
09722d199d83 remove obsoleted files
pontscho
parents: 6967
diff changeset
95 // ---
09722d199d83 remove obsoleted files
pontscho
parents: 6967
diff changeset
96
09722d199d83 remove obsoleted files
pontscho
parents: 6967
diff changeset
97 #define PACK_RGB16(r,g,b,pixel) pixel=(b>>3);\
09722d199d83 remove obsoleted files
pontscho
parents: 6967
diff changeset
98 pixel<<=6;\
09722d199d83 remove obsoleted files
pontscho
parents: 6967
diff changeset
99 pixel|=(g>>2);\
09722d199d83 remove obsoleted files
pontscho
parents: 6967
diff changeset
100 pixel<<=5;\
09722d199d83 remove obsoleted files
pontscho
parents: 6967
diff changeset
101 pixel|=(r>>3)
09722d199d83 remove obsoleted files
pontscho
parents: 6967
diff changeset
102
09722d199d83 remove obsoleted files
pontscho
parents: 6967
diff changeset
103 #define PACK_RGB15(r,g,b,pixel) pixel=(b>>3);\
09722d199d83 remove obsoleted files
pontscho
parents: 6967
diff changeset
104 pixel<<=5;\
09722d199d83 remove obsoleted files
pontscho
parents: 6967
diff changeset
105 pixel|=(g>>3);\
09722d199d83 remove obsoleted files
pontscho
parents: 6967
diff changeset
106 pixel<<=5;\
09722d199d83 remove obsoleted files
pontscho
parents: 6967
diff changeset
107 pixel|=(r>>3)
09722d199d83 remove obsoleted files
pontscho
parents: 6967
diff changeset
108
09722d199d83 remove obsoleted files
pontscho
parents: 6967
diff changeset
109 typedef void(*wsTConvFunc)( const unsigned char * in_pixels, unsigned char * out_pixels, unsigned num_pixels );
09722d199d83 remove obsoleted files
pontscho
parents: 6967
diff changeset
110 wsTConvFunc wsConvFunc = NULL;
7706
90044efe01ee - better dxr3 support
pontscho
parents: 7572
diff changeset
111
90044efe01ee - better dxr3 support
pontscho
parents: 7572
diff changeset
112 void rgb32torgb32( const unsigned char * src, unsigned char * dst,unsigned int src_size )
7206
09722d199d83 remove obsoleted files
pontscho
parents: 6967
diff changeset
113 { memcpy( dst,src,src_size ); }
09722d199d83 remove obsoleted files
pontscho
parents: 6967
diff changeset
114
09722d199d83 remove obsoleted files
pontscho
parents: 6967
diff changeset
115 // ---
09722d199d83 remove obsoleted files
pontscho
parents: 6967
diff changeset
116
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
117 #define MWM_HINTS_FUNCTIONS (1L << 0)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
118 #define MWM_HINTS_DECORATIONS (1L << 1)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
119 #define MWM_HINTS_INPUT_MODE (1L << 2)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
120 #define MWM_HINTS_STATUS (1L << 3)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
121
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
122 #define MWM_FUNC_ALL (1L << 0)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
123 #define MWM_FUNC_RESIZE (1L << 1)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
124 #define MWM_FUNC_MOVE (1L << 2)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
125 #define MWM_FUNC_MINIMIZE (1L << 3)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
126 #define MWM_FUNC_MAXIMIZE (1L << 4)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
127 #define MWM_FUNC_CLOSE (1L << 5)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
128
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
129 #define MWM_DECOR_ALL (1L << 0)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
130 #define MWM_DECOR_BORDER (1L << 1)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
131 #define MWM_DECOR_RESIZEH (1L << 2)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
132 #define MWM_DECOR_TITLE (1L << 3)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
133 #define MWM_DECOR_MENU (1L << 4)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
134 #define MWM_DECOR_MINIMIZE (1L << 5)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
135 #define MWM_DECOR_MAXIMIZE (1L << 6)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
136
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
137 #define MWM_INPUT_MODELESS 0
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
138 #define MWM_INPUT_PRIMARY_APPLICATION_MODAL 1
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
139 #define MWM_INPUT_SYSTEM_MODAL 2
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
140 #define MWM_INPUT_FULL_APPLICATION_MODAL 3
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
141 #define MWM_INPUT_APPLICATION_MODAL MWM_INPUT_PRIMARY_APPLICATION_MODAL
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
142
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
143 #define MWM_TEAROFF_WINDOW (1L<<0)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
144
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
145 void wsWindowDecoration( wsTWindow * win,long d )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
146 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
147 wsMotifHints=XInternAtom( wsDisplay,"_MOTIF_WM_HINTS",0 );
3054
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
148 if ( wsMotifHints == None ) return;
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
149
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
150 memset( &wsMotifWmHints,0,sizeof( MotifWmHints ) );
5031
8e43137d59d8 rewrite MWM hint handling
pontscho
parents: 4818
diff changeset
151 wsMotifWmHints.flags=MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS;
8e43137d59d8 rewrite MWM hint handling
pontscho
parents: 4818
diff changeset
152 if ( d )
8e43137d59d8 rewrite MWM hint handling
pontscho
parents: 4818
diff changeset
153 {
8e43137d59d8 rewrite MWM hint handling
pontscho
parents: 4818
diff changeset
154 wsMotifWmHints.functions=MWM_FUNC_MOVE | MWM_FUNC_CLOSE | MWM_FUNC_MINIMIZE | MWM_FUNC_MAXIMIZE | MWM_FUNC_RESIZE;
8e43137d59d8 rewrite MWM hint handling
pontscho
parents: 4818
diff changeset
155 wsMotifWmHints.decorations=MWM_DECOR_ALL;
8e43137d59d8 rewrite MWM hint handling
pontscho
parents: 4818
diff changeset
156 }
3054
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
157 XChangeProperty( wsDisplay,win->WindowID,wsMotifHints,wsMotifHints,32,
9507f90d8254 add half dvd support for gui
pontscho
parents: 2981
diff changeset
158 PropModeReplace,(unsigned char *)&wsMotifWmHints,5 );
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 );
7801
48b7d7fd7075 - wsErrorHandler was crashing on solaris with a null pointer access in printf;
jkeil
parents: 7751
diff changeset
179 fprintf(stderr,"[ws] Modules: %s\n",current_module?current_module:"(NULL)" );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
180 exit( 0 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
181 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
182
1723
5e4214a7540e GUI stuff. now seeking works, and xmga renders to video window
arpi
parents: 1709
diff changeset
183 void wsXInit( void* mDisplay )
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
184 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
185 int eventbase;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
186 int errorbase;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
187
1723
5e4214a7540e GUI stuff. now seeking works, and xmga renders to video window
arpi
parents: 1709
diff changeset
188 if(mDisplay){
5e4214a7540e GUI stuff. now seeking works, and xmga renders to video window
arpi
parents: 1709
diff changeset
189 wsDisplay=mDisplay;
5e4214a7540e GUI stuff. now seeking works, and xmga renders to video window
arpi
parents: 1709
diff changeset
190 } else {
5e4214a7540e GUI stuff. now seeking works, and xmga renders to video window
arpi
parents: 1709
diff changeset
191 char * DisplayName = ":0.0";
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
192 if ( getenv( "DISPLAY" ) ) DisplayName=getenv( "DISPLAY" );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
193 wsDisplay=XOpenDisplay( DisplayName );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
194 if ( !wsDisplay )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
195 {
5919
60cf2bca993f some bug fix
pontscho
parents: 5910
diff changeset
196 mp_msg( MSGT_GPLAYER,MSGL_FATAL,"[ws] couldn't open the display !\n" );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
197 exit( 0 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
198 }
1723
5e4214a7540e GUI stuff. now seeking works, and xmga renders to video window
arpi
parents: 1709
diff changeset
199 }
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
200
6967
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents: 6794
diff changeset
201 /* enable DND atoms */
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents: 6794
diff changeset
202 wsXDNDInitialize();
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents: 6794
diff changeset
203
1838
4984bd55518e add lgb's localhost detect
pontscho
parents: 1823
diff changeset
204 { /* on remote display XShm will be disabled - LGB */
4984bd55518e add lgb's localhost detect
pontscho
parents: 1823
diff changeset
205 char *dispname=DisplayString(wsDisplay);
4984bd55518e add lgb's localhost detect
pontscho
parents: 1823
diff changeset
206 int localdisp=1;
4984bd55518e add lgb's localhost detect
pontscho
parents: 1823
diff changeset
207 if (dispname&&*dispname!=':') {
4984bd55518e add lgb's localhost detect
pontscho
parents: 1823
diff changeset
208 localdisp=0;
4984bd55518e add lgb's localhost detect
pontscho
parents: 1823
diff changeset
209 wsUseXShm=0;
4984bd55518e add lgb's localhost detect
pontscho
parents: 1823
diff changeset
210 }
5919
60cf2bca993f some bug fix
pontscho
parents: 5910
diff changeset
211 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[ws] Display name: %s => %s display.\n",dispname,localdisp?"local":"REMOTE");
60cf2bca993f some bug fix
pontscho
parents: 5910
diff changeset
212 if (!localdisp) mp_msg( MSGT_GPLAYER,MSGL_STATUS,"[ws] Remote display, disabling XMITSHM\n");
1838
4984bd55518e add lgb's localhost detect
pontscho
parents: 1823
diff changeset
213 }
8864
b8c271750450 - sync with x11_common
pontscho
parents: 8478
diff changeset
214
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
215 if ( !XShmQueryExtension( wsDisplay ) )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
216 {
5919
60cf2bca993f some bug fix
pontscho
parents: 5910
diff changeset
217 mp_msg( MSGT_GPLAYER,MSGL_ERR,"[ws] sorry, your system is not supported X shared memory extension.\n" );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
218 wsUseXShm=0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
219 }
1699
7ddc63b84f1f DGA2 ifdefs, new mainloop/timer stuff
arpi
parents: 1693
diff changeset
220 #ifdef HAVE_XSHAPE
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
221 if ( !XShapeQueryExtension( wsDisplay,&eventbase,&errorbase ) )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
222 {
5919
60cf2bca993f some bug fix
pontscho
parents: 5910
diff changeset
223 mp_msg( MSGT_GPLAYER,MSGL_ERR,"[ws] sorry, your system is not supported XShape extension.\n" );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
224 wsUseXShape=0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
225 }
1699
7ddc63b84f1f DGA2 ifdefs, new mainloop/timer stuff
arpi
parents: 1693
diff changeset
226 #else
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
227 wsUseXShape=0;
1699
7ddc63b84f1f DGA2 ifdefs, new mainloop/timer stuff
arpi
parents: 1693
diff changeset
228 #endif
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
229
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
230 XSynchronize( wsDisplay,True );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
231
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
232 wsScreen=DefaultScreen( wsDisplay );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
233 wsRootWin=RootWindow( wsDisplay,wsScreen );
10194
2608bf0037b6 From: Ben Low <ben@bdlow.net>
pontscho
parents: 10170
diff changeset
234 #ifdef HAVE_XINERAMA
2608bf0037b6 From: Ben Low <ben@bdlow.net>
pontscho
parents: 10170
diff changeset
235 if(XineramaIsActive(wsDisplay))
2608bf0037b6 From: Ben Low <ben@bdlow.net>
pontscho
parents: 10170
diff changeset
236 {
2608bf0037b6 From: Ben Low <ben@bdlow.net>
pontscho
parents: 10170
diff changeset
237 XineramaScreenInfo *screens;
2608bf0037b6 From: Ben Low <ben@bdlow.net>
pontscho
parents: 10170
diff changeset
238 int num_screens;
2608bf0037b6 From: Ben Low <ben@bdlow.net>
pontscho
parents: 10170
diff changeset
239
2608bf0037b6 From: Ben Low <ben@bdlow.net>
pontscho
parents: 10170
diff changeset
240 screens = XineramaQueryScreens(wsDisplay, &num_screens);
2608bf0037b6 From: Ben Low <ben@bdlow.net>
pontscho
parents: 10170
diff changeset
241 if(xinerama_screen >= num_screens) xinerama_screen = 0;
2608bf0037b6 From: Ben Low <ben@bdlow.net>
pontscho
parents: 10170
diff changeset
242 wsOrgX = screens[xinerama_screen].x_org;
2608bf0037b6 From: Ben Low <ben@bdlow.net>
pontscho
parents: 10170
diff changeset
243 wsOrgY = screens[xinerama_screen].y_org;
2608bf0037b6 From: Ben Low <ben@bdlow.net>
pontscho
parents: 10170
diff changeset
244 wsMaxX=screens[xinerama_screen].width;
2608bf0037b6 From: Ben Low <ben@bdlow.net>
pontscho
parents: 10170
diff changeset
245 wsMaxY=screens[xinerama_screen].height;
2608bf0037b6 From: Ben Low <ben@bdlow.net>
pontscho
parents: 10170
diff changeset
246 mp_msg( MSGT_GPLAYER,MSGL_STATUS,"[ws] screens %d Max %d, %d Org %d,%d\n",
2608bf0037b6 From: Ben Low <ben@bdlow.net>
pontscho
parents: 10170
diff changeset
247 num_screens, wsMaxX, wsMaxY, wsOrgX, wsOrgY);
2608bf0037b6 From: Ben Low <ben@bdlow.net>
pontscho
parents: 10170
diff changeset
248 XFree(screens);
2608bf0037b6 From: Ben Low <ben@bdlow.net>
pontscho
parents: 10170
diff changeset
249 }
2608bf0037b6 From: Ben Low <ben@bdlow.net>
pontscho
parents: 10170
diff changeset
250 else
2608bf0037b6 From: Ben Low <ben@bdlow.net>
pontscho
parents: 10170
diff changeset
251 #endif
2608bf0037b6 From: Ben Low <ben@bdlow.net>
pontscho
parents: 10170
diff changeset
252 {
2608bf0037b6 From: Ben Low <ben@bdlow.net>
pontscho
parents: 10170
diff changeset
253 wsOrgX = wsOrgY = 0;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
254 wsMaxX=DisplayWidth( wsDisplay,wsScreen );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
255 wsMaxY=DisplayHeight( wsDisplay,wsScreen );
10194
2608bf0037b6 From: Ben Low <ben@bdlow.net>
pontscho
parents: 10170
diff changeset
256 }
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
257
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
258 wsGetDepthOnScreen();
1699
7ddc63b84f1f DGA2 ifdefs, new mainloop/timer stuff
arpi
parents: 1693
diff changeset
259 #ifdef DEBUG
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
260 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
261 int minor,major,shp;
5919
60cf2bca993f some bug fix
pontscho
parents: 5910
diff changeset
262 mp_msg( MSGT_GPLAYER,MSGL_DBG2,"[ws] Screen depth: %d\n",wsDepthOnScreen );
60cf2bca993f some bug fix
pontscho
parents: 5910
diff changeset
263 mp_msg( MSGT_GPLAYER,MSGL_DBG2,"[ws] size: %dx%d\n",wsMaxX,wsMaxY );
10194
2608bf0037b6 From: Ben Low <ben@bdlow.net>
pontscho
parents: 10170
diff changeset
264 #ifdef HAVE_XINERAMA
2608bf0037b6 From: Ben Low <ben@bdlow.net>
pontscho
parents: 10170
diff changeset
265 mp_msg( MSGT_GPLAYER,MSGL_DBG2,"[ws] origin: +%d+%d\n",wsOrgX,wsOrgY );
2608bf0037b6 From: Ben Low <ben@bdlow.net>
pontscho
parents: 10170
diff changeset
266 #endif
5919
60cf2bca993f some bug fix
pontscho
parents: 5910
diff changeset
267 mp_msg( MSGT_GPLAYER,MSGL_DBG2,"[ws] red mask: 0x%x\n",wsRedMask );
60cf2bca993f some bug fix
pontscho
parents: 5910
diff changeset
268 mp_msg( MSGT_GPLAYER,MSGL_DBG2,"[ws] green mask: 0x%x\n",wsGreenMask );
60cf2bca993f some bug fix
pontscho
parents: 5910
diff changeset
269 mp_msg( MSGT_GPLAYER,MSGL_DBG2,"[ws] blue mask: 0x%x\n",wsBlueMask );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
270 if ( wsUseXShm )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
271 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
272 XShmQueryVersion( wsDisplay,&major,&minor,&shp );
5919
60cf2bca993f some bug fix
pontscho
parents: 5910
diff changeset
273 mp_msg( MSGT_GPLAYER,MSGL_DBG2,"[ws] XShm version is %d.%d\n",major,minor );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
274 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
275 #ifdef HAVE_XSHAPE
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
276 if ( wsUseXShape )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
277 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
278 XShapeQueryVersion( wsDisplay,&major,&minor );
5919
60cf2bca993f some bug fix
pontscho
parents: 5910
diff changeset
279 mp_msg( MSGT_GPLAYER,MSGL_DBG2,"[ws] XShape version is %d.%d\n",major,minor );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
280 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
281 #endif
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
282 }
1699
7ddc63b84f1f DGA2 ifdefs, new mainloop/timer stuff
arpi
parents: 1693
diff changeset
283 #endif
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
284 wsOutMask=wsGetOutMask();
5919
60cf2bca993f some bug fix
pontscho
parents: 5910
diff changeset
285 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[ws] Initialized converter: " );
10411
80dbdfe86c5b I attach a fix to the problem described in:
arpi
parents: 10233
diff changeset
286 sws_rgb2rgb_init(get_sws_cpuflags());
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
287 switch ( wsOutMask )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
288 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
289 case wsRGB32:
5919
60cf2bca993f some bug fix
pontscho
parents: 5910
diff changeset
290 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"rgb32 to rgb32\n" );
7206
09722d199d83 remove obsoleted files
pontscho
parents: 6967
diff changeset
291 wsConvFunc=rgb32torgb32;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
292 break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
293 case wsBGR32:
5919
60cf2bca993f some bug fix
pontscho
parents: 5910
diff changeset
294 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"rgb32 to bgr32\n" );
2782
b52d3e6ff4ab app michale's rgb32tobgr32
pontscho
parents: 2733
diff changeset
295 wsConvFunc=rgb32tobgr32;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
296 break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
297 case wsRGB24:
5919
60cf2bca993f some bug fix
pontscho
parents: 5910
diff changeset
298 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"rgb32 to rgb24\n" );
2733
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
299 wsConvFunc=rgb32to24;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
300 break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
301 case wsBGR24:
5919
60cf2bca993f some bug fix
pontscho
parents: 5910
diff changeset
302 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"rgb32 to bgr24\n" );
7206
09722d199d83 remove obsoleted files
pontscho
parents: 6967
diff changeset
303 wsConvFunc=rgb32tobgr24;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
304 break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
305 case wsRGB16:
5919
60cf2bca993f some bug fix
pontscho
parents: 5910
diff changeset
306 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"rgb32 to rgb16\n" );
2733
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
307 wsConvFunc=rgb32to16;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
308 break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
309 case wsBGR16:
5919
60cf2bca993f some bug fix
pontscho
parents: 5910
diff changeset
310 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"rgb32 to bgr16\n" );
7206
09722d199d83 remove obsoleted files
pontscho
parents: 6967
diff changeset
311 wsConvFunc=rgb32tobgr16;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
312 break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
313 case wsRGB15:
5919
60cf2bca993f some bug fix
pontscho
parents: 5910
diff changeset
314 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"rgb32 to rgb15\n" );
2733
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
315 wsConvFunc=rgb32to15;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
316 break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
317 case wsBGR15:
5919
60cf2bca993f some bug fix
pontscho
parents: 5910
diff changeset
318 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"rgb32 to bgr15\n" );
7206
09722d199d83 remove obsoleted files
pontscho
parents: 6967
diff changeset
319 wsConvFunc=rgb32tobgr15;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
320 break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
321 }
5997
b5fb9a927bf3 add WM detection, and wm specific fullscreen code. (???)
pontscho
parents: 5986
diff changeset
322 XSetErrorHandler( wsErrorHandler );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
323 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
324
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
325 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
326 // Create window.
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
327 // X,Y : window position
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
328 // wX,wY : size of window
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
329 // bW : border width
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
330 // cV : visible mouse cursor on window
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
331 // D : visible frame, title, etc.
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
332 // sR : screen ratio
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
333 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
334
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
335 XClassHint wsClassHint;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
336 XTextProperty wsTextProperty;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
337 Window LeaderWindow;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
338
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
339 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
340 {
7802
037982e833a7 Choose a good visual from the list of supported visuals on the X11 server,
jkeil
parents: 7801
diff changeset
341 int depth;
037982e833a7 Choose a good visual from the list of supported visuals on the X11 server,
jkeil
parents: 7801
diff changeset
342
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
343 win->Property=D;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
344 if ( D & wsShowFrame ) win->Decorations=1;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
345 wsHGC=DefaultGC( wsDisplay,wsScreen );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
346 // The window position and size.
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
347 switch ( X )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
348 {
10194
2608bf0037b6 From: Ben Low <ben@bdlow.net>
pontscho
parents: 10170
diff changeset
349 case -1: win->X=( wsMaxX / 2 ) - ( wX / 2 ) + wsOrgX; break;
2608bf0037b6 From: Ben Low <ben@bdlow.net>
pontscho
parents: 10170
diff changeset
350 case -2: win->X=wsMaxX - wX - 1 + wsOrgX; break;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
351 default: win->X=X; break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
352 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
353 switch ( Y )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
354 {
10194
2608bf0037b6 From: Ben Low <ben@bdlow.net>
pontscho
parents: 10170
diff changeset
355 case -1: win->Y=( wsMaxY / 2 ) - ( hY / 2 ) + wsOrgY; break;
2608bf0037b6 From: Ben Low <ben@bdlow.net>
pontscho
parents: 10170
diff changeset
356 case -2: win->Y=wsMaxY - hY - 1 + wsOrgY; break;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
357 default: win->Y=Y; break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
358 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
359 win->Width=wX;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
360 win->Height=hY;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
361 win->OldX=win->X;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
362 win->OldY=win->Y;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
363 win->OldWidth=win->Width;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
364 win->OldHeight=win->Height;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
365
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
366 // Border size for window.
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
367 win->BorderWidth=bW;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
368 // Hide Mouse Cursor
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
369 win->wsCursor=None;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
370 win->wsMouseEventType=cV;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
371 win->wsCursorData[0]=0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
372 win->wsCursorPixmap=XCreateBitmapFromData( wsDisplay,wsRootWin,win->wsCursorData,1,1 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
373 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
374
7802
037982e833a7 Choose a good visual from the list of supported visuals on the X11 server,
jkeil
parents: 7801
diff changeset
375 depth = vo_find_depth_from_visuals( wsDisplay,wsScreen,NULL );
037982e833a7 Choose a good visual from the list of supported visuals on the X11 server,
jkeil
parents: 7801
diff changeset
376 if ( depth < 15 )
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
377 {
5919
60cf2bca993f some bug fix
pontscho
parents: 5910
diff changeset
378 mp_msg( MSGT_GPLAYER,MSGL_FATAL,"[ws] sorry, this color depth is not enough.\n" );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
379 exit( 0 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
380 }
7802
037982e833a7 Choose a good visual from the list of supported visuals on the X11 server,
jkeil
parents: 7801
diff changeset
381 XMatchVisualInfo( wsDisplay,wsScreen,depth,TrueColor,&win->VisualInfo );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
382
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
383 // ---
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
384 win->AtomLeaderClient=XInternAtom( wsDisplay,"WM_CLIENT_LEADER",False );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
385 win->AtomDeleteWindow=XInternAtom( wsDisplay,"WM_DELETE_WINDOW",False );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
386 win->AtomTakeFocus=XInternAtom( wsDisplay,"WM_TAKE_FOCUS",False );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
387 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
388 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
389 win->AtomWMNormalHint=XInternAtom( wsDisplay,"WM_NORMAL_HINT",False );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
390 win->AtomProtocols=XInternAtom( wsDisplay,"WM_PROTOCOLS",False );
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=WhitePixel( wsDisplay,wsScreen );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
398 win->WindowAttrib.colormap=XCreateColormap( wsDisplay,wsRootWin,win->VisualInfo.visual,AllocNone );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
399 win->WindowAttrib.event_mask=StructureNotifyMask | FocusChangeMask |
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
400 ExposureMask | PropertyChangeMask |
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
401 EnterWindowMask | LeaveWindowMask |
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
402 VisibilityChangeMask |
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
403 KeyPressMask | KeyReleaseMask;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
404 if ( ( cV & wsHandleMouseButton ) ) win->WindowAttrib.event_mask|=ButtonPressMask | ButtonReleaseMask;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
405 if ( ( cV & wsHandleMouseMove ) ) win->WindowAttrib.event_mask|=PointerMotionMask;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
406 win->WindowAttrib.cursor=win->wsCursor;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
407 win->WindowAttrib.override_redirect=False;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
408 if ( D & wsOverredirect ) win->WindowAttrib.override_redirect=True;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
409
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
410 win->WindowMask=CWBackPixel | CWBorderPixel |
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
411 CWColormap | CWEventMask | CWCursor |
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
412 CWOverrideRedirect;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
413
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
414 win->WindowID=XCreateWindow( wsDisplay,
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
415 (win->Parent != 0?win->Parent:wsRootWin),
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
416 win->X,win->Y,win->Width,win->Height,win->BorderWidth,
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
417 win->VisualInfo.depth,
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
418 InputOutput,
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
419 win->VisualInfo.visual,
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
420 win->WindowMask,&win->WindowAttrib );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
421
4411
a97f908988ed small changes
pontscho
parents: 3055
diff changeset
422 wsClassHint.res_name="MPlayer";
a97f908988ed small changes
pontscho
parents: 3055
diff changeset
423
2029
41ed89701ece fix fucking icewm fullscreen bug.
pontscho
parents: 1860
diff changeset
424 wsClassHint.res_class="MPlayer";
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
425 XSetClassHint( wsDisplay,win->WindowID,&wsClassHint );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
426
5997
b5fb9a927bf3 add WM detection, and wm specific fullscreen code. (???)
pontscho
parents: 5986
diff changeset
427 win->SizeHint.flags=PPosition | PSize | PResizeInc | PWinGravity;// | PBaseSize;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
428 win->SizeHint.x=win->X;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
429 win->SizeHint.y=win->Y;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
430 win->SizeHint.width=win->Width;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
431 win->SizeHint.height=win->Height;
5986
d34622ebaf45 window resize bug fixed
pontscho
parents: 5919
diff changeset
432
1860
c65abbc91c5c fix mwm bug's. faszom (C), and remove mixer.*
pontscho
parents: 1858
diff changeset
433 if ( D & wsMinSize )
c65abbc91c5c fix mwm bug's. faszom (C), and remove mixer.*
pontscho
parents: 1858
diff changeset
434 {
c65abbc91c5c fix mwm bug's. faszom (C), and remove mixer.*
pontscho
parents: 1858
diff changeset
435 win->SizeHint.flags|=PMinSize;
c65abbc91c5c fix mwm bug's. faszom (C), and remove mixer.*
pontscho
parents: 1858
diff changeset
436 win->SizeHint.min_width=win->Width;
c65abbc91c5c fix mwm bug's. faszom (C), and remove mixer.*
pontscho
parents: 1858
diff changeset
437 win->SizeHint.min_height=win->Height;
c65abbc91c5c fix mwm bug's. faszom (C), and remove mixer.*
pontscho
parents: 1858
diff changeset
438 }
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
439 if ( D & wsMaxSize )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
440 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
441 win->SizeHint.flags|=PMaxSize;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
442 win->SizeHint.max_width=win->Width;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
443 win->SizeHint.max_height=win->Height;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
444 }
5986
d34622ebaf45 window resize bug fixed
pontscho
parents: 5919
diff changeset
445
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
446 win->SizeHint.height_inc=1;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
447 win->SizeHint.width_inc=1;
5919
60cf2bca993f some bug fix
pontscho
parents: 5910
diff changeset
448 win->SizeHint.base_width=win->Width;
60cf2bca993f some bug fix
pontscho
parents: 5910
diff changeset
449 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
450 win->SizeHint.win_gravity=StaticGravity;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
451 XSetWMNormalHints( wsDisplay,win->WindowID,&win->SizeHint );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
452
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
453 win->WMHints.flags=InputHint | StateHint;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
454 win->WMHints.input=True;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
455 win->WMHints.initial_state=NormalState;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
456 XSetWMHints( wsDisplay,win->WindowID,&win->WMHints );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
457
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
458 wsWindowDecoration( win,win->Decorations );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
459 XStoreName( wsDisplay,win->WindowID,label );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
460 XmbSetWMProperties( wsDisplay,win->WindowID,label,label,NULL,0,NULL,NULL,NULL );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
461
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
462 XSetWMProtocols( wsDisplay,win->WindowID,win->AtomsProtocols,3 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
463 XChangeProperty( wsDisplay,win->WindowID,
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
464 win->AtomLeaderClient,
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
465 XA_WINDOW,32,PropModeReplace,
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
466 (unsigned char *)&LeaderWindow,1 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
467
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
468 wsTextProperty.value=label;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
469 wsTextProperty.encoding=XA_STRING;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
470 wsTextProperty.format=8;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
471 wsTextProperty.nitems=strlen( label );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
472 XSetWMIconName( wsDisplay,win->WindowID,&wsTextProperty );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
473
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
474 win->wGC=XCreateGC( wsDisplay,win->WindowID,
1814
9c674dc76ff3 add wsSetForegroundRGB
pontscho
parents: 1810
diff changeset
475 GCForeground | GCBackground,
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
476 &win->wGCV );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
477
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
478 win->Visible=0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
479 win->Focused=0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
480 win->Mapped=0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
481 win->Rolled=0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
482 if ( D & wsShowWindow ) XMapWindow( wsDisplay,win->WindowID );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
483
1858
88a88d0a3f94 fix skin changing, xv fullscreen redraw bug, etc.
pontscho
parents: 1853
diff changeset
484 wsCreateImage( win,win->Width,win->Height );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
485 // --- End of creating --------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
486
8949
d07ab8e088a9 correct skin changing
pontscho
parents: 8916
diff changeset
487 {
d07ab8e088a9 correct skin changing
pontscho
parents: 8916
diff changeset
488 int i;
d07ab8e088a9 correct skin changing
pontscho
parents: 8916
diff changeset
489 for ( i=0;i < wsWLCount;i++ )
d07ab8e088a9 correct skin changing
pontscho
parents: 8916
diff changeset
490 if ( wsWindowList[i] == NULL ) break;
d07ab8e088a9 correct skin changing
pontscho
parents: 8916
diff changeset
491 if ( i == wsWLCount )
10606
f9c1b97a71cb translated a message to english
alex
parents: 10411
diff changeset
492 { mp_msg( MSGT_GPLAYER,MSGL_FATAL,"[ws] there are too many open windows\n" ); exit( 0 ); }
8949
d07ab8e088a9 correct skin changing
pontscho
parents: 8916
diff changeset
493 wsWindowList[i]=win;
d07ab8e088a9 correct skin changing
pontscho
parents: 8916
diff changeset
494 }
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
495
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
496 XFlush( wsDisplay );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
497 XSync( wsDisplay,False );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
498
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
499 win->ReDraw=NULL;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
500 win->ReSize=NULL;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
501 win->Idle=NULL;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
502 win->MouseHandler=NULL;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
503 win->KeyHandler=NULL;
5919
60cf2bca993f some bug fix
pontscho
parents: 5910
diff changeset
504 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[ws] window is created. ( %s ).\n",label );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
505 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
506
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
507 void wsDestroyWindow( wsTWindow * win )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
508 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
509 int l;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
510 l=wsSearch( win->WindowID );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
511 wsWindowList[l]=NULL;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
512 if ( win->wsCursor != None )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
513 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
514 XFreeCursor( wsDisplay,win->wsCursor );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
515 win->wsCursor=None;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
516 }
8949
d07ab8e088a9 correct skin changing
pontscho
parents: 8916
diff changeset
517 XFreeGC( wsDisplay,win->wGC );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
518 XUnmapWindow( wsDisplay,win->WindowID );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
519 wsDestroyImage( win );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
520 XDestroyWindow( wsDisplay,win->WindowID );
8949
d07ab8e088a9 correct skin changing
pontscho
parents: 8916
diff changeset
521 #if 0
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
522 win->ReDraw=NULL;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
523 win->ReSize=NULL;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
524 win->Idle=NULL;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
525 win->MouseHandler=NULL;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
526 win->KeyHandler=NULL;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
527 win->Visible=0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
528 win->Focused=0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
529 win->Mapped=0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
530 win->Rolled=0;
8949
d07ab8e088a9 correct skin changing
pontscho
parents: 8916
diff changeset
531 #endif
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
532 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
533
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
534 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
535 // Handle events.
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
536 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
537
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
538 inline int wsSearch( Window win )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
539 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
540 int i;
8949
d07ab8e088a9 correct skin changing
pontscho
parents: 8916
diff changeset
541 for ( i=0;i<wsWLCount;i++ ) if ( wsWindowList[i] && wsWindowList[i]->WindowID == win ) return i;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
542 return -1;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
543 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
544
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
545 Bool wsEvents( Display * display,XEvent * Event,XPointer arg )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
546 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
547 unsigned long i = 0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
548 int l;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
549 int x,y;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
550 Window child_window = 0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
551
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
552 l=wsSearch( Event->xany.window );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
553 if ( l == -1 ) return !wsTrue;
1782
dce42eebfda4 win->state fix
pontscho
parents: 1779
diff changeset
554 wsWindowList[l]->State=0;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
555 switch( Event->type )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
556 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
557 case ClientMessage:
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
558 if ( Event->xclient.message_type == wsWindowList[l]->AtomProtocols )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
559 {
7751
27c9c440536f - dvd aspect changing bug - fixed
pontscho
parents: 7706
diff changeset
560 if ( (Atom)Event->xclient.data.l[0] == wsWindowList[l]->AtomDeleteWindow )
5919
60cf2bca993f some bug fix
pontscho
parents: 5910
diff changeset
561 { i=wsWindowClosed; goto expose; }
7751
27c9c440536f - dvd aspect changing bug - fixed
pontscho
parents: 7706
diff changeset
562 if ( (Atom)Event->xclient.data.l[0] == wsWindowList[l]->AtomTakeFocus )
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
563 { i=wsWindowFocusIn; wsWindowList[l]->Focused=wsFocused; goto expose; }
7751
27c9c440536f - dvd aspect changing bug - fixed
pontscho
parents: 7706
diff changeset
564 if ( (Atom)Event->xclient.data.l[0] == wsWindowList[l]->AtomRolle )
5919
60cf2bca993f some bug fix
pontscho
parents: 5910
diff changeset
565 { mp_msg( MSGT_GPLAYER,MSGL_STATUS,"[ws] rolled.\n" ); }
6967
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents: 6794
diff changeset
566 } else {
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents: 6794
diff changeset
567 /* try to process DND events */
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents: 6794
diff changeset
568 wsXDNDProcessClientMessage(wsWindowList[l],&Event->xclient);
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents: 6794
diff changeset
569 }
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
570 break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
571
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
572 case MapNotify: i=wsWindowMapped; wsWindowList[l]->Mapped=wsMapped; goto expose;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
573 case UnmapNotify: i=wsWindowUnmapped; wsWindowList[l]->Mapped=wsNone; goto expose;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
574 case FocusIn:
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
575 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
576 i=wsWindowFocusIn;
b64fa5d25142 add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents: 2782
diff changeset
577 wsWindowList[l]->Focused=wsFocused;
b64fa5d25142 add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents: 2782
diff changeset
578 goto expose;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
579 case FocusOut:
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
580 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
581 i=wsWindowFocusOut;
b64fa5d25142 add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents: 2782
diff changeset
582 wsWindowList[l]->Focused=wsNone;
b64fa5d25142 add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents: 2782
diff changeset
583 goto expose;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
584 case VisibilityNotify:
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
585 switch( Event->xvisibility.state )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
586 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
587 case VisibilityUnobscured: i=wsWindowVisible; wsWindowList[l]->Visible=wsVisible; goto expose;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
588 case VisibilityFullyObscured: i=wsWindowNotVisible; wsWindowList[l]->Visible=wsNotVisible; goto expose;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
589 case VisibilityPartiallyObscured: i=wsWindowPartialVisible; wsWindowList[l]->Visible=wsPVisible; goto expose;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
590 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
591 expose:
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
592 wsWindowList[l]->State=i;
8058
9246adcf95f0 cosmetic
pontscho
parents: 7892
diff changeset
593 if ( wsWindowList[l]->ReDraw ) wsWindowList[l]->ReDraw();
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
594 break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
595
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
596 case Expose:
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
597 wsWindowList[l]->State=wsWindowExpose;
8058
9246adcf95f0 cosmetic
pontscho
parents: 7892
diff changeset
598 if ( ( wsWindowList[l]->ReDraw )&&( !Event->xexpose.count ) ) wsWindowList[l]->ReDraw();
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
599 break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
600
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
601 case ConfigureNotify:
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
602 XTranslateCoordinates( wsDisplay,wsWindowList[l]->WindowID,wsRootWin,0,0,&x,&y,&child_window );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
603 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
604 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
605 wsWindowList[l]->X=x; wsWindowList[l]->Y=y;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
606 wsWindowList[l]->Width=Event->xconfigure.width; wsWindowList[l]->Height=Event->xconfigure.height;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
607 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
608 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
609
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
610 wsWindowList[l]->Rolled=wsNone;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
611 if ( Event->xconfigure.y < 0 )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
612 { i=wsWindowRolled; wsWindowList[l]->Rolled=wsRolled; goto expose; }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
613
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
614 break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
615
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
616 case KeyPress: i=wsKeyPressed; goto keypressed;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
617 case KeyRelease: i=wsKeyReleased;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
618 keypressed:
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
619 wsWindowList[l]->Alt=0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
620 wsWindowList[l]->Shift=0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
621 wsWindowList[l]->NumLock=0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
622 wsWindowList[l]->Control=0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
623 wsWindowList[l]->CapsLock=0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
624 if ( Event->xkey.state & Mod1Mask ) wsWindowList[l]->Alt=1;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
625 if ( Event->xkey.state & Mod2Mask ) wsWindowList[l]->NumLock=1;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
626 if ( Event->xkey.state & ControlMask ) wsWindowList[l]->Control=1;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
627 if ( Event->xkey.state & ShiftMask ) wsWindowList[l]->Shift=1;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
628 if ( Event->xkey.state & LockMask ) wsWindowList[l]->CapsLock=1;
6089
39c2bfe5c267 small fixes
pontscho
parents: 6034
diff changeset
629 #if 0
6183
a4bbda72ce86 fix two small bug and add multimedia keyboard support ( i tested with Acer AirKey V only )
pontscho
parents: 6159
diff changeset
630 {
a4bbda72ce86 fix two small bug and add multimedia keyboard support ( i tested with Acer AirKey V only )
pontscho
parents: 6159
diff changeset
631 KeySym keySym;
a4bbda72ce86 fix two small bug and add multimedia keyboard support ( i tested with Acer AirKey V only )
pontscho
parents: 6159
diff changeset
632 keySym=XKeycodeToKeysym( wsDisplay,Event->xkey.keycode,0 );
a4bbda72ce86 fix two small bug and add multimedia keyboard support ( i tested with Acer AirKey V only )
pontscho
parents: 6159
diff changeset
633 if ( keySym != NoSymbol )
a4bbda72ce86 fix two small bug and add multimedia keyboard support ( i tested with Acer AirKey V only )
pontscho
parents: 6159
diff changeset
634 {
a4bbda72ce86 fix two small bug and add multimedia keyboard support ( i tested with Acer AirKey V only )
pontscho
parents: 6159
diff changeset
635 keySym=( (keySym&0xff00) != 0?( (keySym&0x00ff) + 256 ):( keySym ) );
a4bbda72ce86 fix two small bug and add multimedia keyboard support ( i tested with Acer AirKey V only )
pontscho
parents: 6159
diff changeset
636 wsKeyTable[ keySym ]=i;
a4bbda72ce86 fix two small bug and add multimedia keyboard support ( i tested with Acer AirKey V only )
pontscho
parents: 6159
diff changeset
637 if ( wsWindowList[l]->KeyHandler )
a4bbda72ce86 fix two small bug and add multimedia keyboard support ( i tested with Acer AirKey V only )
pontscho
parents: 6159
diff changeset
638 wsWindowList[l]->KeyHandler( Event->xkey.state,i,keySym );
a4bbda72ce86 fix two small bug and add multimedia keyboard support ( i tested with Acer AirKey V only )
pontscho
parents: 6159
diff changeset
639 }
a4bbda72ce86 fix two small bug and add multimedia keyboard support ( i tested with Acer AirKey V only )
pontscho
parents: 6159
diff changeset
640 }
6089
39c2bfe5c267 small fixes
pontscho
parents: 6034
diff changeset
641 #else
39c2bfe5c267 small fixes
pontscho
parents: 6034
diff changeset
642 {
39c2bfe5c267 small fixes
pontscho
parents: 6034
diff changeset
643 int key;
39c2bfe5c267 small fixes
pontscho
parents: 6034
diff changeset
644 char buf[100];
39c2bfe5c267 small fixes
pontscho
parents: 6034
diff changeset
645 KeySym keySym;
39c2bfe5c267 small fixes
pontscho
parents: 6034
diff changeset
646 static XComposeStatus stat;
39c2bfe5c267 small fixes
pontscho
parents: 6034
diff changeset
647
39c2bfe5c267 small fixes
pontscho
parents: 6034
diff changeset
648 XLookupString( &Event->xkey,buf,sizeof(buf),&keySym,&stat );
39c2bfe5c267 small fixes
pontscho
parents: 6034
diff changeset
649 key=( (keySym&0xff00) != 0?( (keySym&0x00ff) + 256 ):( keySym ) );
39c2bfe5c267 small fixes
pontscho
parents: 6034
diff changeset
650 wsKeyTable[ key ]=i;
6183
a4bbda72ce86 fix two small bug and add multimedia keyboard support ( i tested with Acer AirKey V only )
pontscho
parents: 6159
diff changeset
651 if ( wsWindowList[l]->KeyHandler ) wsWindowList[l]->KeyHandler( Event->xkey.keycode,i,key );
6089
39c2bfe5c267 small fixes
pontscho
parents: 6034
diff changeset
652 }
39c2bfe5c267 small fixes
pontscho
parents: 6034
diff changeset
653 #endif
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
654 break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
655
8916
e3bce0159317 motion fix from Gregory Kovriga <gkovriga@techunix.technion.ac.il>
pontscho
parents: 8864
diff changeset
656 case MotionNotify:
e3bce0159317 motion fix from Gregory Kovriga <gkovriga@techunix.technion.ac.il>
pontscho
parents: 8864
diff changeset
657 i=wsMoveMouse;
e3bce0159317 motion fix from Gregory Kovriga <gkovriga@techunix.technion.ac.il>
pontscho
parents: 8864
diff changeset
658 {
e3bce0159317 motion fix from Gregory Kovriga <gkovriga@techunix.technion.ac.il>
pontscho
parents: 8864
diff changeset
659 /* pump all motion events from the display queue:
e3bce0159317 motion fix from Gregory Kovriga <gkovriga@techunix.technion.ac.il>
pontscho
parents: 8864
diff changeset
660 this way it works faster when moving the window */
8973
0a665389cf2b - add playbar
pontscho
parents: 8949
diff changeset
661 static XEvent e;
0a665389cf2b - add playbar
pontscho
parents: 8949
diff changeset
662 if ( Event->xmotion.state )
0a665389cf2b - add playbar
pontscho
parents: 8949
diff changeset
663 {
0a665389cf2b - add playbar
pontscho
parents: 8949
diff changeset
664 while(XCheckTypedWindowEvent(display,Event->xany.window,MotionNotify,&e)){
8916
e3bce0159317 motion fix from Gregory Kovriga <gkovriga@techunix.technion.ac.il>
pontscho
parents: 8864
diff changeset
665 /* FIXME: need to make sure we didn't release/press the button in between...*/
e3bce0159317 motion fix from Gregory Kovriga <gkovriga@techunix.technion.ac.il>
pontscho
parents: 8864
diff changeset
666 /* FIXME: do we need some timeout here to make sure we don't spend too much time
e3bce0159317 motion fix from Gregory Kovriga <gkovriga@techunix.technion.ac.il>
pontscho
parents: 8864
diff changeset
667 removing events from the queue? */
e3bce0159317 motion fix from Gregory Kovriga <gkovriga@techunix.technion.ac.il>
pontscho
parents: 8864
diff changeset
668 Event = &e;
8973
0a665389cf2b - add playbar
pontscho
parents: 8949
diff changeset
669 }
8916
e3bce0159317 motion fix from Gregory Kovriga <gkovriga@techunix.technion.ac.il>
pontscho
parents: 8864
diff changeset
670 }
e3bce0159317 motion fix from Gregory Kovriga <gkovriga@techunix.technion.ac.il>
pontscho
parents: 8864
diff changeset
671 }
e3bce0159317 motion fix from Gregory Kovriga <gkovriga@techunix.technion.ac.il>
pontscho
parents: 8864
diff changeset
672 goto buttonreleased;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
673 case ButtonRelease: i=Event->xbutton.button + 128; goto buttonreleased;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
674 case ButtonPress: i=Event->xbutton.button; goto buttonreleased;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
675 case EnterNotify: i=wsEnterWindow; goto buttonreleased;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
676 case LeaveNotify: i=wsLeaveWindow;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
677 buttonreleased:
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
678 if ( wsWindowList[l]->MouseHandler )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
679 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
680 break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
681
6967
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents: 6794
diff changeset
682 case SelectionNotify:
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents: 6794
diff changeset
683 /* Handle DandD */
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents: 6794
diff changeset
684 wsXDNDProcessSelection(wsWindowList[l],Event);
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents: 6794
diff changeset
685 break;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
686 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
687 XFlush( wsDisplay );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
688 XSync( wsDisplay,False );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
689 return !wsTrue;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
690 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
691
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
692 Bool wsDummyEvents( Display * display,XEvent * Event,XPointer arg )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
693 { return True; }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
694
4818
3473ca9ef158 new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents: 4566
diff changeset
695 void wsHandleEvents( void ){
1709
a4e0211455d8 GUI integration, step 1
arpi
parents: 1701
diff changeset
696 // handle pending events
a4e0211455d8 GUI integration, step 1
arpi
parents: 1701
diff changeset
697 while ( XPending(wsDisplay) ){
a4e0211455d8 GUI integration, step 1
arpi
parents: 1701
diff changeset
698 XNextEvent( wsDisplay,&wsEvent );
a4e0211455d8 GUI integration, step 1
arpi
parents: 1701
diff changeset
699 // printf("### X event: %d [%d]\n",wsEvent.type,delay);
a4e0211455d8 GUI integration, step 1
arpi
parents: 1701
diff changeset
700 wsEvents( wsDisplay,&wsEvent,NULL );
a4e0211455d8 GUI integration, step 1
arpi
parents: 1701
diff changeset
701 }
a4e0211455d8 GUI integration, step 1
arpi
parents: 1701
diff changeset
702 }
a4e0211455d8 GUI integration, step 1
arpi
parents: 1701
diff changeset
703
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
704 void wsMainLoop( void )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
705 {
1699
7ddc63b84f1f DGA2 ifdefs, new mainloop/timer stuff
arpi
parents: 1693
diff changeset
706 int delay=20;
5919
60cf2bca993f some bug fix
pontscho
parents: 5910
diff changeset
707 mp_msg( MSGT_GPLAYER,MSGL_STATUS,"[ws] init threads: %d\n",XInitThreads() );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
708 XSynchronize( wsDisplay,False );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
709 XLockDisplay( wsDisplay );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
710 // XIfEvent( wsDisplay,&wsEvent,wsEvents,NULL );
1699
7ddc63b84f1f DGA2 ifdefs, new mainloop/timer stuff
arpi
parents: 1693
diff changeset
711
7ddc63b84f1f DGA2 ifdefs, new mainloop/timer stuff
arpi
parents: 1693
diff changeset
712 #if 1
7ddc63b84f1f DGA2 ifdefs, new mainloop/timer stuff
arpi
parents: 1693
diff changeset
713
7ddc63b84f1f DGA2 ifdefs, new mainloop/timer stuff
arpi
parents: 1693
diff changeset
714 while(wsTrue){
7ddc63b84f1f DGA2 ifdefs, new mainloop/timer stuff
arpi
parents: 1693
diff changeset
715 // handle pending events
7ddc63b84f1f DGA2 ifdefs, new mainloop/timer stuff
arpi
parents: 1693
diff changeset
716 while ( XPending(wsDisplay) ){
7ddc63b84f1f DGA2 ifdefs, new mainloop/timer stuff
arpi
parents: 1693
diff changeset
717 XNextEvent( wsDisplay,&wsEvent );
7ddc63b84f1f DGA2 ifdefs, new mainloop/timer stuff
arpi
parents: 1693
diff changeset
718 wsEvents( wsDisplay,&wsEvent,NULL );
1701
7955814db4c7 removed delay debug printf, better 'active delay'
arpi
parents: 1699
diff changeset
719 delay=0;
1699
7ddc63b84f1f DGA2 ifdefs, new mainloop/timer stuff
arpi
parents: 1693
diff changeset
720 }
7ddc63b84f1f DGA2 ifdefs, new mainloop/timer stuff
arpi
parents: 1693
diff changeset
721 usleep(delay*1000); // FIXME!
1701
7955814db4c7 removed delay debug printf, better 'active delay'
arpi
parents: 1699
diff changeset
722 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
723 }
7ddc63b84f1f DGA2 ifdefs, new mainloop/timer stuff
arpi
parents: 1693
diff changeset
724
7ddc63b84f1f DGA2 ifdefs, new mainloop/timer stuff
arpi
parents: 1693
diff changeset
725 #else
7ddc63b84f1f DGA2 ifdefs, new mainloop/timer stuff
arpi
parents: 1693
diff changeset
726
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
727 while( wsTrue )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
728 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
729 XIfEvent( wsDisplay,&wsEvent,wsDummyEvents,NULL );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
730 wsEvents( wsDisplay,&wsEvent,NULL );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
731 }
1699
7ddc63b84f1f DGA2 ifdefs, new mainloop/timer stuff
arpi
parents: 1693
diff changeset
732 #endif
7ddc63b84f1f DGA2 ifdefs, new mainloop/timer stuff
arpi
parents: 1693
diff changeset
733
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
734 XUnlockDisplay( wsDisplay );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
735 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
736
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
737 // ----------------------------------------------------------------------------------------------
5997
b5fb9a927bf3 add WM detection, and wm specific fullscreen code. (???)
pontscho
parents: 5986
diff changeset
738 // Move window to selected layer
b5fb9a927bf3 add WM detection, and wm specific fullscreen code. (???)
pontscho
parents: 5986
diff changeset
739 // ----------------------------------------------------------------------------------------------
b5fb9a927bf3 add WM detection, and wm specific fullscreen code. (???)
pontscho
parents: 5986
diff changeset
740
b5fb9a927bf3 add WM detection, and wm specific fullscreen code. (???)
pontscho
parents: 5986
diff changeset
741 #define WIN_LAYER_ONBOTTOM 2
b5fb9a927bf3 add WM detection, and wm specific fullscreen code. (???)
pontscho
parents: 5986
diff changeset
742 #define WIN_LAYER_NORMAL 4
8150
851e974e6eaa updating
pontscho
parents: 8058
diff changeset
743 #define WIN_LAYER_ONTOP 10
5997
b5fb9a927bf3 add WM detection, and wm specific fullscreen code. (???)
pontscho
parents: 5986
diff changeset
744
b5fb9a927bf3 add WM detection, and wm specific fullscreen code. (???)
pontscho
parents: 5986
diff changeset
745 void wsSetLayer( Display * wsDisplay, Window win, int layer )
8864
b8c271750450 - sync with x11_common
pontscho
parents: 8478
diff changeset
746 { vo_x11_setlayer( wsDisplay,win,layer ); }
5997
b5fb9a927bf3 add WM detection, and wm specific fullscreen code. (???)
pontscho
parents: 5986
diff changeset
747
b5fb9a927bf3 add WM detection, and wm specific fullscreen code. (???)
pontscho
parents: 5986
diff changeset
748 // ----------------------------------------------------------------------------------------------
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
749 // Switch to fullscreen.
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
750 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
751 void wsFullScreen( wsTWindow * win )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
752 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
753 int decoration = 0;
5997
b5fb9a927bf3 add WM detection, and wm specific fullscreen code. (???)
pontscho
parents: 5986
diff changeset
754
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
755 if ( win->isFullScreen )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
756 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
757 win->X=win->OldX;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
758 win->Y=win->OldY;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
759 win->Width=win->OldWidth;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
760 win->Height=win->OldHeight;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
761 win->isFullScreen=False;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
762 decoration=win->Decorations;
8478
7988573021e8 disable DPMS handling
pontscho
parents: 8150
diff changeset
763 #ifdef ENABLE_DPMS
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
764 wsScreenSaverOn( wsDisplay );
8478
7988573021e8 disable DPMS handling
pontscho
parents: 8150
diff changeset
765 #endif
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
766 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
767 else
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
768 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
769 win->OldX=win->X; win->OldY=win->Y;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
770 win->OldWidth=win->Width; win->OldHeight=win->Height;
10194
2608bf0037b6 From: Ben Low <ben@bdlow.net>
pontscho
parents: 10170
diff changeset
771 win->X=wsOrgX; win->Y=wsOrgY;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
772 win->Width=wsMaxX; win->Height=wsMaxY;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
773 win->isFullScreen=True;
8478
7988573021e8 disable DPMS handling
pontscho
parents: 8150
diff changeset
774 #ifdef ENABLE_DPMS
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
775 wsScreenSaverOff( wsDisplay );
8478
7988573021e8 disable DPMS handling
pontscho
parents: 8150
diff changeset
776 #endif
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
777 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
778
9317
c7f5df43b937 - support command line parameter -fstype, eg. -fstype layer=12,above,fullscreen
filon
parents: 8973
diff changeset
779 vo_x11_decoration( wsDisplay,win->WindowID,decoration );
c7f5df43b937 - support command line parameter -fstype, eg. -fstype layer=12,above,fullscreen
filon
parents: 8973
diff changeset
780 vo_x11_sizehint( win->X,win->Y,win->Width,win->Height,0 );
8864
b8c271750450 - sync with x11_common
pontscho
parents: 8478
diff changeset
781 vo_x11_setlayer( wsDisplay,win->WindowID,win->isFullScreen );
11542
85e503ddf65f runtime 'stay-on-top' functionality
joey
parents: 10606
diff changeset
782
85e503ddf65f runtime 'stay-on-top' functionality
joey
parents: 10606
diff changeset
783 if ((!(win->isFullScreen)) & vo_ontop) vo_x11_setlayer(wsDisplay, win->WindowID,1);
85e503ddf65f runtime 'stay-on-top' functionality
joey
parents: 10606
diff changeset
784
9317
c7f5df43b937 - support command line parameter -fstype, eg. -fstype layer=12,above,fullscreen
filon
parents: 8973
diff changeset
785 if ( vo_wm_type == 0 && !(vo_fsmode&16) )
c7f5df43b937 - support command line parameter -fstype, eg. -fstype layer=12,above,fullscreen
filon
parents: 8973
diff changeset
786 XWithdrawWindow( wsDisplay,win->WindowID,wsScreen );
c7f5df43b937 - support command line parameter -fstype, eg. -fstype layer=12,above,fullscreen
filon
parents: 8973
diff changeset
787 XMoveResizeWindow( wsDisplay,win->WindowID,win->X,win->Y,win->Width,win->Height );
5910
20c335d98ab3 fix fullscreen bug es ilyen libvo not initialized bug with gui igy
pontscho
parents: 5031
diff changeset
788 XMapRaised( wsDisplay,win->WindowID );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
789 XRaiseWindow( wsDisplay,win->WindowID );
8864
b8c271750450 - sync with x11_common
pontscho
parents: 8478
diff changeset
790 XFlush( wsDisplay );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
791 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
792
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
793 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
794 // Redraw screen.
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
795 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
796 void wsPostRedisplay( wsTWindow * win )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
797 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
798 if ( win->ReDraw )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
799 {
6794
77980ab4e296 - add preferences support (first try)
pontscho
parents: 6651
diff changeset
800 win->State=wsWindowExpose;
8058
9246adcf95f0 cosmetic
pontscho
parents: 7892
diff changeset
801 win->ReDraw();
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
802 XFlush( wsDisplay );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
803 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
804 }
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 // Do Exit.
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
808 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
809 void wsDoExit( void )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
810 { wsTrue=False; wsResizeWindow( wsWindowList[0],32,32 ); }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
811
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
812 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
813 // Put 'Image' to window.
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
814 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
815 void wsConvert( wsTWindow * win,unsigned char * Image,unsigned int Size )
2733
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
816 { if ( wsConvFunc ) wsConvFunc( Image,win->ImageData,win->xImage->width * win->xImage->height * 4 ); }
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
817
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
818 void wsPutImage( wsTWindow * win )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
819 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
820 if ( wsUseXShm )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
821 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
822 XShmPutImage( wsDisplay,win->WindowID,win->wGC,win->xImage,
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
823 0,0,
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
824 ( win->Width - win->xImage->width ) / 2,( win->Height - win->xImage->height ) / 2,
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
825 win->xImage->width,win->xImage->height,0 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
826 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
827 else
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
828 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
829 XPutImage( wsDisplay,win->WindowID,win->wGC,win->xImage,
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
830 0,0,
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
831 ( win->Width - win->xImage->width ) / 2,( win->Height - win->xImage->height ) / 2,
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
832 win->xImage->width,win->xImage->height );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
833 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
834 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
835
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
836 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
837 // Move window to x, y.
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
838 // ----------------------------------------------------------------------------------------------
2854
fd44ecf77f8d move bug meg fileload bug fixed asszem.
pontscho
parents: 2851
diff changeset
839 void wsMoveWindow( wsTWindow * win,int b,int x, int y )
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
840 {
2854
fd44ecf77f8d move bug meg fileload bug fixed asszem.
pontscho
parents: 2851
diff changeset
841 if ( b )
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
842 {
2854
fd44ecf77f8d move bug meg fileload bug fixed asszem.
pontscho
parents: 2851
diff changeset
843 switch ( x )
fd44ecf77f8d move bug meg fileload bug fixed asszem.
pontscho
parents: 2851
diff changeset
844 {
10194
2608bf0037b6 From: Ben Low <ben@bdlow.net>
pontscho
parents: 10170
diff changeset
845 case -1: win->X=( wsMaxX / 2 ) - ( win->Width / 2 ) + wsOrgX; break;
2608bf0037b6 From: Ben Low <ben@bdlow.net>
pontscho
parents: 10170
diff changeset
846 case -2: win->X=wsMaxX - win->Width + wsOrgX; break;
2854
fd44ecf77f8d move bug meg fileload bug fixed asszem.
pontscho
parents: 2851
diff changeset
847 default: win->X=x; break;
fd44ecf77f8d move bug meg fileload bug fixed asszem.
pontscho
parents: 2851
diff changeset
848 }
fd44ecf77f8d move bug meg fileload bug fixed asszem.
pontscho
parents: 2851
diff changeset
849 switch ( y )
fd44ecf77f8d move bug meg fileload bug fixed asszem.
pontscho
parents: 2851
diff changeset
850 {
10194
2608bf0037b6 From: Ben Low <ben@bdlow.net>
pontscho
parents: 10170
diff changeset
851 case -1: win->Y=( wsMaxY / 2 ) - ( win->Height / 2 ) + wsOrgY; break;
2608bf0037b6 From: Ben Low <ben@bdlow.net>
pontscho
parents: 10170
diff changeset
852 case -2: win->Y=wsMaxY - win->Height + wsOrgY; break;
2854
fd44ecf77f8d move bug meg fileload bug fixed asszem.
pontscho
parents: 2851
diff changeset
853 default: win->Y=y; break;
fd44ecf77f8d move bug meg fileload bug fixed asszem.
pontscho
parents: 2851
diff changeset
854 }
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
855 }
2854
fd44ecf77f8d move bug meg fileload bug fixed asszem.
pontscho
parents: 2851
diff changeset
856 else { win->X=x; win->Y=y; }
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
857
2851
b64fa5d25142 add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents: 2782
diff changeset
858 win->SizeHint.flags=PPosition | PWinGravity;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
859 win->SizeHint.x=win->X;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
860 win->SizeHint.y=win->Y;
2851
b64fa5d25142 add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents: 2782
diff changeset
861 win->SizeHint.win_gravity=StaticGravity;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
862 XSetWMNormalHints( wsDisplay,win->WindowID,&win->SizeHint );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
863
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
864 XMoveWindow( wsDisplay,win->WindowID,win->X,win->Y );
1810
d44b0ce32791 fix move&resize
pontscho
parents: 1782
diff changeset
865 if ( win->ReSize ) win->ReSize( win->X,win->Y,win->Width,win->Height );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
866 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
867
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
868 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
869 // Resize window to sx, sy.
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
870 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
871 void wsResizeWindow( wsTWindow * win,int sx, int sy )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
872 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
873 win->Width=sx;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
874 win->Height=sy;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
875
5997
b5fb9a927bf3 add WM detection, and wm specific fullscreen code. (???)
pontscho
parents: 5986
diff changeset
876 win->SizeHint.flags=PPosition | PSize | PWinGravity;// | PBaseSize;
5986
d34622ebaf45 window resize bug fixed
pontscho
parents: 5919
diff changeset
877 win->SizeHint.x=win->X;
d34622ebaf45 window resize bug fixed
pontscho
parents: 5919
diff changeset
878 win->SizeHint.y=win->Y;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
879 win->SizeHint.width=win->Width;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
880 win->SizeHint.height=win->Height;
5997
b5fb9a927bf3 add WM detection, and wm specific fullscreen code. (???)
pontscho
parents: 5986
diff changeset
881
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
882 if ( win->Property & wsMinSize )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
883 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
884 win->SizeHint.flags|=PMinSize;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
885 win->SizeHint.min_width=win->Width;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
886 win->SizeHint.min_height=win->Height;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
887 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
888 if ( win->Property & wsMaxSize )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
889 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
890 win->SizeHint.flags|=PMaxSize;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
891 win->SizeHint.max_width=win->Width;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
892 win->SizeHint.max_height=win->Height;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
893 }
5997
b5fb9a927bf3 add WM detection, and wm specific fullscreen code. (???)
pontscho
parents: 5986
diff changeset
894
2851
b64fa5d25142 add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents: 2782
diff changeset
895 win->SizeHint.win_gravity=StaticGravity;
5986
d34622ebaf45 window resize bug fixed
pontscho
parents: 5919
diff changeset
896 win->SizeHint.base_width=sx; win->SizeHint.base_height=sy;
5997
b5fb9a927bf3 add WM detection, and wm specific fullscreen code. (???)
pontscho
parents: 5986
diff changeset
897
9317
c7f5df43b937 - support command line parameter -fstype, eg. -fstype layer=12,above,fullscreen
filon
parents: 8973
diff changeset
898 if ( vo_wm_type == 0 ) XUnmapWindow( wsDisplay,win->WindowID );
5997
b5fb9a927bf3 add WM detection, and wm specific fullscreen code. (???)
pontscho
parents: 5986
diff changeset
899
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
900 XSetWMNormalHints( wsDisplay,win->WindowID,&win->SizeHint );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
901 XResizeWindow( wsDisplay,win->WindowID,sx,sy );
5986
d34622ebaf45 window resize bug fixed
pontscho
parents: 5919
diff changeset
902 XMapRaised( wsDisplay,win->WindowID );
1810
d44b0ce32791 fix move&resize
pontscho
parents: 1782
diff changeset
903 if ( win->ReSize ) win->ReSize( win->X,win->Y,win->Width,win->Height );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
904 }
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 // Iconify window.
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
908 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
909 void wsIconify( wsTWindow win )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
910 { XIconifyWindow( wsDisplay,win.WindowID,0 ); }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
911
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
912 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
913 // Move top the window.
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
914 // ----------------------------------------------------------------------------------------------
6146
b9651eb9749e fix some gtk bug...
pontscho
parents: 6089
diff changeset
915 void wsMoveTopWindow( Display * wsDisplay,Window win )
2851
b64fa5d25142 add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents: 2782
diff changeset
916 {
8864
b8c271750450 - sync with x11_common
pontscho
parents: 8478
diff changeset
917 // XUnmapWindow( wsDisplay,win );
b8c271750450 - sync with x11_common
pontscho
parents: 8478
diff changeset
918 // XMapWindow( wsDisplay,win );
b8c271750450 - sync with x11_common
pontscho
parents: 8478
diff changeset
919 XMapRaised( wsDisplay,win );
b8c271750450 - sync with x11_common
pontscho
parents: 8478
diff changeset
920 XRaiseWindow( wsDisplay,win );
2045
deb4aff05c44 fix other bugs
pontscho
parents: 2030
diff changeset
921 }
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
922
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
923 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
924 // Set window background to 'color'.
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
925 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
926 void wsSetBackground( wsTWindow * win,int color )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
927 { XSetWindowBackground( wsDisplay,win->WindowID,color ); }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
928
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
929 void wsSetBackgroundRGB( wsTWindow * win,int r,int g,int b )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
930 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
931 int color = 0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
932 switch ( wsOutMask )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
933 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
934 case wsRGB32:
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
935 case wsRGB24: color=( r << 16 ) + ( g << 8 ) + b; break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
936 case wsBGR32:
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
937 case wsBGR24: color=( b << 16 ) + ( g << 8 ) + r; break;
2733
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
938 case wsRGB16: PACK_RGB16( b,g,r,color ); break;
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
939 case wsBGR16: PACK_RGB16( r,g,b,color ); break;
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
940 case wsRGB15: PACK_RGB15( b,g,r,color ); break;
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
941 case wsBGR15: PACK_RGB15( r,g,b,color ); break;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
942 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
943 XSetWindowBackground( wsDisplay,win->WindowID,color );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
944 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
945
1814
9c674dc76ff3 add wsSetForegroundRGB
pontscho
parents: 1810
diff changeset
946 void wsSetForegroundRGB( wsTWindow * win,int r,int g,int b )
9c674dc76ff3 add wsSetForegroundRGB
pontscho
parents: 1810
diff changeset
947 {
9c674dc76ff3 add wsSetForegroundRGB
pontscho
parents: 1810
diff changeset
948 int color = 0;
9c674dc76ff3 add wsSetForegroundRGB
pontscho
parents: 1810
diff changeset
949 switch ( wsOutMask )
9c674dc76ff3 add wsSetForegroundRGB
pontscho
parents: 1810
diff changeset
950 {
9c674dc76ff3 add wsSetForegroundRGB
pontscho
parents: 1810
diff changeset
951 case wsRGB32:
9c674dc76ff3 add wsSetForegroundRGB
pontscho
parents: 1810
diff changeset
952 case wsRGB24: color=( r << 16 ) + ( g << 8 ) + b; break;
9c674dc76ff3 add wsSetForegroundRGB
pontscho
parents: 1810
diff changeset
953 case wsBGR32:
9c674dc76ff3 add wsSetForegroundRGB
pontscho
parents: 1810
diff changeset
954 case wsBGR24: color=( b << 16 ) + ( g << 8 ) + r; break;
2733
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
955 case wsRGB16: PACK_RGB16( b,g,r,color ); break;
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
956 case wsBGR16: PACK_RGB16( r,g,b,color ); break;
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
957 case wsRGB15: PACK_RGB15( b,g,r,color ); break;
4dddb055d2cd add prostproc/rgb2rgb
pontscho
parents: 2476
diff changeset
958 case wsBGR15: PACK_RGB15( r,g,b,color ); break;
1814
9c674dc76ff3 add wsSetForegroundRGB
pontscho
parents: 1810
diff changeset
959 }
9c674dc76ff3 add wsSetForegroundRGB
pontscho
parents: 1810
diff changeset
960 XSetForeground( wsDisplay,win->wGC,color );
9c674dc76ff3 add wsSetForegroundRGB
pontscho
parents: 1810
diff changeset
961 }
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
962
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
963 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
964 // Draw string at x,y with fc ( foreground color ) and bc ( background color ).
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
965 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
966 void wsDrawString( wsTWindow win,int x,int y,char * str,int fc,int bc )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
967 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
968 XSetForeground( wsDisplay,win.wGC,bc );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
969 XFillRectangle( wsDisplay,win.WindowID,win.wGC,x,y,
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
970 XTextWidth( win.Font,str,strlen( str ) ) + 20,
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
971 win.FontHeight + 2 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
972 XSetForeground( wsDisplay,win.wGC,fc );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
973 XDrawString( wsDisplay,win.WindowID,win.wGC,x + 10,y + 13,str,strlen( str ) );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
974 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
975
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
976 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
977 // Calculation string width.
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
978 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
979 int wsTextWidth( wsTWindow win,char * str )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
980 { return XTextWidth( win.Font,str,strlen( str ) ) + 20; }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
981
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
982 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
983 // Show / hide mouse cursor.
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
984 // ----------------------------------------------------------------------------------------------
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
985 void wsVisibleMouse( wsTWindow * win,int m )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
986 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
987 switch ( m )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
988 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
989 case wsShowMouseCursor:
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
990 if ( win->wsCursor != None )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
991 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
992 XFreeCursor( wsDisplay,win->wsCursor );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
993 win->wsCursor=None;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
994 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
995 XDefineCursor( wsDisplay,win->WindowID,0 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
996 break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
997 case wsHideMouseCursor:
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
998 win->wsCursor=XCreatePixmapCursor( wsDisplay,win->wsCursorPixmap,win->wsCursorPixmap,&win->wsColor,&win->wsColor,0,0 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
999 XDefineCursor( wsDisplay,win->WindowID,win->wsCursor );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1000 break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1001 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1002 XFlush( wsDisplay );
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 int wsGetDepthOnScreen( void )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1006 {
7802
037982e833a7 Choose a good visual from the list of supported visuals on the X11 server,
jkeil
parents: 7801
diff changeset
1007 int depth;
037982e833a7 Choose a good visual from the list of supported visuals on the X11 server,
jkeil
parents: 7801
diff changeset
1008 XImage * mXImage;
037982e833a7 Choose a good visual from the list of supported visuals on the X11 server,
jkeil
parents: 7801
diff changeset
1009 Visual * visual;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1010
7802
037982e833a7 Choose a good visual from the list of supported visuals on the X11 server,
jkeil
parents: 7801
diff changeset
1011 if( (depth = vo_find_depth_from_visuals( wsDisplay,wsScreen,&visual )) > 0 )
037982e833a7 Choose a good visual from the list of supported visuals on the X11 server,
jkeil
parents: 7801
diff changeset
1012 {
037982e833a7 Choose a good visual from the list of supported visuals on the X11 server,
jkeil
parents: 7801
diff changeset
1013 mXImage = XCreateImage( wsDisplay,visual,depth,ZPixmap,0,NULL,
037982e833a7 Choose a good visual from the list of supported visuals on the X11 server,
jkeil
parents: 7801
diff changeset
1014 1,1,32,0 );
037982e833a7 Choose a good visual from the list of supported visuals on the X11 server,
jkeil
parents: 7801
diff changeset
1015 wsDepthOnScreen = mXImage->bits_per_pixel;
037982e833a7 Choose a good visual from the list of supported visuals on the X11 server,
jkeil
parents: 7801
diff changeset
1016 wsRedMask=mXImage->red_mask;
037982e833a7 Choose a good visual from the list of supported visuals on the X11 server,
jkeil
parents: 7801
diff changeset
1017 wsGreenMask=mXImage->green_mask;
037982e833a7 Choose a good visual from the list of supported visuals on the X11 server,
jkeil
parents: 7801
diff changeset
1018 wsBlueMask=mXImage->blue_mask;
037982e833a7 Choose a good visual from the list of supported visuals on the X11 server,
jkeil
parents: 7801
diff changeset
1019 XDestroyImage( mXImage );
037982e833a7 Choose a good visual from the list of supported visuals on the X11 server,
jkeil
parents: 7801
diff changeset
1020 }
037982e833a7 Choose a good visual from the list of supported visuals on the X11 server,
jkeil
parents: 7801
diff changeset
1021 else
037982e833a7 Choose a good visual from the list of supported visuals on the X11 server,
jkeil
parents: 7801
diff changeset
1022 {
037982e833a7 Choose a good visual from the list of supported visuals on the X11 server,
jkeil
parents: 7801
diff changeset
1023 int bpp,ibpp;
037982e833a7 Choose a good visual from the list of supported visuals on the X11 server,
jkeil
parents: 7801
diff changeset
1024 XWindowAttributes attribs;
037982e833a7 Choose a good visual from the list of supported visuals on the X11 server,
jkeil
parents: 7801
diff changeset
1025
037982e833a7 Choose a good visual from the list of supported visuals on the X11 server,
jkeil
parents: 7801
diff changeset
1026 mXImage=XGetImage( wsDisplay,wsRootWin,0,0,1,1,AllPlanes,ZPixmap );
037982e833a7 Choose a good visual from the list of supported visuals on the X11 server,
jkeil
parents: 7801
diff changeset
1027 bpp=mXImage->bits_per_pixel;
037982e833a7 Choose a good visual from the list of supported visuals on the X11 server,
jkeil
parents: 7801
diff changeset
1028
037982e833a7 Choose a good visual from the list of supported visuals on the X11 server,
jkeil
parents: 7801
diff changeset
1029 XGetWindowAttributes( wsDisplay,wsRootWin,&attribs );
037982e833a7 Choose a good visual from the list of supported visuals on the X11 server,
jkeil
parents: 7801
diff changeset
1030 ibpp=attribs.depth;
037982e833a7 Choose a good visual from the list of supported visuals on the X11 server,
jkeil
parents: 7801
diff changeset
1031 mXImage=XGetImage( wsDisplay,wsRootWin,0,0,1,1,AllPlanes,ZPixmap );
037982e833a7 Choose a good visual from the list of supported visuals on the X11 server,
jkeil
parents: 7801
diff changeset
1032 bpp=mXImage->bits_per_pixel;
037982e833a7 Choose a good visual from the list of supported visuals on the X11 server,
jkeil
parents: 7801
diff changeset
1033 if ( ( ibpp + 7 ) / 8 != ( bpp + 7 ) / 8 ) ibpp=bpp;
037982e833a7 Choose a good visual from the list of supported visuals on the X11 server,
jkeil
parents: 7801
diff changeset
1034 wsDepthOnScreen=ibpp;
037982e833a7 Choose a good visual from the list of supported visuals on the X11 server,
jkeil
parents: 7801
diff changeset
1035 wsRedMask=mXImage->red_mask;
037982e833a7 Choose a good visual from the list of supported visuals on the X11 server,
jkeil
parents: 7801
diff changeset
1036 wsGreenMask=mXImage->green_mask;
037982e833a7 Choose a good visual from the list of supported visuals on the X11 server,
jkeil
parents: 7801
diff changeset
1037 wsBlueMask=mXImage->blue_mask;
037982e833a7 Choose a good visual from the list of supported visuals on the X11 server,
jkeil
parents: 7801
diff changeset
1038 XDestroyImage( mXImage );
037982e833a7 Choose a good visual from the list of supported visuals on the X11 server,
jkeil
parents: 7801
diff changeset
1039 }
037982e833a7 Choose a good visual from the list of supported visuals on the X11 server,
jkeil
parents: 7801
diff changeset
1040 return wsDepthOnScreen;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1041 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1042
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1043 void wsXDone( void )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1044 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1045 XCloseDisplay( wsDisplay );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1046 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1047
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1048 void wsVisibleWindow( wsTWindow * win,int show )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1049 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1050 switch( show )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1051 {
5997
b5fb9a927bf3 add WM detection, and wm specific fullscreen code. (???)
pontscho
parents: 5986
diff changeset
1052 case wsShowWindow: XMapRaised( wsDisplay,win->WindowID ); break;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1053 case wsHideWindow: XUnmapWindow( wsDisplay,win->WindowID ); break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1054 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1055 XFlush( wsDisplay );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1056 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1057
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1058 void wsDestroyImage( wsTWindow * win )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1059 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1060 if ( win->xImage )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1061 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1062 XDestroyImage( win->xImage );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1063 if ( wsUseXShm )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1064 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1065 XShmDetach( wsDisplay,&win->Shminfo );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1066 shmdt( win->Shminfo.shmaddr );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1067 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1068 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1069 win->xImage=NULL;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1070 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1071
1858
88a88d0a3f94 fix skin changing, xv fullscreen redraw bug, etc.
pontscho
parents: 1853
diff changeset
1072 void wsCreateImage( wsTWindow * win,int Width,int Height )
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1073 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1074 int CompletionType = -1;
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 CompletionType=XShmGetEventBase( wsDisplay ) + ShmCompletion;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1078 win->xImage=XShmCreateImage( wsDisplay,win->VisualInfo.visual,
7802
037982e833a7 Choose a good visual from the list of supported visuals on the X11 server,
jkeil
parents: 7801
diff changeset
1079 win->VisualInfo.depth,ZPixmap,NULL,&win->Shminfo,Width,Height );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1080 if ( win->xImage == NULL )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1081 {
5919
60cf2bca993f some bug fix
pontscho
parents: 5910
diff changeset
1082 mp_msg( MSGT_GPLAYER,MSGL_FATAL,"[ws] shared memory extension error.\n" );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1083 exit( 0 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1084 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1085 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
1086 if ( win->Shminfo.shmid < 0 )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1087 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1088 XDestroyImage( win->xImage );
5919
60cf2bca993f some bug fix
pontscho
parents: 5910
diff changeset
1089 mp_msg( MSGT_GPLAYER,MSGL_FATAL,"[ws] shared memory extension error.\n" );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1090 exit( 0 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1091 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1092 win->Shminfo.shmaddr=(char *)shmat( win->Shminfo.shmid,0,0 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1093
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1094 if ( win->Shminfo.shmaddr == ((char *) -1) )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1095 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1096 XDestroyImage( win->xImage );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1097 if ( win->Shminfo.shmaddr != ((char *) -1) ) shmdt( win->Shminfo.shmaddr );
5919
60cf2bca993f some bug fix
pontscho
parents: 5910
diff changeset
1098 mp_msg( MSGT_GPLAYER,MSGL_FATAL,"[ws] shared memory extension error.\n" );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1099 exit( 0 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1100 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1101 win->xImage->data=win->Shminfo.shmaddr;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1102 win->Shminfo.readOnly=0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1103 XShmAttach( wsDisplay,&win->Shminfo );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1104 shmctl( win->Shminfo.shmid,IPC_RMID,0 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1105 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1106 else
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1107 {
7802
037982e833a7 Choose a good visual from the list of supported visuals on the X11 server,
jkeil
parents: 7801
diff changeset
1108 win->xImage=XCreateImage( wsDisplay,win->VisualInfo.visual,win->VisualInfo.depth,
1858
88a88d0a3f94 fix skin changing, xv fullscreen redraw bug, etc.
pontscho
parents: 1853
diff changeset
1109 ZPixmap,0,0,Width,Height,
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1110 (wsDepthOnScreen == 3) ? 32 : wsDepthOnScreen,
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1111 0 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1112 if ( ( win->xImage->data=malloc( win->xImage->bytes_per_line * win->xImage->height ) ) == NULL )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1113 {
5919
60cf2bca993f some bug fix
pontscho
parents: 5910
diff changeset
1114 mp_msg( MSGT_GPLAYER,MSGL_FATAL,"[ws] sorry, not enough memory for draw buffer.\n" );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1115 exit( 0 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1116 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1117 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1118 win->ImageData=(unsigned char *)win->xImage->data;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1119 win->ImageDataw=(unsigned short int *)win->xImage->data;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1120 win->ImageDatadw=(unsigned int *)win->xImage->data;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1121 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1122
1858
88a88d0a3f94 fix skin changing, xv fullscreen redraw bug, etc.
pontscho
parents: 1853
diff changeset
1123 void wsResizeImage( wsTWindow * win,int Width,int Height )
88a88d0a3f94 fix skin changing, xv fullscreen redraw bug, etc.
pontscho
parents: 1853
diff changeset
1124 { wsDestroyImage( win ); wsCreateImage( win,Width,Height ); }
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1125
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1126 int wsGetOutMask( void )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1127 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1128 if ( ( wsDepthOnScreen == 32 )&&( wsRedMask == 0xff0000 )&&( wsGreenMask == 0x00ff00 )&&( wsBlueMask == 0x0000ff ) ) return wsRGB32;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1129 if ( ( wsDepthOnScreen == 32 )&&( wsRedMask == 0x0000ff )&&( wsGreenMask == 0x00ff00 )&&( wsBlueMask == 0xff0000 ) ) return wsBGR32;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1130 if ( ( wsDepthOnScreen == 24 )&&( wsRedMask == 0xff0000 )&&( wsGreenMask == 0x00ff00 )&&( wsBlueMask == 0x0000ff ) ) return wsRGB24;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1131 if ( ( wsDepthOnScreen == 24 )&&( wsRedMask == 0x0000ff )&&( wsGreenMask == 0x00ff00 )&&( wsBlueMask == 0xff0000 ) ) return wsBGR24;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1132 if ( ( wsDepthOnScreen == 16 )&&( wsRedMask == 0xf800 )&&( wsGreenMask == 0x7e0 )&&( wsBlueMask == 0x1f ) ) return wsRGB16;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1133 if ( ( wsDepthOnScreen == 16 )&&( wsRedMask == 0x1f )&&( wsGreenMask == 0x7e0 )&&( wsBlueMask == 0xf800 ) ) return wsBGR16;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1134 if ( ( wsDepthOnScreen == 15 )&&( wsRedMask == 0x7c00 )&&( wsGreenMask == 0x3e0 )&&( wsBlueMask == 0x1f ) ) return wsRGB15;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1135 if ( ( wsDepthOnScreen == 15 )&&( wsRedMask == 0x1f )&&( wsGreenMask == 0x3e0 )&&( wsBlueMask == 0x7c00 ) ) return wsBGR15;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1136 return 0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1137 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1138
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1139 void wsSetTitle( wsTWindow * win,char * name )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1140 { XStoreName( wsDisplay,win->WindowID,name ); }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1141
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1142 void wsSetMousePosition( wsTWindow * win,int x, int y )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1143 { XWarpPointer( wsDisplay,wsRootWin,win->WindowID,0,0,0,0,x,y ); }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1144
8478
7988573021e8 disable DPMS handling
pontscho
parents: 8150
diff changeset
1145 #ifdef ENABLE_DPMS
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1146 static int dpms_disabled=0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1147 static int timeout_save=0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1148
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1149 void wsScreenSaverOn( Display *mDisplay )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1150 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1151 int nothing;
4566
3b1721b9e211 fix dpsm compile bug in gui
pontscho
parents: 4465
diff changeset
1152 #ifdef HAVE_XDPMS
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1153 if ( dpms_disabled )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1154 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1155 if ( DPMSQueryExtension( mDisplay,&nothing,&nothing ) )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1156 {
5919
60cf2bca993f some bug fix
pontscho
parents: 5910
diff changeset
1157 if ( !DPMSEnable( mDisplay ) ) mp_msg( MSGT_GPLAYER,MSGL_ERR,"DPMS not available ?\n" ); // restoring power saving settings
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1158 else
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1159 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1160 // DPMS does not seem to be enabled unless we call DPMSInfo
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1161 BOOL onoff;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1162 CARD16 state;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1163 DPMSInfo( mDisplay,&state,&onoff );
5919
60cf2bca993f some bug fix
pontscho
parents: 5910
diff changeset
1164 if ( onoff ) mp_msg( MSGT_GPLAYER,MSGL_STATUS,"Successfully enabled DPMS.\n" );
60cf2bca993f some bug fix
pontscho
parents: 5910
diff changeset
1165 else mp_msg( MSGT_GPLAYER,MSGL_STATUS,"Could not enable DPMS.\n" );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1166 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1167 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1168 }
4566
3b1721b9e211 fix dpsm compile bug in gui
pontscho
parents: 4465
diff changeset
1169 #endif
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1170 if ( timeout_save )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1171 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1172 int dummy, interval, prefer_blank, allow_exp;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1173 XGetScreenSaver( mDisplay,&dummy,&interval,&prefer_blank,&allow_exp );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1174 XSetScreenSaver( mDisplay,timeout_save,interval,prefer_blank,allow_exp );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1175 XGetScreenSaver( mDisplay,&timeout_save,&interval,&prefer_blank,&allow_exp );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1176 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1177 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1178
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1179 void wsScreenSaverOff( Display * mDisplay )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1180 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1181 int interval,prefer_blank,allow_exp,nothing;
4566
3b1721b9e211 fix dpsm compile bug in gui
pontscho
parents: 4465
diff changeset
1182 #ifdef HAVE_XDPMS
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1183 if ( DPMSQueryExtension( mDisplay,&nothing,&nothing ) )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1184 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1185 BOOL onoff;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1186 CARD16 state;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1187 DPMSInfo( mDisplay,&state,&onoff );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1188 if ( onoff )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1189 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1190 Status stat;
5919
60cf2bca993f some bug fix
pontscho
parents: 5910
diff changeset
1191 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"Disabling DPMS.\n" );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1192 dpms_disabled=1;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1193 stat=DPMSDisable( mDisplay ); // monitor powersave off
5919
60cf2bca993f some bug fix
pontscho
parents: 5910
diff changeset
1194 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"stat: %d.\n",stat );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1195 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1196 }
4566
3b1721b9e211 fix dpsm compile bug in gui
pontscho
parents: 4465
diff changeset
1197 #endif
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1198 XGetScreenSaver( mDisplay,&timeout_save,&interval,&prefer_blank,&allow_exp );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1199 if ( timeout_save ) XSetScreenSaver( mDisplay,0,interval,prefer_blank,allow_exp ); // turning off screensaver
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1200 }
8478
7988573021e8 disable DPMS handling
pontscho
parents: 8150
diff changeset
1201 #endif
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1202
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1203 void wsSetShape( wsTWindow * win,char * data )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1204 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1205 #ifdef HAVE_XSHAPE
1852
58dd326fcc4a fix xshape, mixer, fullscreen, etc
pontscho
parents: 1850
diff changeset
1206 if ( !wsUseXShape ) return;
58dd326fcc4a fix xshape, mixer, fullscreen, etc
pontscho
parents: 1850
diff changeset
1207 if ( data )
58dd326fcc4a fix xshape, mixer, fullscreen, etc
pontscho
parents: 1850
diff changeset
1208 {
58dd326fcc4a fix xshape, mixer, fullscreen, etc
pontscho
parents: 1850
diff changeset
1209 win->Mask=XCreateBitmapFromData( wsDisplay,win->WindowID,data,win->Width,win->Height );
58dd326fcc4a fix xshape, mixer, fullscreen, etc
pontscho
parents: 1850
diff changeset
1210 XShapeCombineMask( wsDisplay,win->WindowID,ShapeBounding,0,0,win->Mask,ShapeSet );
58dd326fcc4a fix xshape, mixer, fullscreen, etc
pontscho
parents: 1850
diff changeset
1211 XFreePixmap( wsDisplay,win->Mask );
58dd326fcc4a fix xshape, mixer, fullscreen, etc
pontscho
parents: 1850
diff changeset
1212 }
58dd326fcc4a fix xshape, mixer, fullscreen, etc
pontscho
parents: 1850
diff changeset
1213 else XShapeCombineMask( wsDisplay,win->WindowID,ShapeBounding,0,0,None,ShapeSet );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1214 #endif
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1215 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1216
6651
8f49c75a2824 - add icon (nice, but very ugly hakk:)
pontscho
parents: 6622
diff changeset
1217 void wsSetIcon( Display * dsp,Window win,Pixmap icon,Pixmap mask )
8f49c75a2824 - add icon (nice, but very ugly hakk:)
pontscho
parents: 6622
diff changeset
1218 {
8f49c75a2824 - add icon (nice, but very ugly hakk:)
pontscho
parents: 6622
diff changeset
1219 XWMHints * wm;
8f49c75a2824 - add icon (nice, but very ugly hakk:)
pontscho
parents: 6622
diff changeset
1220 long data[2];
8f49c75a2824 - add icon (nice, but very ugly hakk:)
pontscho
parents: 6622
diff changeset
1221 Atom iconatom;
8f49c75a2824 - add icon (nice, but very ugly hakk:)
pontscho
parents: 6622
diff changeset
1222
8f49c75a2824 - add icon (nice, but very ugly hakk:)
pontscho
parents: 6622
diff changeset
1223 wm=XGetWMHints( dsp,win );
8f49c75a2824 - add icon (nice, but very ugly hakk:)
pontscho
parents: 6622
diff changeset
1224 if ( !wm ) wm=XAllocWMHints();
8f49c75a2824 - add icon (nice, but very ugly hakk:)
pontscho
parents: 6622
diff changeset
1225
8f49c75a2824 - add icon (nice, but very ugly hakk:)
pontscho
parents: 6622
diff changeset
1226 wm->icon_pixmap=icon;
8f49c75a2824 - add icon (nice, but very ugly hakk:)
pontscho
parents: 6622
diff changeset
1227 wm->icon_mask=mask;
8f49c75a2824 - add icon (nice, but very ugly hakk:)
pontscho
parents: 6622
diff changeset
1228 wm->flags|=IconPixmapHint | IconMaskHint;
8f49c75a2824 - add icon (nice, but very ugly hakk:)
pontscho
parents: 6622
diff changeset
1229
8f49c75a2824 - add icon (nice, but very ugly hakk:)
pontscho
parents: 6622
diff changeset
1230 XSetWMHints( dsp,win,wm );
8f49c75a2824 - add icon (nice, but very ugly hakk:)
pontscho
parents: 6622
diff changeset
1231
8f49c75a2824 - add icon (nice, but very ugly hakk:)
pontscho
parents: 6622
diff changeset
1232 data[0]=icon;
8f49c75a2824 - add icon (nice, but very ugly hakk:)
pontscho
parents: 6622
diff changeset
1233 data[1]=mask;
8f49c75a2824 - add icon (nice, but very ugly hakk:)
pontscho
parents: 6622
diff changeset
1234 iconatom=XInternAtom( dsp,"KWM_WIN_ICON",0 );
8f49c75a2824 - add icon (nice, but very ugly hakk:)
pontscho
parents: 6622
diff changeset
1235 XChangeProperty( dsp,win,iconatom,iconatom,32,PropModeReplace,(unsigned char *)data,2 );
8f49c75a2824 - add icon (nice, but very ugly hakk:)
pontscho
parents: 6622
diff changeset
1236
8f49c75a2824 - add icon (nice, but very ugly hakk:)
pontscho
parents: 6622
diff changeset
1237 XFree( wm );
8f49c75a2824 - add icon (nice, but very ugly hakk:)
pontscho
parents: 6622
diff changeset
1238 }
8f49c75a2824 - add icon (nice, but very ugly hakk:)
pontscho
parents: 6622
diff changeset
1239
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1240 #include "wsmkeys.h"