summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Riedi <andrewriedi@gmail.com>2007-07-05 20:00:05 -0700
committerAndrew Riedi <andrewriedi@gmail.com>2007-07-05 20:00:05 -0700
commit3869cd3c66234f784848823f76dcf386bdac7b1e (patch)
tree35f1887618f99956a5a28a7fb4822e517bafb6d5
parent8c4bf6293e30fbf1484befa580f7cbaace405c89 (diff)
downloadsound-3869cd3c66234f784848823f76dcf386bdac7b1e.tar.gz
sound-3869cd3c66234f784848823f76dcf386bdac7b1e.tar.bz2
Move window specific code into the window structure.
-rw-r--r--include/sound.h26
-rw-r--r--soundeffects/soundeffects.c46
2 files changed, 49 insertions, 23 deletions
diff --git a/include/sound.h b/include/sound.h
index bb62813..52c8c5c 100644
--- a/include/sound.h
+++ b/include/sound.h
@@ -37,29 +37,33 @@ typedef char *(*SoundFindFileProc) ( char *filename, char *theme );
#define SOUND_DISPLAY_OPTION_USE_ALSA 2
#define SOUND_DISPLAY_OPTION_NUM 3
+#define AllowMove (1 << 0)
+#define AllowResize (1 << 1)
+
typedef struct _SoundDisplay {
int screenPrivateIndex;
CompOption opt[SOUND_DISPLAY_OPTION_NUM];
- SoundTestProc soundTest;
- SoundPlayProc soundPlay;
- SoundPlayFileOggProc soundPlayFileOgg;
- SoundPlayFileProc soundPlayFile;
- SoundFindFileProc soundFindFile;
+ SoundTestProc soundTest;
+ SoundPlayProc soundPlay;
+ SoundPlayFileOggProc soundPlayFileOgg;
+ SoundPlayFileProc soundPlayFile;
+ SoundFindFileProc soundFindFile;
} SoundDisplay;
typedef struct _SoundScreen {
int windowPrivateIndex;
- WindowAddNotifyProc windowAddNotify;
- WindowResizeNotifyProc windowResizeNotify;
- WindowMoveNotifyProc windowMoveNotify;
- WindowGrabNotifyProc windowGrabNotify;
- WindowUngrabNotifyProc windowUngrabNotify;
+ WindowAddNotifyProc windowAddNotify;
+ WindowResizeNotifyProc windowResizeNotify;
+ WindowMoveNotifyProc windowMoveNotify;
+ WindowGrabNotifyProc windowGrabNotify;
+ WindowUngrabNotifyProc windowUngrabNotify;
} SoundScreen;
typedef struct _SoundWindow {
+ unsigned int allowMask;
} SoundWindow;
#define GET_SOUND_DISPLAY(d) \
@@ -76,7 +80,7 @@ typedef struct _SoundWindow {
GET_SOUND_DISPLAY (s->display))
#define GET_SOUND_WINDOW(w, ss) \
- ((SoundWindow *) (w)->privates[(ws)->windowPrivateIndex].ptr)
+ ((SoundWindow *) (w)->privates[(ss)->windowPrivateIndex].ptr)
#define SOUND_WINDOW(w) \
SoundWindow *sw = GET_SOUND_WINDOW (w, \
diff --git a/soundeffects/soundeffects.c b/soundeffects/soundeffects.c
index 15fe01b..e36a3df 100644
--- a/soundeffects/soundeffects.c
+++ b/soundeffects/soundeffects.c
@@ -21,13 +21,9 @@
#include <compiz.h>
#include <sound.h>
-#define AllowMove (1 << 0)
-#define AllowResize (1 << 1)
-
static CompMetadata soundeffectsMetadata;
static int displayPrivateIndex;
static int soundDisplayPrivateIndex;
-static unsigned int allowMask = 0;
static void soundeffectsWindowAddNotify( CompWindow *w )
{
@@ -44,13 +40,14 @@ static void soundeffectsWindowAddNotify( CompWindow *w )
static void soundeffectsWindowResizeNotify( CompWindow *w, int dx, int dy,
int dwidth, int dheight )
{
+ SOUND_WINDOW( w );
SOUND_SCREEN( w->screen );
SOUND_DISPLAY( w->screen->display );
- if ( allowMask & AllowResize )
+ if ( sw->allowMask & AllowResize )
{
(*sd->soundPlayFile) ( w->screen->display, "resize.ogg" );
- allowMask &= ~AllowResize;
+ sw->allowMask &= ~AllowResize;
}
UNWRAP( ss, w->screen, windowResizeNotify );
@@ -61,10 +58,11 @@ static void soundeffectsWindowResizeNotify( CompWindow *w, int dx, int dy,
static void soundeffectsWindowMoveNotify( CompWindow *w, int dx, int dy,
Bool immediate )
{
+ SOUND_WINDOW( w );
SOUND_SCREEN( w->screen );
SOUND_DISPLAY( w->screen->display );
- if ( allowMask & AllowMove )
+ if ( sw->allowMask & AllowMove )
{
if ( !immediate && abs( dx ) >= abs( dy ) )
{
@@ -80,7 +78,7 @@ static void soundeffectsWindowMoveNotify( CompWindow *w, int dx, int dy,
else
(*sd->soundPlayFile) ( w->screen->display, "moveup.ogg" );
}
- allowMask &= ~AllowMove;
+ sw->allowMask &= ~AllowMove;
}
UNWRAP( ss, w->screen, windowMoveNotify );
@@ -92,12 +90,13 @@ static void soundeffectsWindowGrabNotify( CompWindow *w, int x, int y,
unsigned int state,
unsigned int mask )
{
+ SOUND_WINDOW( w );
SOUND_SCREEN( w->screen );
if ( mask & CompWindowGrabMoveMask )
- allowMask |= AllowMove;
+ sw->allowMask |= AllowMove;
if ( mask & CompWindowGrabResizeMask )
- allowMask |= AllowResize;
+ sw->allowMask |= AllowResize;
UNWRAP( ss, w->screen, windowGrabNotify );
(*w->screen->windowGrabNotify) ( w, x, y, state, mask );
@@ -183,6 +182,29 @@ static void soundeffectsFiniScreen( CompPlugin *plugin, CompScreen *s )
free( ss );
}
+static Bool soundeffectsInitWindow( CompPlugin *plugin, CompWindow *w )
+{
+ SoundWindow *sw;
+
+ SOUND_SCREEN( w->screen );
+
+ sw = malloc( sizeof( SoundWindow ) );
+ if (!sw)
+ return FALSE;
+
+ sw->allowMask = 0;
+
+ w->privates[ss->windowPrivateIndex].ptr = sw;
+
+ return TRUE;
+}
+
+static void soundeffectsFiniWindow( CompPlugin *plugin, CompWindow *w )
+{
+ SOUND_WINDOW( w );
+ free( sw );
+}
+
static Bool soundeffectsInit( CompPlugin *plugin )
{
if ( !compInitPluginMetadataFromInfo( &soundeffectsMetadata,
@@ -228,8 +250,8 @@ CompPluginVTable soundeffectsVTable =
soundeffectsFiniDisplay,
soundeffectsInitScreen,
soundeffectsFiniScreen,
- 0, /* InitWindow */
- 0, /* FiniWindow */
+ soundeffectsInitWindow,
+ soundeffectsFiniWindow,
0, /* GetDisplayOptions */
0, /* SetDisplayOption */
0, /* GetScreenOptions */