summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlp Toker <alp@atoker.com>2006-06-19 21:13:48 +0100
committerAlp Toker <alp@atoker.com>2006-06-19 21:13:48 +0100
commit0bb5efa179666b00073d25fdc03e6985c3073a83 (patch)
treefc4ef83fe8d7b59b8614a64d7f5ab9518e9cdbd7
downloadcompiz-cil-0bb5efa179666b00073d25fdc03e6985c3073a83.tar.gz
compiz-cil-0bb5efa179666b00073d25fdc03e6985c3073a83.tar.bz2
Mono bindings for Compiz
This does not work yet.
-rw-r--r--AUTHORS1
-rw-r--r--COPYING21
-rw-r--r--README58
-rw-r--r--include.mk20
-rw-r--r--plugins/Cube.cs9
-rw-r--r--plugins/Makefile5
-rw-r--r--plugins/Simple.cs19
-rw-r--r--plugins/SvgCairo.cs85
-rw-r--r--plugins/Zoom.cs156
-rw-r--r--src/Display.cs12
-rw-r--r--src/Icon.cs8
-rw-r--r--src/Makefile3
-rw-r--r--src/Option.cs69
-rw-r--r--src/Plugin.cs8
-rw-r--r--src/Screen.cs94
-rw-r--r--src/Texture.cs14
-rw-r--r--src/Window.cs91
17 files changed, 673 insertions, 0 deletions
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..d6b9e4c
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1 @@
+Alp Toker <alp@atoker.com>
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..12c6f31
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,21 @@
+Copyright (c) 2006 Alp Toker and the individuals listed
+on the ChangeLog entries.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/README b/README
new file mode 100644
index 0000000..070aea1
--- /dev/null
+++ b/README
@@ -0,0 +1,58 @@
+COMPIZ-SHARP
+============
+
+The aim of this project is to provide a means of driving OpenGL
+compositing in the X Window System using the Mono framework. The
+project must achieve this in a way such that effects can be provided
+concurrently by individual effect plugins with their logic written
+purely in a CLS-compliant language supported by Mono, such as C#. The
+infrastructure itself is not restricted to this requirement and may be
+implemented with a combination of C "glue" code and C# in the style of
+existing bindings. The project must yield one or more effect plugins
+that demonstrates a sensible subset of functionality offered by GL
+compositing managers. Common sense should be the guiding force rather
+than a word-for-word adherence to the following plans, as this project
+explores some new ground:
+
+The project should achieve its goals by extending compiz
+non-invasively, ideally as a a regular compiz module which hosts the
+Mono runtime. In the case that this is infeasible or highly inelegant,
+the project mentor may be consulted as to whether it would be a better
+solution to extend compiz itself to allow more flexible extensions by
+working with the author of compiz and contributing to that project
+directly.
+
+David Reveman's description of compiz:
+
+compiz - OpenGL window and compositing manager
+
+ Compiz is an OpenGL compositing manager that uses
+ GLX_EXT_texture_from_pixmap for binding redirected top-level windows
+ to texture objects. It has a flexible plug-in system and it is
+ designed to run well on most graphics hardware.
+
+The API exposed by the project must cover the subset of entry points
+needed to create functional effect plugins, and should provide
+complete coverage of all relevant public API. The managed (C#) API may
+deviate in terminology from that used in compiz in order to follow the
+naming standards and style of the CLR and existing Mono libraries.
+
+The project should allow plugins to implement effects using Mono's Tao
+OpenGL library. This library has not been widely distributed and is
+not yet in a deliverable form, so some work towards making it
+shippable might be made but productisation of dependent libraries will
+generally be outwith the scope of the project.
+
+Code will be written foremost with maintainability, correctness and
+stability in mind, followed by completeness and performance concerns.
+Progress should be made such that there is demonstrable integration of
+Mono with the compositing manager for the mid-program evaluation, and
+a complete workable framework that meets the requirements set out in
+this specification by the time of the final evaluation.
+
+LICENSE
+=======
+
+All code and documentation produced for the project will be
+contributed under the terms of the MIT X11 license.
+
diff --git a/include.mk b/include.mk
new file mode 100644
index 0000000..19495e6
--- /dev/null
+++ b/include.mk
@@ -0,0 +1,20 @@
+CSC_DEBUGFLAGS=-debug -d:TRACE
+CSC=gmcs $(CSC_DEBUGFLAGS)
+MONO_DEBUGFLAGS=--debug
+RUNTIME=mono $(MONO_DEBUGFLAGS)
+
+#TODO: unsafe, resources
+#curr dir refs go in args
+
+#%.exe:
+%.exe %.dll %.module:
+ $(CSC) -out:$@ -t:$(TARGET) $(addprefix -pkg:,$(PKGS)) $(addprefix -r:,$(REFS)) $(addprefix -addmodule:,$(filter %.module,$^)) $(filter %.cs,$^)
+
+%.exe: TARGET = exe
+
+%.dll: TARGET = library
+
+%.module: TARGET = module
+
+#$(MODULE)_SOURCES := foo.cs
+
diff --git a/plugins/Cube.cs b/plugins/Cube.cs
new file mode 100644
index 0000000..9997b14
--- /dev/null
+++ b/plugins/Cube.cs
@@ -0,0 +1,9 @@
+using System;
+using Compiz;
+using Cairo;
+using Svg;
+
+//??
+public class CubeScreen : Screen
+{
+}
diff --git a/plugins/Makefile b/plugins/Makefile
new file mode 100644
index 0000000..2a7beb0
--- /dev/null
+++ b/plugins/Makefile
@@ -0,0 +1,5 @@
+REFS=../src/compiz-sharp.dll
+
+Zoom.dll: Zoom.cs
+
+include ../include.mk
diff --git a/plugins/Simple.cs b/plugins/Simple.cs
new file mode 100644
index 0000000..84abfb1
--- /dev/null
+++ b/plugins/Simple.cs
@@ -0,0 +1,19 @@
+using System;
+using Compiz;
+
+public class SimpleEffect
+{
+}
+
+//implements/inherits CompScreen class/iface?
+
+//Q: are options one-set-per-screen? i think so
+
+public class SimpleScreen
+{
+ [Option ("Zoom In")]
+ bool zoomIn;
+
+ [Option ("Window types")]
+ WindowType windowTypes;
+}
diff --git a/plugins/SvgCairo.cs b/plugins/SvgCairo.cs
new file mode 100644
index 0000000..29865c0
--- /dev/null
+++ b/plugins/SvgCairo.cs
@@ -0,0 +1,85 @@
+using System;
+using System.Runtime.InteropServices;
+using Cairo;
+
+namespace NDesk.Graphics
+{
+ public class Svg
+ {
+ [DllImport("svg-cairo")]
+ internal static extern IntPtr svg_cairo_create (out IntPtr svg_cairo);
+
+ [DllImport("svg-cairo")]
+ internal static extern IntPtr svg_cairo_destroy (out IntPtr svg_cairo);
+
+ [DllImport("svg-cairo")]
+ internal static extern IntPtr svg_cairo_parse (IntPtr svg_cairo, string filename);
+
+ [DllImport("svg-cairo")]
+ internal static extern IntPtr svg_cairo_parse_file (IntPtr svg_cairo, IntPtr file);
+
+ //TODO: verify
+ [DllImport("svg-cairo")]
+ internal static extern IntPtr svg_cairo_parse_buffer (IntPtr svg_cairo, byte[] buf, uint count);
+
+ [DllImport("svg-cairo")]
+ internal static extern IntPtr svg_cairo_parse_chunk_begin (IntPtr svg_cairo);
+
+ //TODO: verify
+ [DllImport("svg-cairo")]
+ internal static extern IntPtr svg_cairo_parse_chunk (IntPtr svg_cairo, byte[] buf, uint count);
+
+ [DllImport("svg-cairo")]
+ internal static extern IntPtr svg_cairo_parse_chunk_end (IntPtr svg_cairo);
+
+ [DllImport("svg-cairo")]
+ internal static extern IntPtr svg_cairo_render (IntPtr svg_cairo, IntPtr xrs);
+
+ [DllImport("svg-cairo")]
+ internal static extern IntPtr svg_cairo_set_viewport_dimension (IntPtr svg_cairo, uint width, uint height);
+
+ [DllImport("svg-cairo")]
+ internal static extern void svg_cairo_get_size (IntPtr svg_cairo, out uint width, out uint height);
+
+ public IntPtr Handle;
+
+ public Svg ()
+ {
+ svg_cairo_create (out Handle);
+ }
+
+ public void Render (Cairo.Context xrs)
+ {
+ svg_cairo_render (Handle, xrs.Handle);
+ }
+
+ public void Parse (string filename)
+ {
+ svg_cairo_parse (Handle, filename);
+ }
+
+ public void SetViewportDimension (uint width, uint height)
+ {
+ svg_cairo_set_viewport_dimension (Handle, width, height);
+ }
+
+ public void GetSize (out uint width, out uint height)
+ {
+ svg_cairo_get_size (Handle, out width, out height);
+ }
+ }
+
+ /* The returned status; not used yet:
+
+ protected enum Status
+ {
+ Success,
+ NoMemory,
+ IOError,
+ FileNotFound,
+ InvalidValue,
+ InvalidCall,
+ ParseError,
+ }
+ */
+}
diff --git a/plugins/Zoom.cs b/plugins/Zoom.cs
new file mode 100644
index 0000000..4ab7675
--- /dev/null
+++ b/plugins/Zoom.cs
@@ -0,0 +1,156 @@
+/* Copyright 2006 Alp Toker <alp@atoker.com> */
+
+using System;
+using Compiz;
+//using Tao.FreeGlut;
+//using Tao.OpenGl;
+
+/*
+public class ZoomEffect
+{
+}
+*/
+
+public class ZoomScreen
+{
+ const float SensitivityFactor = 0.001f;
+
+ [Option ("Pointer Invert Y")]
+ public bool invertY = false;
+
+ //Warning:
+ //sensitivity factor breaks consistency between interface and implementation
+ //Use a property?
+ [Option ("Pointer Sensitivity")]
+ public float sensitivity = 1.0f * SensitivityFactor;
+
+ //TODO: maybe do key bindings as methods?
+ //[Option ("Zoom In")]
+ //public Binding zoomIn;
+
+ [Option ("Zoom Speed")]
+ public float speed = 1.5f;
+
+ [Option ("Zoom Timestep")]
+ public float timestep = 1.2f;
+
+ [Option ("Filter Linear")]
+ public bool filterLinear = false;
+
+ int grabIndex;
+
+ //begin GL floats
+ float currentZoom = 1.0f;
+ float newZoom = 1.0f;
+
+ float xVelocity = 0.0f;
+ float yVelocity = 0.0f;
+ float zVelocity = 0.0f;
+
+ float xTranslate = 0.0f;
+ float yTranslate = 0.0f;
+
+ float xtrans;
+ float ytrans;
+ float ztrans;
+ //end GL floats
+
+ //XPoint savedPointer;
+ bool grabbed = false;
+
+ float maxTranslate = 0.0f;
+
+ //TODO: fabs() etc. misported
+ bool AdjustVelocity ()
+ {
+ float d, adjust, amount;
+
+ d = (newZoom - currentZoom) * 75.0f;
+
+ adjust = d * 0.002f;
+ amount = Math.Abs (d);
+ if (amount < 1.0f)
+ amount = 1.0f;
+ else if (amount > 5.0f)
+ amount = 5.0f;
+
+ zVelocity = (amount * zVelocity + adjust) / (amount + 1.0f);
+
+ return (Math.Abs (d) < 0.1f && Math.Abs (zVelocity) < 0.005f);
+ }
+
+ void PreparePaint (int msSinceLastPaint)
+ {
+ int steps;
+ float amount, chunk;
+
+ amount = msSinceLastPaint * 0.05f * speed;
+ steps = (int) (amount / (0.5f * timestep));
+ if (steps == 0)
+ steps = 1;
+ chunk = amount / (float) steps;
+
+ //for (; steps != 0 ; steps--)
+ while (steps-- != 0)
+ {
+ xVelocity /= 1.25f;
+ yVelocity /= 1.25f;
+
+ if (AdjustVelocity ())
+ {
+ currentZoom = newZoom;
+ zVelocity = 0.0f;
+ }
+ else
+ {
+ currentZoom += (zVelocity * msSinceLastPaint) / 1;//s->redrawTime;
+ }
+
+ }
+
+ }
+
+ void DonePaint ()
+ {
+ if (currentZoom != newZoom || xVelocity != 0 || yVelocity != 0 || zVelocity != 0)
+ //screen.Damage ();
+ Console.WriteLine ("damage");
+ }
+
+ void Paint (ScreenPaintAttrib sa, ScreenPaint mask)
+ {
+ sa.xTranslate += xtrans;
+ sa.yTranslate += ytrans;
+
+ sa.zCamera = -ztrans;
+
+ /* hack to get sides rendered correctly */
+ if (xtrans > 0.0f)
+ sa.xRotate += 0.000001f;
+ else
+ sa.xRotate -= 0.000001f;
+
+ mask &= ScreenPaint.Region;
+ mask |= ScreenPaint.Transformed;
+
+ //base.Paint (ref sa, mask);
+ }
+
+ void ZoomIn (int x, int y)
+ {
+ }
+
+ void ZoomOut ()
+ {
+ }
+
+ void ZoomTerminate ()
+ {
+ if (false) {
+ newZoom = 1.0f;
+ grabbed = false;
+
+ //screen.Damage ();
+ }
+ }
+}
diff --git a/src/Display.cs b/src/Display.cs
new file mode 100644
index 0000000..6d393dd
--- /dev/null
+++ b/src/Display.cs
@@ -0,0 +1,12 @@
+using System;
+
+namespace Compiz
+{
+ public class Display
+ {
+ //TODO: use events here?
+ public virtual void HandleEvent ()
+ {
+ }
+ }
+}
diff --git a/src/Icon.cs b/src/Icon.cs
new file mode 100644
index 0000000..7825329
--- /dev/null
+++ b/src/Icon.cs
@@ -0,0 +1,8 @@
+using System;
+
+namespace Compiz
+{
+ public class Icon : Texture
+ {
+ }
+}
diff --git a/src/Makefile b/src/Makefile
new file mode 100644
index 0000000..6ee2f86
--- /dev/null
+++ b/src/Makefile
@@ -0,0 +1,3 @@
+compiz-sharp.dll: Display.cs Icon.cs Option.cs Plugin.cs Screen.cs Texture.cs Window.cs
+
+include ../include.mk
diff --git a/src/Option.cs b/src/Option.cs
new file mode 100644
index 0000000..25aef42
--- /dev/null
+++ b/src/Option.cs
@@ -0,0 +1,69 @@
+using System;
+
+namespace Compiz
+{
+ public enum OptionType
+ {
+ Bool,
+ Int,
+ Float,
+ String,
+ Color,
+ Binding,
+ List,
+ }
+
+ public enum BindingType
+ {
+ None,
+ Key,
+ Button,
+ }
+
+ [AttributeUsage (AttributeTargets.Field, Inherited=true)]
+ public class Option : Attribute
+ {
+ public string name;
+ public string shortDesc;
+ public string longDesc;
+
+ /*
+ CompOptionType type;
+
+ //default value
+ CompOptionValue value;
+
+ CompOptionRestriction rest;
+ */
+
+ public Option (string name)
+ {
+ }
+ }
+
+ /*
+ [AttributeUsage (AttributeTargets.Field, Inherited=true)]
+ public class Restriction : Attribute
+ {
+ }
+
+ public class IntRestriction : Restriction
+ {
+ public int Min;
+ public int Max;
+ }
+
+ public class FloatRestriction : Restriction
+ {
+ public int Min;
+ public int Max;
+ }
+
+ public class StringRestriction : Restriction
+ {
+ public StringRestriction (string regex)
+ {
+ }
+ }
+ */
+}
diff --git a/src/Plugin.cs b/src/Plugin.cs
new file mode 100644
index 0000000..c857704
--- /dev/null
+++ b/src/Plugin.cs
@@ -0,0 +1,8 @@
+using System;
+
+namespace Compiz
+{
+ public class Plugin
+ {
+ }
+}
diff --git a/src/Screen.cs b/src/Screen.cs
new file mode 100644
index 0000000..7d53a45
--- /dev/null
+++ b/src/Screen.cs
@@ -0,0 +1,94 @@
+using System;
+
+namespace Compiz
+{
+ public class Screen
+ {
+ public Display Display;
+
+ public void Configure ()
+ {
+ }
+
+ /*
+ public void Damage (Region region)
+ {
+ }
+ */
+
+ public void Damage ()
+ {
+ }
+
+ public void DamagePending ()
+ {
+ }
+
+
+
+ public void MoveViewport (int tx, bool sync)
+ {
+ }
+
+
+
+
+
+
+ public void FocusDefaultWindow ()
+ {
+ }
+
+ public Screen ScreenAtDisplay ()
+ {
+ return null;
+ }
+
+ public void WarpPointer (int dx, int dy)
+ {
+ }
+
+ public bool Lighting
+ {
+ get {
+ return true;
+ }
+ }
+ }
+
+ public enum ScreenOption
+ {
+ }
+
+ public enum ScreenEdge
+ {
+ Left,
+ Right,
+ Top,
+ Bottom,
+ TopLeft,
+ TopRight,
+ BottomLeft,
+ BottomRight,
+ }
+
+ [Flags]
+ public enum ScreenPaint : uint
+ {
+ Region = 1 << 0,
+ Full = 1 << 1,
+ Transformed = 1 << 2,
+ WithTransformedWindows = 1 << 3,
+ Clear = 1 << 4,
+ }
+
+ public struct ScreenPaintAttrib {
+ public float xRotate;
+ public float yRotate;
+ public float vRotate;
+ public float xTranslate;
+ public float yTranslate;
+ public float zTranslate;
+ public float zCamera;
+ }
+}
diff --git a/src/Texture.cs b/src/Texture.cs
new file mode 100644
index 0000000..999460d
--- /dev/null
+++ b/src/Texture.cs
@@ -0,0 +1,14 @@
+using System;
+
+namespace Compiz
+{
+ public class Texture
+ {
+ }
+
+ public enum TextureFilter
+ {
+ Fast,
+ Good,
+ }
+}
diff --git a/src/Window.cs b/src/Window.cs
new file mode 100644
index 0000000..a278e23
--- /dev/null
+++ b/src/Window.cs
@@ -0,0 +1,91 @@
+using System;
+
+namespace Compiz
+{
+ public class Window
+ {
+ //with current design, this would need to be Screen<T>
+ public Screen Screen;
+
+ public void Map ()
+ {
+ }
+
+ public void Unmap ()
+ {
+ }
+
+ public void Bind ()
+ {
+ }
+
+ public void Release ()
+ {
+ }
+
+ public void Move (int dx, int dy, bool damage, bool immediate)
+ {
+ }
+
+ public void SyncWindowPosition ()
+ {
+ }
+
+
+ public void Activate ()
+ {
+ }
+
+ public void Close ()
+ {
+ }
+
+
+
+ public void Unredirect ()
+ {
+ }
+
+ public void Redirect ()
+ {
+ }
+
+ public int DefaultViewport
+ {
+ get {
+ return 0;
+ }
+ }
+
+ public Icon GetIcon (int width, int height)
+ {
+ return null;
+ }
+
+ [Flags]
+ //TODO: friendly naming, confirm order
+ public enum WindowType
+ {
+ Desktop = 1 << 0,
+ Dock = 1 << 1,
+ Toolbar = 1 << 2,
+ Menu = 1 << 3,
+ Utility = 1 << 4,
+ Splash = 1 << 5,
+ Dialog = 1 << 6,
+ ModalDialog = 1 << 7,
+ Normal = 1 << 8,
+ Fullscreen = 1 << 9,
+ Unknown = 1 << 10,
+ }
+
+ public struct WindowPaintAttrib
+ {
+ public ushort opacity;
+ public ushort brightness;
+ public ushort saturation;
+ public float xScale;
+ public float yScale;
+ }
+ }
+}