monitor.h

00001 /*******************************************************************************
00002 
00003            filename             : monitor.h
00004            description          : Class definition
00005 
00006            copyright            : (C) 2004, 2006 by Jean-Christophe Baillie
00007            email                : jean-christophe.baillie@m4x.org
00008 
00009 ********************************************************************************/
00010 
00011 #ifndef _MONITOR_H
00012 # define _MONITOR_H
00013 
00014 # ifdef WIN32
00015 #  include "monitor-win.h"
00016 # else
00017 # include "libport/cstring"
00018 # include <cerrno>
00019 # include <cassert>
00020 # include <iostream>
00021 # include <X11/X.h>
00022 # include <X11/Xlib.h>
00023 # include <X11/Xutil.h>
00024 # include <list>
00025 # include <sys/ipc.h>
00026 # include <sys/shm.h>
00027 # include <X11/extensions/XShm.h>
00028 
00029 typedef unsigned char bits8;
00030 
00031 class Monitor
00032 {
00033  public:
00034   // if fastmode enabled, use its own display: better framerate, but
00035   // irresponsive if not frequently updated
00036   Monitor(int, int, const char * name=NULL, bool fastMode = true);
00037   ~Monitor();
00038 
00039   void createWindow(const char* name);
00040   int  VisualClass ()
00041   {
00042     return visual->c_class;
00043   }
00044   int  Depth ()
00045   {
00046     return depth;
00047   }
00048   int  Width ()
00049   {
00050     return xImage != NULL ? xImage->width : 0;
00051   }
00052   int  Height ()
00053   {
00054     return xImage != NULL ? xImage->height : 0;
00055   }
00056   XImage *X ()
00057   {
00058     return xImage;
00059   }
00060   Bool IsShared ()
00061   {
00062     return isShared;
00063   }
00064   Bool HasSharedPixmap ()
00065   {
00066     return (Bool) (sharedPixmap != None);
00067   }
00068   Pixmap SharedPixmap ()
00069   {
00070     return sharedPixmap;
00071   }
00072   void  setName (const char * name)
00073   {
00074     XStoreName(display, window, name);
00075   }
00076   int   setImage(bits8*, int);
00077   int   createImage();
00078   int   destroyImage();
00079   void  clear();
00080   int   put();
00081 
00082   static void       processMessages();
00083 
00084  private:
00085   Window          window;
00086 
00087   Visual          *visual;
00088   int             depth;
00089   Bool            isShared; // MITSHM
00090   XImage          *xImage;
00091   Pixmap          sharedPixmap; // None (0L) if unassigned
00092   XShmSegmentInfo shmInfo;
00093 
00094   int                  screenNumber, windowsHeight, windowsWidth;
00095   Screen              *screen;
00096   XWindowAttributes   windowAttributes;
00097   int                 x, y, w, h;
00098 
00099   XEvent              event;
00100   Atom                atomWMDeleteWindow;
00101   GC                  gc;
00102   Display             *localDisplay;
00103 
00104   static pthread_mutex_t      lock;
00105 
00106   static Display    *display;  //shared display
00107   static void addList(Monitor *);
00108   static void removeList(Monitor *);
00109   static std::list<Monitor*> monitorList;
00110 };
00111 
00112 # endif
00113 
00114 #endif

Generated on Tue Apr 10 17:45:44 2007 for URBISDK by  doxygen 1.5.1