1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
|
/* -*-c++-*-
*
* $Id: PxWindow.h,v 1.1.1.1 2003/02/08 00:42:21 dairiki Exp $
*
* Copyright (C) 2003 Geoffrey T. Dairiki
*
* This file is part of Pyxine, Python bindings for xine.
*
* Pyxine is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* Pyxine is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#pragma interface
#ifndef _PxWindow_H
#define _PxWindow_H
extern "C" {
//# include <X11/Xlib.h>
# include <xine.h>
}
#include <map>
#include "pxlib.h"
#include "Mutex.h"
#include "Thread.h"
#include "Geometry.h"
#include "XDisplay.h"
#include "Callback.h"
#include "WindowList.h"
#ifndef SWIG
BEGIN_PXLIB_NAMESPACE
extern "C" {
typedef void c_dest_size_cb_t (void *user_data,
int video_width, int video_height,
double video_pixel_aspect,
int *dest_width, int *dest_height,
double *dest_pixel_aspect);
typedef void c_frame_output_cb_t (void *user_data,
int video_width, int video_height,
double video_pixel_aspect,
int *dest_x, int *dest_y,
int *dest_width, int *dest_height,
double *dest_pixel_aspect,
int *win_x, int *win_y);
}
#endif // !SWIG
class PxWindow;
typedef CachedPythonCallback<VideoGeometry,VideoGeometry> DestSizeCallback;
typedef CachedPythonCallback<VideoGeometry,VideoOutputGeometry> FrameOutputCallback;
////////////////////////////////////////////////////////////////
class PxDisplay
: public XDisplay, private Thread
{
WindowList windows;
ThreadRunner event_thread;
LockedWindowPtr find_window (Window window) { return windows.find(window); }
#ifndef SWIG
PxDisplay(const PxDisplay&); // not allowed
PxDisplay& operator= (const PxDisplay&); // not allowed
#endif // !SWIG
public:
PxDisplay(const char * display_name);
virtual ~PxDisplay();
bool has_windows();
#ifndef SWIG
void add_window (PxWindow * w) { windows.add(w); }
void remove_window (PxWindow * w) { windows.remove(w); }
virtual void run (); // the event loop
#endif // !defined(SWIG)
};
////////////////////////////////////////////////////////////////
class PxWindow
: public Mutex
{
#ifndef SWIG
struct XineVisual
: public x11_visual_t
{
XineVisual(XDisplay& _display, Window window, PxWindow *pxwindow);
};
#endif
PxDisplay& display;
Window window;
const int SHM_COMPLETION;
atomic<xine_stream_t *> stream; /* Stream to which to report events */
const XineVisual xine_visual;
atomic<WindowGeometry> window_geometry;
DestSizeCallback dest_size_cb;
FrameOutputCallback frame_output_cb;
int verbosity;
#ifndef SWIG
PxWindow(const PxWindow&); // not allowed
PxWindow& operator= (const PxWindow&); // not allowed
#endif
static c_dest_size_cb_t c_dest_size_cb;
static c_frame_output_cb_t c_frame_output_cb;
public:
PxWindow(PxDisplay * display, Window window,
PyObject *py_dest_size_cb, PyObject *py_frame_output_cb);
~PxWindow();
PyObject * get_window_geometry () const;
const x11_visual_t * get_xine_x11_visual () const;
void set_xine_stream (xine_stream_t * s);
int get_verbosity () const;
void set_verbosity (int verbosity);
double get_pixel_aspect () const;
void invalidate_cache() const;
#ifndef SWIG
void _handle_event (XEvent * e);
operator Window () const { return window; }
#endif // !defined(SWIG)
};
#ifndef SWIG
END_PXLIB_NAMESPACE
#endif // !SWIG
#endif // !_PxWindow_H
|