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-2013 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     //! zlevel of the window
00062     int             zlevel;
00063     //! last flip time in milliseconds
00064     int             lastflip;
00065     //! the window works direct on the layer (old staff, to be removed)
00066     bool            islayersurface;
00067     //! copy of surface if window works direct on the layer (old staff, to be removed)
00068     MMSFBSurface    *saved_surface;
00069 } VISIBLE_WINDOWS;
00070 
00071 //! Manager for MMSFBWindows will be instantiated once in an application.
00072 /*!
00073 \author Jens Schneider
00074 */
00075 class MMSFBWindowManager {
00076     private:
00077         MMSFBLayer              *layer;         /* layer on which the windows will be drawn */
00078         MMSFBSurface            *layer_surface; /* layer's surface */
00079         MMSFBSurfacePixelFormat layer_pixelformat;
00080 
00081         // destination surface for flipSurface() method
00082         MMSFBSurface            *dst_surface;
00083 
00084         vector<AVAILABLE_WINDOWS> windows;  /* a list of created windows */
00085 
00086         vector<VISIBLE_WINDOWS> vwins;      /* a list of currently visible windows */
00087 
00088         MMSFBSurface    *high_freq_surface; /* surface which will flipped with high frequency */
00089         MMSFBSurface    *high_freq_saved_surface;
00090         MMSFBRegion     high_freq_region;   /* rectangle which will flipped with high frequency */
00091         int             high_freq_lastflip; /* last flip time of the high_freq_region */
00092 
00093         bool            show_pointer;
00094         int             pointer_posx;
00095         int             pointer_posy;
00096         MMSFBRectangle  pointer_rect;
00097         MMSFBRegion     pointer_region;
00098         MMSFBSurface    *pointer_surface;
00099         unsigned char   pointer_opacity;
00100         bool            button_pressed;
00101         int             pointer_fadecnt;
00102 
00103         MMSMutex lock;            /* to make it thread-safe */
00104 
00105         MMSFBWindowManagerThread *mmsfbwinmanthread;
00106 
00107         MMSFBSurfacePixelFormat pixelformat;    // pixelformat for all my images
00108         bool                    usetaff;        // use the taff (image) format?
00109         MMSTAFF_PF              taffpf;         // pixelformat for the taff converter
00110 
00111         //! set to true if disko is running in OpenGL mode (GL/GLES)
00112         bool    ogl_mode;
00113 
00114         void lockWM();
00115         void unlockWM();
00116 
00117         bool addWindow(MMSFBWindow *window);
00118         bool removeWindow(MMSFBWindow *window);
00119 
00120         bool raiseToTop(MMSFBWindow *window);
00121         bool lowerToBottom(MMSFBWindow *window);
00122 
00123         bool loadWindowConfig(MMSFBWindow *window, VISIBLE_WINDOWS *vwin);
00124 
00125         bool showWindow(MMSFBWindow *window, bool locked = false, bool refresh = true);
00126         bool hideWindow(MMSFBWindow *window, bool locked = false, bool refresh = true);
00127 
00128         bool flipSurface(MMSFBSurface *surface, MMSFBRegion *region = NULL,
00129                          bool locked = false, bool refresh = true);
00130 
00131         bool setWindowOpacity(MMSFBWindow *window);
00132         bool setWindowPosition(MMSFBWindow *window, MMSFBRectangle *vrect = NULL);
00133         bool setWindowSize(MMSFBWindow *window, int w, int h);
00134 
00135         bool setWindowVisibleRectangle(MMSFBWindow *window, MMSFBRectangle *rect = NULL);
00136         bool getWindowVisibleRectangle(MMSFBWindow *window, MMSFBRectangle *rect);
00137         bool getScreenshot(MMSFBWindow *window);
00138 
00139         bool loadPointer();
00140         void drawPointer(MMSFBRegion *region);
00141         unsigned char getPointerOpacity();
00142         void setPointerOpacity(unsigned char opacity);
00143         void fadePointer();
00144 
00145     public:
00146         MMSFBWindowManager();
00147         virtual ~MMSFBWindowManager();
00148 
00149         bool init(MMSFBLayer *layer, bool show_pointer = false);
00150         bool reset();
00151         bool getLayer(MMSFBLayer **layer);
00152 
00153         void setPointerPosition(int pointer_posx, int pointer_posy, bool pressed = false);
00154         bool getPointerPosition(int &pointer_posx, int &pointer_posy);
00155 
00156     friend class MMSFBLayer;
00157     friend class MMSFBSurface;
00158     friend class MMSFBWindow;
00159     friend class MMSFBWindowManagerThread;
00160 };
00161 
00162 /* access to global mmsfbwindowmanager */
00163 extern MMSFBWindowManager *mmsfbwindowmanager;
00164 
00165 #endif /*MMSFBWINDOWMANAGER_H_*/

Generated by doxygen