1
/* Ekiga -- A VoIP and Video-Conferencing application
2
* Copyright (C) 2000-2007 Damien Sandras
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software Foundation,
16
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
19
* Ekiga is licensed under the GPL license and as a special exception,
20
* you have permission to link or otherwise combine this program with the
21
* programs OPAL, OpenH323 and PWLIB, and distribute the combination,
22
* without applying the requirements of the GNU GPL to the OPAL, OpenH323
23
* and PWLIB programs, as long as you do follow the requirements of the
24
* GNU GPL for all the rest of the software thus combined.
28
* XWindow.h - description
29
* --------------------------
30
* begin : Fri Oct 26 2007
31
* copyright : (C) 2007 by Matthias Schneider <ma30002000@yahoo.de>
32
* description : High-level class unaccelerated X Video output
42
#include <ptlib/videoio.h>
43
#include <ptlib/vconvert.h>
46
#include <X11/Xutil.h>
47
#include <X11/Xatom.h>
49
#include <X11/extensions/XShm.h>
54
* String: wrapper/helper.
56
* This class provides XVideo support under Linux if it is supported by the graphics hardware and driver.
57
* XVideo makes use of hardware capabilities in order to do
58
* - colorspace transformation
62
* This class features a fullscreen mode, an always-on-top mode and allows to enable and disable the window
63
* manager decorations. A picture-in-picture functionality is provided by registering a second XVWindow class
64
* window as a slave window. This class should work with most if not all window managers. It has to initialized
65
* with the display and window where it shall appear and the original image and intial window size
66
* After having been initialized successfully a frame is passed via PutFrame which takes care of the presentation.
68
* @author Matthias Schneider
78
virtual int Init (Display *dp,
88
virtual void PutFrame (uint8_t *frame,
92
virtual bool ProcessEvents();
96
virtual void ToggleFullscreen ();
98
virtual void ToggleOntop ();
100
virtual void ToggleDecoration ();
102
virtual void SetWindow (int x,
104
unsigned int windowWidth,
105
unsigned int windowHeight);
107
virtual void GetWindow (int *x,
109
unsigned int *windowWidth,
110
unsigned int *windowHeight);
112
virtual bool IsFullScreen () const { return _state.fullscreen; };
114
virtual bool HasDecoration () const { return _state.decoration; };
116
virtual bool IsOntop () const { return _state.ontop; };
118
virtual Window GetWindowHandle () const { return _XWindow; };
120
virtual Display* GetDisplay () const { return _display; };
122
virtual GC GetGC () const { return _gc; };
124
virtual int GetYUVWidth () const { return _imageWidth; };
126
virtual int GetYUVHeight() const { return _imageHeight; };
128
virtual void RegisterMaster (XWindow *master) { _master = master; };
130
virtual void RegisterSlave (XWindow *slave) { _slave = slave; };
132
virtual void SetSwScalingAlgo (unsigned int algorithm) { _scalingAlgorithm = algorithm; };
135
static bool _shmError;
175
unsigned int _scalingAlgorithm;
177
Atom XA_NET_SUPPORTED;
178
Atom XA_WIN_PROTOCOLS;
180
Atom XA_NET_WM_STATE;
181
Atom XA_NET_WM_STATE_FULLSCREEN;
182
Atom XA_NET_WM_STATE_ABOVE;
183
Atom XA_NET_WM_STATE_STAYS_ON_TOP;
184
Atom XA_NET_WM_STATE_BELOW;
185
Atom WM_DELETE_WINDOW;
187
virtual bool CreateAtomsAndWindow(GC gc,
194
* Sets the layer for the window.
196
virtual void SetLayer (int layer);
199
* Fullscreen for ewmh WMs.
201
virtual void SetEWMHFullscreen (int action);
204
* Toggle window decoration on and off
206
virtual void SetDecoration (bool d);
209
* Detects window manager type.
211
virtual int GetWMType ();
213
virtual int GetGnomeLayer ();
218
virtual int GetSupportedState (Atom atom);
221
* Returns the root window's.
223
virtual int GetWindowProperty (Atom type,
225
unsigned long *nitems);
227
virtual void CalculateSize (int width,
229
bool doAspectCorrection);
231
virtual void SetSizeHints (int x,
240
char* _imageDataOrig;
242
char _colorFormat[6];
245
PColourConverter* _colorConverter;
246
uint8_t* _frameBuffer;
249
XShmSegmentInfo _XShmInfo;
255
virtual bool checkDepth ();
258
* Attach to Shared Memory
261
virtual void ShmAttach(int imageWidth, int imageHeight);
264
virtual void CreateXImage(int width, int height);
266
virtual void DumpVisuals();
270
#define wm_FULLSCREEN 2
271
#define wm_STAYS_ON_TOP 4
274
#define wm_NETWM (wm_FULLSCREEN | wm_STAYS_ON_TOP | wm_ABOVE | wm_BELOW)
276
#define WIN_LAYER_ONBOTTOM 2
277
#define WIN_LAYER_NORMAL 4
278
#define WIN_LAYER_ONTOP 6
279
#define WIN_LAYER_ABOVE_DOCK 10
281
#define _NET_WM_STATE_REMOVE 0 /* remove/unset property */
282
#define _NET_WM_STATE_ADD 1 /* add/set property */
283
#define _NET_WM_STATE_TOGGLE 2 /* toggle property */
285
#define MWM_HINTS_FUNCTIONS (1L << 0)
286
#define MWM_HINTS_DECORATIONS (1L << 1)
287
#define MWM_FUNC_RESIZE (1L << 1)
288
#define MWM_FUNC_MOVE (1L << 2)
289
#define MWM_FUNC_MINIMIZE (1L << 3)
290
#define MWM_FUNC_MAXIMIZE (1L << 4)
291
#define MWM_FUNC_CLOSE (1L << 5)
292
#define MWM_DECOR_ALL (1L << 0)
293
#define MWM_DECOR_MENU (1L << 4)
295
#define PIP_RATIO_WIN 3
296
#define PIP_RATIO_FS 5