Logo
  • Main Page
  • Related Pages
  • Modules
  • Classes
  • Files

mmsfbwindowmanager.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005-2007 Stefan Schwarzer, Jens Schneider,             *
00003  *                           Matthias Hardt, Guido Madaus                  *
00004  *                                                                         *
00005  *   Copyright (C) 2007-2008 BerLinux Solutions GbR                        *
00006  *                           Stefan Schwarzer & Guido Madaus               *
00007  *                                                                         *
00008  *   Copyright (C) 2009-2012 BerLinux Solutions GmbH                       *
00009  *                                                                         *
00010  *   Authors:                                                              *
00011  *      Stefan Schwarzer   <stefan.schwarzer@diskohq.org>,                 *
00012  *      Matthias Hardt     <matthias.hardt@diskohq.org>,                   *
00013  *      Jens Schneider     <jens.schneider@diskohq.org>,                   *
00014  *      Guido Madaus       <guido.madaus@diskohq.org>,                     *
00015  *      Patrick Helterhoff <patrick.helterhoff@diskohq.org>,               *
00016  *      René Bählkow       <rene.baehlkow@diskohq.org>                     *
00017  *                                                                         *
00018  *   This library is free software; you can redistribute it and/or         *
00019  *   modify it under the terms of the GNU Lesser General Public            *
00020  *   License version 2.1 as published by the Free Software Foundation.     *
00021  *                                                                         *
00022  *   This library is distributed in the hope that it will be useful,       *
00023  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00024  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00025  *   Lesser General Public License for more details.                       *
00026  *                                                                         *
00027  *   You should have received a copy of the GNU Lesser General Public      *
00028  *   License along with this library; if not, write to the                 *
00029  *   Free Software Foundation, Inc.,                                       *
00030  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
00031  **************************************************************************/
00032 
00033 #ifndef MMSFBWINDOWMANAGER_H_
00034 #define MMSFBWINDOWMANAGER_H_
00035 
00036 #include "mmstools/tools.h"
00037 #include "mmstools/mmslogger.h"
00038 #include "mmsgui/fb/mmsfblayer.h"
00039 #include "mmsgui/fb/mmsfbwindowmanagerthread.h"
00040 
00041 typedef struct {
00042     //! window pointer
00043     MMSFBWindow     *window;
00044     //! visible rectangle, can be set if only a part of the window should be displayed
00045     MMSFBRectangle  vrect;
00046 } AVAILABLE_WINDOWS;
00047 
00048 typedef struct {
00049     //! window pointer
00050     MMSFBWindow     *window;
00051     //! surface of the window
00052     MMSFBSurface    *surface;
00053     //! visible rectangle, can be set if only a part of the window should be displayed
00054     MMSFBRectangle  vrect;
00055     //! region of the window within layer (if vrect is used, the region is the visible region)
00056     MMSFBRegion     region;
00057     //! use of alpha value
00058     bool            alphachannel;
00059     //! opacity of the window
00060     unsigned char   opacity;
00061     //! last flip time in milliseconds
00062     int             lastflip;
00063     //! the window works direct on the layer (old staff, to be removed)
00064     bool            islayersurface;
00065     //! copy of surface if window works direct on the layer (old staff, to be removed)
00066     MMSFBSurface    *saved_surface;
00067 } VISIBLE_WINDOWS;
00068 
00069 //! Manager for MMSFBWindows will be instantiated once in an application.
00070 /*!
00071 \author Jens Schneider
00072 */
00073 class MMSFBWindowManager {
00074     private:
00075         MMSFBLayer              *layer;         /* layer on which the windows will be drawn */
00076         MMSFBSurface            *layer_surface; /* layer's surface */
00077         MMSFBSurfacePixelFormat layer_pixelformat;
00078 
00079         // destination surface for flipSurface() method
00080         MMSFBSurface            *dst_surface;
00081 
00082         vector<AVAILABLE_WINDOWS> windows;  /* a list of created windows */
00083 
00084         vector<VISIBLE_WINDOWS> vwins;      /* a list of currently visible windows */
00085 
00086         MMSFBSurface    *high_freq_surface; /* surface which will flipped with high frequency */
00087         MMSFBSurface    *high_freq_saved_surface;
00088         MMSFBRegion     high_freq_region;   /* rectangle which will flipped with high frequency */
00089         int             high_freq_lastflip; /* last flip time of the high_freq_region */
00090 
00091         bool            show_pointer;
00092         int             pointer_posx;
00093         int             pointer_posy;
00094         MMSFBRectangle  pointer_rect;
00095         MMSFBRegion     pointer_region;
00096         MMSFBSurface    *pointer_surface;
00097         unsigned char   pointer_opacity;
00098         bool            button_pressed;
00099         int             pointer_fadecnt;
00100 
00101         MMSMutex lock;            /* to make it thread-safe */
00102 
00103         MMSFBWindowManagerThread *mmsfbwinmanthread;
00104 
00105         MMSFBSurfacePixelFormat pixelformat;    // pixelformat for all my images
00106         bool                    usetaff;        // use the taff (image) format?
00107         MMSTAFF_PF              taffpf;         // pixelformat for the taff converter
00108 
00109         //! set to true if disko is running in OpenGL mode (GL/GLES)
00110         bool    ogl_mode;
00111 
00112         void lockWM();
00113         void unlockWM();
00114 
00115         bool addWindow(MMSFBWindow *window);
00116         bool removeWindow(MMSFBWindow *window);
00117 
00118         bool raiseToTop(MMSFBWindow *window, int zlevel = 0);
00119         bool lowerToBottom(MMSFBWindow *window);
00120 
00121         bool loadWindowConfig(MMSFBWindow *window, VISIBLE_WINDOWS *vwin);
00122 
00123         bool showWindow(MMSFBWindow *window, bool locked = false, bool refresh = true);
00124         bool hideWindow(MMSFBWindow *window, bool locked = false, bool refresh = true);
00125 
00126         bool flipSurface(MMSFBSurface *surface, MMSFBRegion *region = NULL,
00127                          bool locked = false, bool refresh = true);
00128 
00129         bool setWindowOpacity(MMSFBWindow *window);
00130         bool setWindowPosition(MMSFBWindow *window, MMSFBRectangle *vrect = NULL);
00131         bool setWindowSize(MMSFBWindow *window, int w, int h);
00132 
00133         bool setWindowVisibleRectangle(MMSFBWindow *window, MMSFBRectangle *rect = NULL);
00134         bool getWindowVisibleRectangle(MMSFBWindow *window, MMSFBRectangle *rect);
00135         bool getScreenshot(MMSFBWindow *window);
00136 
00137         bool loadPointer();
00138         void drawPointer(MMSFBRegion *region);
00139         unsigned char getPointerOpacity();
00140         void setPointerOpacity(unsigned char opacity);
00141         void fadePointer();
00142 
00143     public:
00144         MMSFBWindowManager();
00145         virtual ~MMSFBWindowManager();
00146 
00147         bool init(MMSFBLayer *layer, bool show_pointer = false);
00148         bool reset();
00149         bool getLayer(MMSFBLayer **layer);
00150 
00151         void setPointerPosition(int pointer_posx, int pointer_posy, bool pressed = false);
00152         bool getPointerPosition(int &pointer_posx, int &pointer_posy);
00153 
00154     friend class MMSFBLayer;
00155     friend class MMSFBSurface;
00156     friend class MMSFBWindow;
00157     friend class MMSFBWindowManagerThread;
00158 };
00159 
00160 /* access to global mmsfbwindowmanager */
00161 extern MMSFBWindowManager *mmsfbwindowmanager;
00162 
00163 #endif /*MMSFBWINDOWMANAGER_H_*/

Generated by doxygen