summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorracarr <racarr>2007-01-27 20:08:07 +0000
committerracarr <racarr>2007-01-27 20:08:07 +0000
commit21c38e28fa5809b8eb2d95a13668f2b342a56b31 (patch)
tree92b39df391daca45573c2ad224a3be2058dd917f
downloadberyl-desktop-manager-21c38e28fa5809b8eb2d95a13668f2b342a56b31.tar.gz
beryl-desktop-manager-21c38e28fa5809b8eb2d95a13668f2b342a56b31.tar.bz2
Add beryl-desktop-manager, be gentle, not much time put in to it so far
-rw-r--r--src/HOWTO6
-rw-r--r--src/Makefile2
-rw-r--r--src/bdm.c172
3 files changed, 180 insertions, 0 deletions
diff --git a/src/HOWTO b/src/HOWTO
new file mode 100644
index 0000000..ff2a156
--- /dev/null
+++ b/src/HOWTO
@@ -0,0 +1,6 @@
+For now beryl desktop manager expects a file in ~/.bdm named wallpapers.list
+with at least one entry. Each entry should be a path to an image which will be
+successively assigned to a viewport. Each Entry should be a line by itself. In
+beryl-settings enable the option under Desktop background of core (for now).
+
+
diff --git a/src/Makefile b/src/Makefile
new file mode 100644
index 0000000..cb2cbf0
--- /dev/null
+++ b/src/Makefile
@@ -0,0 +1,2 @@
+all:
+ gcc -g `pkg-config --libs --cflags gtk+-2.0 x11 glib-2.0 cairo` bdm.c -o bdm
diff --git a/src/bdm.c b/src/bdm.c
new file mode 100644
index 0000000..54d26d9
--- /dev/null
+++ b/src/bdm.c
@@ -0,0 +1,172 @@
+/*
+* Author: Robert Carr <racarr@beryl-project.org
+*/
+
+#include <string.h>
+#include <gtk/gtk.h>
+#include <gdk/gdk.h>
+#include <gdk/gdkx.h>
+#include <gdk/gdkprivate.h>
+#include <cairo/cairo.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+
+cairo_t * g_pCairoContext;
+
+static void render (int width, int height, GdkPixbuf *pixbuf)
+{
+ cairo_set_source_rgba(g_pCairoContext,0,0,0,0);
+ cairo_paint(g_pCairoContext);
+ cairo_save(g_pCairoContext);
+ gdk_cairo_set_source_pixbuf(g_pCairoContext,pixbuf,width,height);
+ cairo_rectangle(g_pCairoContext, 0, 0, width,height);
+ cairo_fill(g_pCairoContext);
+ cairo_stroke(g_pCairoContext);
+
+ cairo_paint(g_pCairoContext);
+ cairo_restore(g_pCairoContext);
+}
+
+static gboolean on_alpha_window_expose(GtkWidget * widget, GdkEventExpose * expose, GdkPixbuf *pixbuf)
+{
+ static int iWidth;
+ static int iHeight;
+ g_pCairoContext = gdk_cairo_create(widget->window);
+
+ cairo_set_operator (g_pCairoContext, CAIRO_OPERATOR_SOURCE);
+ gtk_window_get_size(GTK_WINDOW(widget),iWidth,iHeight);
+ render(iWidth,iHeight,pixbuf);
+ cairo_destroy (g_pCairoContext);
+
+
+}
+
+
+
+static void on_alpha_screen_changed(GtkWidget * widget, GdkScreen * pOldScreen, GtkWidget * label)
+{
+ GdkScreen * pScreen = gtk_window_get_screen(widget);
+ GdkColormap * pColormap = gdk_screen_get_rgba_colormap (pScreen);
+
+ gtk_widget_set_colormap(widget,pColormap);
+}
+
+int main(int argc, char * argv[])
+{
+ GtkWidget * window;
+ GtkWidget * hbox;
+ Display * display;
+ Window root;
+ Atom desktopGeometryAtom;
+ Atom actual;
+ Atom bigViewportAtom;
+ int result, format;
+ unsigned long n, left;
+ unsigned char *propData;
+ unsigned long data[2];
+ int viewx, viewy;
+ int onex, oney;
+ int numx, numy;
+ int i;
+ int j;
+ Bool backwards;
+
+ display = XOpenDisplay(getenv("DISPLAY"));
+ root = XDefaultRootWindow(display);
+
+ desktopGeometryAtom = XInternAtom(display, "_NET_DESKTOP_GEOMETRY", 0);
+ bigViewportAtom = XInternAtom(display, "_BERYL_DESKTOP_MANAGED", 0);
+
+ unsigned long datas = 1;
+
+ int retVal = XChangeProperty(display, XRootWindow(display,0), bigViewportAtom,
+ XA_CARDINAL, 32, PropModeReplace,
+ (unsigned char *)&datas, 1);
+
+ printf(" \n retVal: %d \n \n",retVal);
+
+ result = XGetWindowProperty(display,root,desktopGeometryAtom,0L,2L,FALSE,XA_CARDINAL,&actual, &format, &n, &left, &propData);
+
+ if (result == Success && n && propData)
+ {
+ memcpy(data, propData, sizeof(unsigned long)*2);
+ XFree(propData);
+
+ if (data[0] > 0 && data[0] < 0xffffffff)
+ {
+ viewx = data[0];
+ viewy = data[1];
+ }
+ }
+
+ gtk_init(&argc,&argv);
+
+ printf("Resolution: %d x %d \n \n",data[0],data[1]);
+ onex = gdk_screen_get_width(gdk_screen_get_default());
+ oney = gdk_screen_get_height(gdk_screen_get_default());
+ printf("One res: %d x %d \n \n",onex,oney);
+ numx = viewx/onex;
+ numy = viewy/oney;
+ char * homedir = getenv("HOME");
+ char * bla = g_strconcat(homedir,"/.bdm/wallpaper.list");
+ FILE * file = fopen(bla,"r");
+
+ char * filenames;
+ filenames=malloc(100*numx);
+ char * walk = filenames;
+ for (i = 0; i < numx; i++)
+ {
+ if (!fgets(walk,100,file))
+ {
+ strcpy(walk,walk-100);
+ }
+
+ walk=g_strchomp(walk);
+
+ walk+=100;
+ }
+
+ backwards = FALSE;
+
+ walk = filenames;
+
+ for (j = 0; j < numy ; j++)
+ {
+
+ for (i = 0; i < numx ; i++)
+ {
+ GtkWidget * dwindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_default_size(GTK_WINDOW(dwindow),onex,oney);
+ gtk_window_set_screen(GTK_WINDOW(dwindow),gdk_screen_get_default());
+ gtk_window_set_decorated(GTK_WINDOW(dwindow),FALSE);
+ gtk_window_set_type_hint(GTK_WINDOW(dwindow),GDK_WINDOW_TYPE_HINT_DESKTOP);
+ GdkPixbuf * pixbuf = gdk_pixbuf_new_from_file(walk,NULL);
+ GdkPixbuf * scaledpix = gdk_pixbuf_scale_simple(pixbuf,1280,800,GDK_INTERP_NEAREST);
+ //GtkImage * image = gtk_image_new_from_pixbuf(scaledpix);
+ //gtk_widget_show(image);
+ //gtk_container_add(GTK_CONTAINER(dwindow),GTK_WIDGET(image));
+ gtk_window_move(GTK_WINDOW(dwindow),i*onex,j*oney);
+ on_alpha_screen_changed(dwindow,NULL,NULL);
+ gtk_window_resize(GTK_WINDOW(dwindow),onex,oney);
+ gtk_widget_set_app_paintable(dwindow, TRUE);
+ g_signal_connect( G_OBJECT(dwindow),"expose-event",G_CALLBACK(on_alpha_window_expose),scaledpix);
+ gtk_widget_show(GTK_WINDOW(dwindow));
+ if (!backwards)
+ walk+=100;
+ else
+ walk-=100;
+ }
+ backwards = !backwards;
+ if (backwards)
+ walk-=100;
+
+ }
+
+
+ gtk_main();
+}