summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Spilsbury <Sam@XPS-SUSE.site>2009-01-14 00:34:50 +0900
committerSam Spilsbury <Sam@XPS-SUSE.site>2009-01-14 00:34:50 +0900
commitacd973bcc0d6c6a73d06e600e0e5471f9a48b338 (patch)
tree5f05277a186de0fb2eb86c3c534196078b5d1f2b
parente96fd5f1296f184c9528e06b03ada813a66b9375 (diff)
downloadthrow-acd973bcc0d6c6a73d06e600e0e5471f9a48b338.tar.gz
throw-acd973bcc0d6c6a73d06e600e0e5471f9a48b338.tar.bz2
Initial C++ port:
-rw-r--r--CMakeLists.txt2
-rw-r--r--Makefile36
-rw-r--r--plugin.info2
-rw-r--r--throw.c398
4 files changed, 8 insertions, 430 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f09d32e..85dd583 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,3 +1,3 @@
include (CompizFusion)
-compiz_fusion_plugin (throw)
+compiz_fusion_plugin (throw PLUGINDEPS composite)
diff --git a/Makefile b/Makefile
index d9a07cf..fb9d387 100644
--- a/Makefile
+++ b/Makefile
@@ -89,14 +89,14 @@ INSTALL = install
BCOP = `pkg-config --variable=bin bcop`
-CFLAGS = -g -Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -fno-strict-aliasing `pkg-config --cflags $(PKG_DEP) compiz ` $(CFLAGS_ADD)
+CFLAGS = -g -Wall -Wpointer-arith -fno-strict-aliasing `pkg-config --cflags $(PKG_DEP) compiz ` $(CFLAGS_ADD)
LDFLAGS = `pkg-config --libs $(PKG_DEP) compiz ` $(LDFLAGS_ADD)
DEFINES = -DIMAGEDIR=\"$(IMAGEDIR)\" -DDATADIR=\"$(DATADIR)\"
POFILEDIR = $(shell if [ -n "$(PODIR)" ]; then $(ECHO) $(PODIR); else $(ECHO) ./po;fi )
-COMPIZ_HEADERS = compiz.h compiz-core.h
+COMPIZ_HEADERS = compiz.h core/core.h
COMPIZ_INC = $(shell pkg-config --variable=includedir compiz)/compiz/
is-bcop-target := $(shell if [ -e $(PLUGIN).xml.in ]; then cat $(PLUGIN).xml.in | grep "useBcop=\"true\""; \
@@ -105,7 +105,6 @@ is-bcop-target := $(shell if [ -e $(PLUGIN).xml.in ]; then cat $(PLUGIN).xml.in
trans-target := $(shell if [ -e $(PLUGIN).xml.in -o -e $(PLUGIN).xml ]; then $(ECHO) $(BUILDDIR)/$(PLUGIN).xml;fi )
bcop-target := $(shell if [ -n "$(is-bcop-target)" ]; then $(ECHO) $(BUILDDIR)/$(PLUGIN).xml; fi )
-bcop-target-src := $(shell if [ -n "$(is-bcop-target)" ]; then $(ECHO) $(BUILDDIR)/$(PLUGIN)_options.c; fi )
bcop-target-hdr := $(shell if [ -n "$(is-bcop-target)" ]; then $(ECHO) $(BUILDDIR)/$(PLUGIN)_options.h; fi )
gen-schemas := $(shell if [ \( -e $(PLUGIN).xml.in -o -e $(PLUGIN).xml \) -a -n "`pkg-config --variable=xsltdir compiz-gconf`" ]; then $(ECHO) true; fi )
@@ -119,17 +118,14 @@ endif
# find all the object files
-c-objs := $(patsubst %.c,%.lo,$(shell find -name '*.c' 2> /dev/null | grep -v "$(BUILDDIR)/" | sed -e 's/^.\///'))
-c-objs += $(patsubst %.cpp,%.lo,$(shell find -name '*.cpp' 2> /dev/null | grep -v "$(BUILDDIR)/" | sed -e 's/^.\///'))
+c-objs := $(patsubst %.cpp,%.lo,$(shell find -name '*.cpp' 2> /dev/null | grep -v "$(BUILDDIR)/" | sed -e 's/^.\///'))
c-objs += $(patsubst %.cxx,%.lo,$(shell find -name '*.cxx' 2> /dev/null | grep -v "$(BUILDDIR)/" | sed -e 's/^.\///'))
-c-objs := $(filter-out $(bcop-target-src:.c=.lo),$(c-objs))
h-files := $(shell find -name '*.h' 2> /dev/null | grep -v "$(BUILDDIR)/" | sed -e 's/^.\///')
h-files += $(bcop-target-hdr)
h-files += $(foreach file,$(COMPIZ_HEADERS) $(CHK_HEADERS),$(shell $(ECHO) -n "$(COMPIZ_INC)$(file)"))
all-c-objs := $(addprefix $(BUILDDIR)/,$(c-objs))
-all-c-objs += $(bcop-target-src:.c=.lo)
# additional files
@@ -280,28 +276,6 @@ $(BUILDDIR)/compiz-%.pc: compiz-%.pc.in
# Compiling
#
-$(BUILDDIR)/%.lo: %.c $(h-files)
- @if [ '$(color)' != 'no' ]; then \
- $(ECHO) -n -e "\033[0;1;5mcompiling \033[0m: \033[0;32m$< \033[0m-> \033[0;31m$@\033[0m"; \
- else \
- $(ECHO) "compiling $< -> $@"; \
- fi
- @$(LIBTOOL) --quiet --mode=compile $(CC) $(CFLAGS) $(DEFINES) -I$(BUILDDIR) -c -o $@ $<
- @if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e "\r\033[0mcompiling : \033[34m$< -> $@\033[0m"; \
- fi
-
-$(BUILDDIR)/%.lo: $(BUILDDIR)/%.c $(h-files)
- @if [ '$(color)' != 'no' ]; then \
- $(ECHO) -n -e "\033[0;1;5mcompiling \033[0m: \033[0;32m$< \033[0m-> \033[0;31m$@\033[0m"; \
- else \
- $(ECHO) "compiling $< -> $@"; \
- fi
- @$(LIBTOOL) --quiet --mode=compile $(CC) $(CFLAGS) $(DEFINES) -I$(BUILDDIR) -c -o $@ $<
- @if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e "\r\033[0mcompiling : \033[34m$< -> $@\033[0m"; \
- fi
-
$(BUILDDIR)/%.lo: %.cpp $(h-files)
@if [ '$(color)' != 'no' ]; then \
$(ECHO) -n -e "\033[0;1;5mcompiling \033[0m: \033[0;32m$< \033[0m-> \033[0;31m$@\033[0m"; \
@@ -319,7 +293,7 @@ $(BUILDDIR)/%.lo: %.cxx $(h-files)
else \
$(ECHO) "compiling $< -> $@"; \
fi
- @$(LIBTOOL) --quiet --mode=compile $(CPP) $(CFLAGS) $(DEFINES) -I$(BUILDDIR) -c -o $@ $<
+ @$(LIBTOOL) --mode=compile $(CPP) $(CFLAGS) $(DEFINES) -I$(BUILDDIR) -c -o $@ $<
@if [ '$(color)' != 'no' ]; then \
$(ECHO) -e "\r\033[0mcompiling : \033[34m$< -> $@\033[0m"; \
fi
@@ -336,7 +310,7 @@ $(BUILDDIR)/lib$(PLUGIN).la: $(all-c-objs)
else \
$(ECHO) "linking : $@"; \
fi
- @$(LIBTOOL) --quiet --mode=link $(CC) $(LDFLAGS) -rpath $(DESTDIR) -o $@ $(all-c-objs)
+ @$(LIBTOOL) --quiet --mode=link $(CC) $(LDFLAGS) -rpath $(DESTDIR) -o $@ $(all-c-objs) -R `pkg-config --variable=libdir compiz`/compiz
@if [ '$(color)' != 'no' ]; then \
$(ECHO) -e "\r\033[0mlinking : \033[34m$@\033[0m"; \
fi
diff --git a/plugin.info b/plugin.info
index ee71724..faf123c 100644
--- a/plugin.info
+++ b/plugin.info
@@ -1 +1,3 @@
PLUGIN = throw
+PKG_DEP = compiz-composite
+LD_FLAGS = -Wl, -rpath /opt/compiz/lib/compiz
diff --git a/throw.c b/throw.c
deleted file mode 100644
index cac8b9a..0000000
--- a/throw.c
+++ /dev/null
@@ -1,398 +0,0 @@
-/**
- *
- * Compiz throw windows plugin
- *
- * throw.c
- *
- * Copyright (c) 2008 Sam Spilsbury <smspillaz@gmail.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- **/
-
-#define _GNU_SOURCE
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-
-#include <compiz-core.h>
-
-#include "throw_options.h"
-
-#define PI 3.1415926
-
-static int displayPrivateIndex;
-
-typedef struct _ThrowDisplay
-{
- int screenPrivateIndex;
-} ThrowDisplay;
-
-typedef struct _ThrowScreen
-{
- WindowGrabNotifyProc windowGrabNotify;
- WindowUngrabNotifyProc windowUngrabNotify;
- WindowMoveNotifyProc windowMoveNotify;
- PreparePaintScreenProc preparePaintScreen;
- DonePaintScreenProc donePaintScreen;
-
- int windowPrivateIndex;
-} ThrowScreen;
-
-
-typedef struct _ThrowWindow
-{
- float xVelocity;
- float yVelocity;
- int time;
- Bool moving;
-} ThrowWindow;
-
-#define GET_THROW_DISPLAY(d) \
- ((ThrowDisplay *) (d)->base.privates[displayPrivateIndex].ptr)
-
-#define THROW_DISPLAY(d) \
- ThrowDisplay *td = GET_THROW_DISPLAY (d)
-
-#define GET_THROW_SCREEN(s, td) \
- ((ThrowScreen *) (s)->base.privates[(td)->screenPrivateIndex].ptr)
-
-#define THROW_SCREEN(s) \
- ThrowScreen *ts = GET_THROW_SCREEN (s, GET_THROW_DISPLAY (s->display))
-
-#define GET_THROW_WINDOW(w, ts) \
- ((ThrowWindow *) (w)->base.privates[(ts)->windowPrivateIndex].ptr)
-
-#define THROW_WINDOW(w) \
- ThrowWindow *tw = GET_THROW_WINDOW (w, \
- GET_THROW_SCREEN (w->screen, \
- GET_THROW_DISPLAY (w->screen->display)))
-
-#define WIN_REAL_X(w) (w->attrib.x - w->input.left)
-#define WIN_REAL_Y(w) (w->attrib.y - w->input.top)
-
-#define WIN_REAL_W(w) (w->width + w->input.left + w->input.right)
-#define WIN_REAL_H(w) (w->height + w->input.top + w->input.bottom)
-
-/* Handle the velocity */
-static void
-throwPreparePaintScreen (CompScreen *s,
- int ms)
-{
- CompWindow *w;
- THROW_SCREEN (s);
-
- for (w = s->windows; w; w = w->next)
- {
- THROW_WINDOW (w);
-
- if (tw->moving)
- tw->time += ms;
-
- if (!tw->moving && (
- (tw->xVelocity < 0.0f || tw->xVelocity > 0.0f) ||
- (tw->yVelocity < 0.0f || tw->yVelocity > 0.0)))
- {
-
- tw->xVelocity /= (1.0 + (throwGetFrictionConstant (s) / 100));
- tw->yVelocity /= (1.0 + (throwGetFrictionConstant (s) / 100));
- int dx = roundf(tw->xVelocity * (ms / 10) * (throwGetVelocityX (s) / 10));
- int dy = roundf (tw->yVelocity * (ms / 10) * (throwGetVelocityY (s) / 10));
-
- if (throwGetConstrainX (s))
- {
- if ((WIN_REAL_X (w) + dx) < 0)
- dx = 0;
- else if ((WIN_REAL_X (w) + WIN_REAL_W (w) + dx) > w->screen->width)
- dx = 0;
- }
- if (throwGetConstrainY (s))
- {
- if ((WIN_REAL_Y (w) + dy) < 0)
- dy = 0;
- else if ((WIN_REAL_Y (w) + WIN_REAL_H (w) + dy) > w->screen->height)
- dy = 0;
- }
-
- moveWindow (w, dx, dy, TRUE, FALSE);
- syncWindowPosition (w);
- }
-
- }
-
- UNWRAP (ts, s, preparePaintScreen);
- (*s->preparePaintScreen) (s, ms);
- WRAP (ts, s, preparePaintScreen, throwPreparePaintScreen);
-}
-
-static void
-throwDonePaintScreen (CompScreen *s)
-{
- THROW_SCREEN (s);
- CompWindow *w;
- for (w = s->windows; w; w = w->next)
- {
- THROW_WINDOW (w);
- if (tw->moving ||
- (tw->xVelocity < 0.0f || tw->xVelocity > 0.0f) ||
- (tw->yVelocity < 0.0f || tw->yVelocity > 0.0f))
- {
- addWindowDamage (w);
- }
- }
-
- UNWRAP (ts, s, donePaintScreen);
- (*s->donePaintScreen) (s);
- WRAP (ts, s, donePaintScreen, throwDonePaintScreen);
-}
-
-static void
-throwWindowGrabNotify (CompWindow *w,
- int x,
- int y,
- unsigned int state,
- unsigned int mask)
-{
- CompScreen * s = w->screen;
-
- THROW_SCREEN (s);
-
- if (mask & CompWindowGrabMoveMask)
- {
- THROW_WINDOW (w);
-
- tw->moving = TRUE;
-
- tw->time = 0;
- tw->xVelocity = 0.0f;
- tw->yVelocity = 0.0f;
- }
-
- UNWRAP (ts, s, windowGrabNotify);
- (*s->windowGrabNotify) (w, x, y, state, mask);
- WRAP (ts, s, windowGrabNotify, throwWindowGrabNotify);
-}
-
-static void
-throwWindowUngrabNotify (CompWindow *w)
-{
- CompScreen *s = w->screen;
-
- THROW_SCREEN (s);
- THROW_WINDOW (w);
-
- tw->moving = FALSE;
-
- UNWRAP (ts, s, windowUngrabNotify);
- (*s->windowUngrabNotify) (w);
- WRAP (ts, s, windowUngrabNotify, throwWindowUngrabNotify);
-}
-
-static void
-throwWindowMoveNotify (CompWindow *w,
- int dx,
- int dy,
- Bool immediate)
-{
- THROW_WINDOW (w);
- THROW_SCREEN (w->screen);
-
- if (tw->moving)
- {
-
- if (tw->time < 1)
- tw->time = 1;
-
- tw->xVelocity = dx / tw->time;
- tw->yVelocity = dy / tw->time;
- tw->time = 1;
- }
-
- UNWRAP (ts, w->screen, windowMoveNotify);
- (*w->screen->windowMoveNotify) (w, dx, dy, immediate);
- WRAP (ts, w->screen, windowMoveNotify, throwWindowMoveNotify);
-}
-
-static Bool
-throwInitDisplay (CompPlugin *p,
- CompDisplay *d)
-{
- ThrowDisplay *td;
-
- if (!checkPluginABI ("core", CORE_ABIVERSION))
- return FALSE;
-
- td = malloc (sizeof (ThrowDisplay));
- if (!td)
- return FALSE;
-
- td->screenPrivateIndex = allocateScreenPrivateIndex (d);
- if (td->screenPrivateIndex < 0)
- {
- free (td);
- return FALSE;
- }
-
- d->base.privates[displayPrivateIndex].ptr = td;
-
- return TRUE;
-}
-
-static void
-throwFiniDisplay (CompPlugin *p,
- CompDisplay *d)
-{
- THROW_DISPLAY (d);
-
- freeScreenPrivateIndex (d, td->screenPrivateIndex);
-
- free (td);
-}
-
-static Bool
-throwInitScreen (CompPlugin *p,
- CompScreen *s)
-{
- ThrowScreen * ts;
-
- THROW_DISPLAY (s->display);
-
- ts = malloc (sizeof (ThrowScreen));
- if (!ts)
- return FALSE;
-
- ts->windowPrivateIndex = allocateWindowPrivateIndex (s);
- if (ts->windowPrivateIndex < 0)
- {
- free (ts);
- return FALSE;
- }
-
- WRAP (ts, s, windowGrabNotify, throwWindowGrabNotify);
- WRAP (ts, s, windowUngrabNotify, throwWindowUngrabNotify);
- WRAP (ts, s, preparePaintScreen, throwPreparePaintScreen);
- WRAP (ts, s, windowMoveNotify, throwWindowMoveNotify);
- WRAP (ts, s, donePaintScreen, throwDonePaintScreen);
-
- s->base.privates[td->screenPrivateIndex].ptr = ts;
-
- return TRUE;
-}
-
-static Bool
-throwInitWindow (CompPlugin *p,
- CompWindow *w)
-{
- ThrowWindow *tw;
-
- THROW_SCREEN (w->screen);
-
- tw = calloc (1, sizeof (ThrowWindow));
- if (!tw)
- return FALSE;
-
- tw->xVelocity = 0.0f;
- tw->yVelocity = 0.0f;
- tw->moving = FALSE;
- tw->time = 0;
-
- w->base.privates[ts->windowPrivateIndex].ptr = tw;
-
- return TRUE;
-}
-
-static void
-throwFiniWindow (CompPlugin *p,
- CompWindow *w)
-{
- THROW_WINDOW (w);
- free (tw);
-}
-
-static void
-throwFiniScreen (CompPlugin *p,
- CompScreen *s)
-{
- THROW_SCREEN (s);
-
- freeWindowPrivateIndex (s, ts->windowPrivateIndex);
-
- UNWRAP (ts, s, windowGrabNotify);
- UNWRAP (ts, s, windowUngrabNotify);
- UNWRAP (ts, s, preparePaintScreen);
- UNWRAP (ts, s, windowMoveNotify);
- UNWRAP (ts, s, donePaintScreen);
-
- free (ts);
-}
-
-static CompBool
-throwInitObject (CompPlugin *p,
- CompObject *o)
-{
- static InitPluginObjectProc dispTab[] = {
- (InitPluginObjectProc) 0, /* InitCore */
- (InitPluginObjectProc) throwInitDisplay,
- (InitPluginObjectProc) throwInitScreen,
- (InitPluginObjectProc) throwInitWindow,
- };
-
- RETURN_DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), TRUE, (p, o));
-}
-
-static void
-throwFiniObject (CompPlugin *p,
- CompObject *o)
-{
- static FiniPluginObjectProc dispTab[] = {
- (FiniPluginObjectProc) 0, /* FiniCore */
- (FiniPluginObjectProc) throwFiniDisplay,
- (FiniPluginObjectProc) throwFiniScreen,
- (FiniPluginObjectProc) throwFiniWindow,
- };
-
- DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), (p, o));
-}
-
-static Bool
-throwInit (CompPlugin *p)
-{
- displayPrivateIndex = allocateDisplayPrivateIndex ();
- if (displayPrivateIndex < 0)
- return FALSE;
-
- return TRUE;
-}
-
-static void
-throwFini (CompPlugin *p)
-{
- freeDisplayPrivateIndex(displayPrivateIndex);
-}
-
-static CompPluginVTable throwVTable = {
- "throw",
- 0,
- throwInit,
- throwFini,
- throwInitObject,
- throwFiniObject,
- 0,
- 0
-};
-
-CompPluginVTable*
-getCompPluginInfo (void)
-{
- return &throwVTable;
-}