Debian Codegraph @

motion-blur/src/applet-notifications.c

raw
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 #include <stdlib.h>
21 #include <string.h>
22 #include <math.h>
23
24 #include "applet-struct.h"
25 #include "applet-notifications.h"
26
27 #define CD_DOCK_IN_MOVMENT(pDock) ((myConfig.bAlways && cairo_dock_container_is_animating (CAIRO_CONTAINER(pDock))) || pDock->bIsShrinkingDown || pDock->bIsGrowingUp)
28
29
30 gboolean cd_motion_blur_pre_render (gpointer pUserData, CairoDock *pDock, cairo_t *pCairoContext)
31 {
32 return GLDI_NOTIFICATION_LET_PASS;
33 if (pCairoContext != NULL)
34 return GLDI_NOTIFICATION_LET_PASS;
35 CDMotionBlurData *pData = CD_APPLET_GET_MY_DOCK_DATA (pDock);
36
37 if ((pData != NULL && pData->iBlurCount != 0) || CD_DOCK_IN_MOVMENT (pDock))
38 glAccum(GL_MULT, myConfig.fBlurFactor);
39
40 return GLDI_NOTIFICATION_LET_PASS;
41 }
42
43 gboolean cd_motion_blur_post_render (gpointer pUserData, CairoDock *pDock, cairo_t *pCairoContext)
44 {
45 if (pCairoContext != NULL)
46 return GLDI_NOTIFICATION_LET_PASS;
47
48 CDMotionBlurData *pData = CD_APPLET_GET_MY_DOCK_DATA (pDock);
49 if (pData == NULL)
50 return GLDI_NOTIFICATION_LET_PASS;
51
52 if ((pData != NULL && pData->iBlurCount > 0) || CD_DOCK_IN_MOVMENT (pDock))
53 {
54 glAccum (GL_ACCUM, 1 - myConfig.fBlurFactor);
55 glAccum (GL_RETURN, 1.0);
56 glAccum (GL_LOAD, myConfig.fBlurFactor);
57 }
58 else
59 {
60 glClearAccum (0., 0., 0., 0.);
61 glClear (GL_ACCUM_BUFFER_BIT);
62 glAccum (GL_ACCUM, 1.);
63 }
64
65 return GLDI_NOTIFICATION_LET_PASS;
66 }
67
68
69 gboolean cd_motion_blur_mouse_moved (gpointer pUserData, CairoDock *pDock, gboolean *bStartAnimation)
70 {
71 if (! CAIRO_DOCK_CONTAINER_IS_OPENGL (CAIRO_CONTAINER (pDock)))
72 return GLDI_NOTIFICATION_LET_PASS;
73 CDMotionBlurData *pData = CD_APPLET_GET_MY_DOCK_DATA (pDock);
74 if (pData == NULL)
75 {
76 pData = g_new0 (CDMotionBlurData, 1);
77 CD_APPLET_SET_MY_DOCK_DATA (pDock, pData);
78 }
79 pData->iBlurCount = -3 / log (myConfig.fBlurFactor); // blur applied N times to get 10^-3
80 *bStartAnimation = TRUE;
81
82 return GLDI_NOTIFICATION_LET_PASS;
83 }
84
85
86 gboolean cd_motion_blur_update_dock (gpointer pUserData, CairoDock *pDock, gboolean *bContinueAnimation)
87 {
88 CDMotionBlurData *pData = CD_APPLET_GET_MY_DOCK_DATA (pDock);
89 if (pData == NULL)
90 return GLDI_NOTIFICATION_LET_PASS;
91
92 if (! pDock->bIsShrinkingDown && ! pDock->bIsGrowingUp)
93 pData->iBlurCount --;
94 //g_print ("blur <- %d\n", pData->iBlurCount);
95
96 cairo_dock_redraw_container (CAIRO_CONTAINER (pDock));
97 if (pData->iBlurCount < 0)
98 {
99 g_free (pData);
100 CD_APPLET_SET_MY_DOCK_DATA (pDock, NULL);
101 return GLDI_NOTIFICATION_LET_PASS;
102 }
103
104 *bContinueAnimation = TRUE;
105 return GLDI_NOTIFICATION_LET_PASS;
106 }
107
108 gboolean cd_motion_free_data (gpointer pUserData, CairoDock *pDock)
109 {
110 CDMotionBlurData *pData = CD_APPLET_GET_MY_DOCK_DATA (pDock);
111 if (pData != NULL)
112 {
113 g_free (pData);
114 CD_APPLET_SET_MY_DOCK_DATA (pDock, NULL);
115 }
116 return GLDI_NOTIFICATION_LET_PASS;
117 }