~ubuntu-branches/ubuntu/maverick/ekiga/maverick

« back to all changes in this revision

Viewing changes to lib/gui/xwindow.h

  • Committer: Bazaar Package Importer
  • Author(s): Eugen Dedu, Eugen Dedu, Loic Minier
  • Date: 2008-09-27 10:00:00 UTC
  • mfrom: (1.1.8 upstream)
  • mto: (1.4.1 squeeze)
  • mto: This revision was merged to the branch mainline in revision 38.
  • Revision ID: james.westby@ubuntu.com-20080927100000-l5k5werb6czr5b3h
Tags: 3.0.1-1
[ Eugen Dedu ]
* New version.  (Closes: #500089).
* Add our own changelog file in /usr/share/doc.
* Remove gnomemeeting transitional package.
* Discover new interfaces.  (Closes: #488199).
* Compile with dbus support.  (Closes: #467212).
* Numeric keypad inserts digits at correct position.  (Closes: #440159).
* Use libnotify upon call.  (Closes: #412604).
* Symlink identical GNOME help files, to reduce size.  (Closes: #505536).
* Explicitely build-depends on a few dev packages, even if they were
  pulled out anyway by the other dependencies.

[ Loic Minier ]
* Use clean:: instead of clean: in rules.
* Don't disable Uploaders: generation for control.in -> control generation
  in rules.
* Fix some tabs which were size 4 anyway.
* Generate a PO template during build by calling intltool-update -p in
  install; thanks Ubuntu and Martin Pitt; closes: #505535.
* Also let the -dbg depend on ${misc:Depends}.
* Cleanup rules; in particular, use dpkg-parsechangelog and honor
  distclean/clean failures, remove old clean rules, commented out stuff,
  gtk-only stuff.
* Pass -s to dh_* in binary-arch.
* Use debian/*.links and debian/*.manpages instead of symlink manually or
  passing files to dh_installman.
* Use ftp.gnome.org in copyright.
* Switch to quilt and fix target deps in the process; build-dep on quilt
  instead of dpatch; rename news.dpatch to 00_news.patch and refresh;
  replace 00list with series.
* Install autotools-dev config.guess and .sub after patching.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Ekiga -- A VoIP and Video-Conferencing application
 
2
 * Copyright (C) 2000-2007 Damien Sandras
 
3
 *
 
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.
 
8
 *
 
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.
 
13
 *
 
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.
 
17
 *
 
18
 *
 
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.
 
25
 */
 
26
 
 
27
/*
 
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 
 
33
 */
 
34
 
 
35
 
 
36
#ifndef XWINDOW_H
 
37
#define XWINDOW_H
 
38
 
 
39
#include <stdint.h>
 
40
#include "config.h"
 
41
 
 
42
#include <ptlib/videoio.h>
 
43
#include <ptlib/vconvert.h>
 
44
 
 
45
#include <X11/Xlib.h>
 
46
#include <X11/Xutil.h>
 
47
#include <X11/Xatom.h>
 
48
#ifdef HAVE_SHM
 
49
#include <X11/extensions/XShm.h>
 
50
#endif
 
51
 
 
52
 
 
53
/**
 
54
 * String: wrapper/helper.
 
55
 *
 
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
 
59
 * - scaling
 
60
 * - anti-aliasing
 
61
 *
 
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.
 
67
 *
 
68
 * @author Matthias Schneider
 
69
 */
 
70
class XWindow
 
71
{
 
72
public:
 
73
 
 
74
  XWindow();
 
75
 
 
76
  virtual ~XWindow();
 
77
  
 
78
  virtual int Init (Display *dp, 
 
79
            Window xvWindow, 
 
80
            GC gc, 
 
81
            int x, 
 
82
            int y, 
 
83
            int windowWidth, 
 
84
            int windowHeight, 
 
85
            int imageWidth, 
 
86
            int imageHeight);
 
87
 
 
88
  virtual void PutFrame (uint8_t *frame, 
 
89
                 uint16_t width, 
 
90
                 uint16_t height);
 
91
 
 
92
  virtual bool ProcessEvents();
 
93
  
 
94
  virtual void Sync();
 
95
 
 
96
  virtual void ToggleFullscreen ();
 
97
 
 
98
  virtual void ToggleOntop ();
 
99
  
 
100
  virtual void ToggleDecoration ();
 
101
 
 
102
  virtual void SetWindow (int x, 
 
103
                  int y, 
 
104
                  unsigned int windowWidth, 
 
105
                  unsigned int windowHeight);
 
106
  
 
107
  virtual void GetWindow (int *x, 
 
108
                  int *y, 
 
109
                  unsigned int *windowWidth, 
 
110
                  unsigned int *windowHeight);
 
111
 
 
112
  virtual bool IsFullScreen () const { return _state.fullscreen; };
 
113
 
 
114
  virtual bool HasDecoration () const { return _state.decoration; };
 
115
 
 
116
  virtual bool IsOntop () const { return _state.ontop; };
 
117
 
 
118
  virtual Window GetWindowHandle () const { return _XWindow; };
 
119
 
 
120
  virtual Display* GetDisplay () const { return _display; };
 
121
 
 
122
  virtual GC GetGC () const { return _gc; };
 
123
 
 
124
  virtual int GetYUVWidth () const { return _imageWidth; };
 
125
 
 
126
  virtual int GetYUVHeight() const { return _imageHeight; };
 
127
 
 
128
  virtual void RegisterMaster (XWindow *master) { _master = master; };
 
129
 
 
130
  virtual void RegisterSlave (XWindow *slave) { _slave = slave; };
 
131
 
 
132
  virtual void SetSwScalingAlgo (unsigned int algorithm) { _scalingAlgorithm = algorithm; };
 
133
 
 
134
#ifdef HAVE_SHM
 
135
  static bool _shmError;
 
136
#endif
 
137
protected:
 
138
  Display *_display;
 
139
  Window _rootWindow;
 
140
  Window _XWindow;
 
141
  GC _gc;
 
142
  int _depth;
 
143
  XWindow * _master;
 
144
  XWindow * _slave;
 
145
  XVisualInfo _XVInfo;
 
146
 
 
147
  int _imageWidth;
 
148
  int _imageHeight;
 
149
 
 
150
  bool _useShm;
 
151
  bool _paintColorKey;
 
152
  int _colorKey;
 
153
  int _wmType;
 
154
  bool _isInitialized;
 
155
  bool _embedded;
 
156
 
 
157
  typedef struct 
 
158
  {
 
159
    bool fullscreen;
 
160
    bool ontop;
 
161
    bool decoration;
 
162
    int oldx;
 
163
    int oldy;
 
164
    int oldWidth;
 
165
    int oldHeight;
 
166
    int curX;
 
167
    int curY;
 
168
    int curWidth;
 
169
    int curHeight;
 
170
    int origLayer;
 
171
  } State;
 
172
 
 
173
  State _state;
 
174
 
 
175
  unsigned int _scalingAlgorithm;
 
176
 
 
177
  Atom XA_NET_SUPPORTED;
 
178
  Atom XA_WIN_PROTOCOLS;
 
179
  Atom XA_WIN_LAYER;
 
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;
 
186
 
 
187
  virtual bool CreateAtomsAndWindow(GC gc,
 
188
                                    int x, 
 
189
                                    int y,
 
190
                                    int windowWidth,
 
191
                                    int windowHeight);
 
192
 
 
193
  /**
 
194
   * Sets the layer for the window.
 
195
   */
 
196
  virtual void SetLayer (int layer);
 
197
 
 
198
  /**
 
199
   * Fullscreen for ewmh WMs.
 
200
   */
 
201
  virtual void SetEWMHFullscreen (int action);
 
202
 
 
203
  /**
 
204
   * Toggle window decoration on and off
 
205
   */
 
206
  virtual void SetDecoration (bool d);
 
207
 
 
208
  /**
 
209
   * Detects window manager type.
 
210
   */
 
211
  virtual int GetWMType ();
 
212
 
 
213
  virtual int GetGnomeLayer ();
 
214
 
 
215
  /**
 
216
   * Tests an atom.
 
217
   */
 
218
  virtual int GetSupportedState (Atom atom);
 
219
 
 
220
  /**
 
221
   * Returns the root window's.
 
222
   */
 
223
  virtual int GetWindowProperty (Atom type, 
 
224
                         Atom **args, 
 
225
                         unsigned long *nitems);
 
226
 
 
227
  virtual void CalculateSize (int width, 
 
228
                              int height, 
 
229
                              bool doAspectCorrection);
 
230
 
 
231
  virtual void SetSizeHints (int x,  
 
232
                     int y, 
 
233
                     int imageWidth, 
 
234
                     int imageHeight, 
 
235
                     int windowWidth, 
 
236
                     int windowHeight);
 
237
private:
 
238
 
 
239
  XImage * _XImage;
 
240
  char* _imageDataOrig;
 
241
  int _outOffset;
 
242
  char _colorFormat[6];
 
243
  int _planes;
 
244
 
 
245
  PColourConverter* _colorConverter;
 
246
  uint8_t* _frameBuffer;
 
247
  
 
248
#ifdef HAVE_SHM
 
249
  XShmSegmentInfo _XShmInfo;
 
250
#endif
 
251
 
 
252
  /**
 
253
   * Verify pixel depth
 
254
   */
 
255
  virtual bool checkDepth ();
 
256
 
 
257
  /**
 
258
   * Attach to Shared Memory
 
259
   */
 
260
#ifdef HAVE_SHM  
 
261
  virtual void ShmAttach(int imageWidth, int imageHeight);
 
262
#endif
 
263
 
 
264
  virtual void CreateXImage(int width, int height);
 
265
 
 
266
  virtual void DumpVisuals();
 
267
};
 
268
 
 
269
#define wm_LAYER         1
 
270
#define wm_FULLSCREEN    2
 
271
#define wm_STAYS_ON_TOP  4
 
272
#define wm_ABOVE         8
 
273
#define wm_BELOW         16
 
274
#define wm_NETWM (wm_FULLSCREEN | wm_STAYS_ON_TOP | wm_ABOVE | wm_BELOW)
 
275
 
 
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
 
280
 
 
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 */
 
284
 
 
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)
 
294
 
 
295
#define PIP_RATIO_WIN  3
 
296
#define PIP_RATIO_FS   5
 
297
#define DEFAULT_X 1
 
298
#define DEFAULT_Y 1
 
299
 
 
300
typedef struct
 
301
{
 
302
  int flags;
 
303
  long functions;
 
304
  long decorations;
 
305
  long input_mode;
 
306
  long state;
 
307
} MotifWmHints;
 
308
 
 
309
#endif //XWINDOW_H