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

mmsfbwindowmanagerthread.cpp

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 #include "mmsgui/fb/mmsfbwindowmanagerthread.h"
00034 #include "mmsgui/fb/mmsfbwindowmanager.h"
00035 
00036 MMSFBWindowManagerThread::MMSFBWindowManagerThread(MMSFBSurface **high_freq_surface,
00037                                                    MMSFBSurface **high_freq_saved_surface,
00038                                                    int *high_freq_lastflip,
00039                                                    MMSMutex *lock) {
00040     this->high_freq_surface = high_freq_surface;
00041     this->high_freq_saved_surface = high_freq_saved_surface;
00042     this->high_freq_lastflip = high_freq_lastflip;
00043     this->lock = lock;
00044 }
00045 
00046 void MMSFBWindowManagerThread::threadMain() {
00047     //int   pointer_opacity = 0;
00048     //int   hidecnt = 1;
00049 
00050     while (1) {
00051 
00052         if (!this->flipQueue.empty()) {
00053             FLIP_STRUCT tmpFlipStruct;
00054             tmpFlipStruct = this->flipQueue.front();
00055             this->flipQueue.pop();
00056 
00057             lock->lock();
00058             mmsfbwindowmanager->flipSurface(tmpFlipStruct.surface, tmpFlipStruct.region,
00059                                            MMSFB_FLIP_NONE, tmpFlipStruct.refresh);
00060             lock->unlock();
00061 
00062             msleep(100);
00063             continue;
00064         }
00065 
00066         // fade out the pointer
00067         mmsfbwindowmanager->fadePointer();
00068 
00069 
00070         if (!*(this->high_freq_surface)) {
00071             /* have no region */
00072             msleep(200);
00073             continue;
00074         }
00075 
00076         /* get the flip time */
00077         struct  timeval tv;
00078         gettimeofday(&tv, NULL);
00079         int newfliptime = (((int)tv.tv_sec)%1000000)*1000+((int)tv.tv_usec)/1000;
00080         int diff = newfliptime - *(this->high_freq_lastflip);
00081         if ((diff > 0)&&(diff < 1000)) {
00082             /* already running */
00083             msleep(200);
00084             continue;
00085         }
00086 
00087         /* have a surface but it was not flipped fast enough */
00088         lock->lock();
00089         if (!*(this->high_freq_surface)) {
00090             lock->unlock();
00091             continue;
00092         }
00093         if (*(this->high_freq_saved_surface)) {
00094             (*(this->high_freq_surface))->lock();
00095             (*(this->high_freq_saved_surface))->lock();
00096             /* copy saved surface because window works direct with layer */
00097             (*(this->high_freq_surface))->setBlittingFlags(MMSFB_BLIT_NOFX);
00098             (*(this->high_freq_surface))->blit(*(this->high_freq_saved_surface), NULL, 0, 0);
00099             (*(this->high_freq_saved_surface))->unlock();
00100             (*(this->high_freq_surface))->unlock();
00101         }
00102         DEBUGOUT("flipped not fast enough");
00103         mmsfbwindowmanager->flipSurface(*(this->high_freq_surface), NULL,
00104                                        MMSFB_FLIP_NONE, true);
00105         *(this->high_freq_surface) = NULL;
00106         *(this->high_freq_saved_surface) = NULL;
00107         *(this->high_freq_lastflip) = 0;
00108         lock->unlock();
00109     }
00110 }
00111 

Generated by doxygen