~ubuntu-branches/ubuntu/saucy/cairo-dock-plug-ins/saucy

« back to all changes in this revision

Viewing changes to motion-blur/src/applet-notifications.c

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2009-08-26 21:07:39 UTC
  • Revision ID: james.westby@ubuntu.com-20090826210739-gyjuuqezrzuluao4
Tags: upstream-2.0.8.1
ImportĀ upstreamĀ versionĀ 2.0.8.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
* This file is a part of the Cairo-Dock project
 
3
*
 
4
* Copyright : (C) see the 'copyright' file.
 
5
* E-mail    : see the 'copyright' file.
 
6
*
 
7
* This program is free software; you can redistribute it and/or
 
8
* modify it under the terms of the GNU General Public License
 
9
* as published by the Free Software Foundation; either version 3
 
10
* of the License, or (at your option) any later version.
 
11
*
 
12
* This program is distributed in the hope that it will be useful,
 
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
* GNU General Public License for more details.
 
16
* You should have received a copy of the GNU General Public License
 
17
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
18
*/
 
19
 
 
20
/******************************************************************************
 
21
 
 
22
This file is a part of the cairo-dock program, 
 
23
released under the terms of the GNU General Public License.
 
24
 
 
25
Written by Fabrice Rey (for any bug report, please mail me to fabounet@users.berlios.de)
 
26
 
 
27
******************************************************************************/
 
28
 
 
29
#include <stdlib.h>
 
30
#include <string.h>
 
31
 
 
32
#include "applet-struct.h"
 
33
#include "applet-notifications.h"
 
34
 
 
35
#define CD_DOCK_IN_MOVMENT(pDock) ((myConfig.bAlways && pDock->iSidGLAnimation) || pDock->bIsShrinkingDown || pDock->bIsGrowingUp)
 
36
 
 
37
 
 
38
gboolean cd_motion_blur_pre_render (gpointer pUserData, CairoDock *pDock, cairo_t *pCairoContext)
 
39
{
 
40
        if (pCairoContext != NULL)
 
41
                return CAIRO_DOCK_LET_PASS_NOTIFICATION;
 
42
        CDMotionBlurData *pData = CD_APPLET_GET_MY_DOCK_DATA (pDock);
 
43
        
 
44
        if ((pData != NULL && pData->iBlurCount != 0) || CD_DOCK_IN_MOVMENT (pDock))
 
45
                glAccum(GL_MULT, myConfig.fBlurFactor);
 
46
        
 
47
        return CAIRO_DOCK_LET_PASS_NOTIFICATION;
 
48
}
 
49
 
 
50
gboolean cd_motion_blur_post_render (gpointer pUserData, CairoDock *pDock, cairo_t *pCairoContext)
 
51
{
 
52
        if (pCairoContext != NULL)
 
53
                return CAIRO_DOCK_LET_PASS_NOTIFICATION;
 
54
        CDMotionBlurData *pData = CD_APPLET_GET_MY_DOCK_DATA (pDock);
 
55
        
 
56
        if ((pData != NULL && pData->iBlurCount != 0) || CD_DOCK_IN_MOVMENT (pDock))
 
57
        {
 
58
                glAccum (GL_ACCUM, 1 - myConfig.fBlurFactor);
 
59
                glAccum (GL_RETURN, 1.0);
 
60
        }
 
61
        else
 
62
        {
 
63
                glClearAccum (0., 0., 0., 0.);
 
64
                glClear (GL_ACCUM_BUFFER_BIT);
 
65
                glAccum (GL_ACCUM, 1.);
 
66
        }
 
67
        
 
68
        return CAIRO_DOCK_LET_PASS_NOTIFICATION;
 
69
}
 
70
 
 
71
 
 
72
gboolean cd_motion_blur_mouse_moved (gpointer pUserData, CairoDock *pDock, gboolean *bStartAnimation)
 
73
{
 
74
        if (! CAIRO_DOCK_CONTAINER_IS_OPENGL (CAIRO_CONTAINER (pDock)))
 
75
                return CAIRO_DOCK_LET_PASS_NOTIFICATION;
 
76
        CDMotionBlurData *pData = CD_APPLET_GET_MY_DOCK_DATA (pDock);
 
77
        if (pData == NULL)
 
78
                pData = g_new0 (CDMotionBlurData, 1);
 
79
        
 
80
        pData->iBlurCount = 20;
 
81
        *bStartAnimation = TRUE;
 
82
        
 
83
        CD_APPLET_SET_MY_DOCK_DATA (pDock, pData);
 
84
        return CAIRO_DOCK_LET_PASS_NOTIFICATION;
 
85
}
 
86
 
 
87
 
 
88
gboolean cd_motion_blur_update_dock (gpointer pUserData, CairoDock *pDock, gboolean *bContinueAnimation)
 
89
{
 
90
        CDMotionBlurData *pData = CD_APPLET_GET_MY_DOCK_DATA (pDock);
 
91
        if (pData == NULL)
 
92
                return CAIRO_DOCK_LET_PASS_NOTIFICATION;
 
93
        
 
94
        if (! pDock->bIsShrinkingDown && ! pDock->bIsGrowingUp)
 
95
                pData->iBlurCount --;
 
96
        //g_print ("blur <- %d\n", pData->iBlurCount);
 
97
        
 
98
        if (pData->iBlurCount <= 0)
 
99
        {
 
100
                g_free (pData);
 
101
                CD_APPLET_SET_MY_DOCK_DATA (pDock, NULL);
 
102
                return CAIRO_DOCK_LET_PASS_NOTIFICATION;
 
103
        }
 
104
        
 
105
        *bContinueAnimation = TRUE;
 
106
        return CAIRO_DOCK_LET_PASS_NOTIFICATION;
 
107
}