First part of vizionix - Linux software for making VJ projections
authorTomas Mudrunka <tomas@mudrunka.cz>
Thu, 19 Apr 2012 13:23:36 +0000 (15:23 +0200)
committerTomas Mudrunka <tomas@mudrunka.cz>
Thu, 19 Apr 2012 13:23:36 +0000 (15:23 +0200)
c/vizionix/Makefile [new file with mode: 0644]
c/vizionix/mkxsock.c [new file with mode: 0644]
c/vizionix/mplaywrap.sh [new file with mode: 0755]

diff --git a/c/vizionix/Makefile b/c/vizionix/Makefile
new file mode 100644 (file)
index 0000000..f737c37
--- /dev/null
@@ -0,0 +1,3 @@
+mkxsock: mkxsock.c
+       gcc -Wall -g $? -o $@ `pkg-config --cflags --libs gtk+-2.0` -export-dynamic
+
diff --git a/c/vizionix/mkxsock.c b/c/vizionix/mkxsock.c
new file mode 100644 (file)
index 0000000..afc9beb
--- /dev/null
@@ -0,0 +1,73 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <getopt.h>
+#include <gtk/gtk.h>
+
+void print_help(char ** argv) {
+       printf(
+               "Usage: %s [args]\n"
+               "Args:\n"
+               "\t -c color\n"
+               "\t -w width\n"
+               "\t -h height\n"
+               "\t -? (display help)"
+               "\nExample: %s -c black -w 640 -h 480\n\n",
+               argv[0], argv[0]);
+}
+
+gint main(gint argc, gchar ** argv)
+{
+       gchar *colorstr = "black";
+       int width = 640;
+       int height = 480;
+
+       int opt;
+       while ((opt = getopt(argc, argv, "?c:w:h:")) != -1) {
+               switch (opt) {
+                       case 'c':
+                               colorstr = optarg;
+                               break;
+                       case 'w':
+                               width = atoi(optarg);
+                               break;
+                       case 'h':
+                               height = atoi(optarg);
+                               break;
+                       case '?':
+                               print_help(argv);
+                               return 0;
+                               break;
+               }
+       }
+
+       //printf("%s\n", colorstr); return 0;
+
+       gtk_init(&argc, &argv);
+
+       //Colors
+       GdkColor color;
+       gdk_color_parse(colorstr, &color);
+
+       //Create window
+       GtkWidget *win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+       GtkWidget *sock = gtk_socket_new();
+       g_signal_connect(sock, "plug-removed", gtk_main_quit, NULL);
+       g_signal_connect(win, "delete-event", gtk_main_quit, NULL);
+       gtk_widget_set_size_request(sock, width, height);
+       gtk_widget_modify_bg(sock, GTK_STATE_NORMAL, &color);
+       gtk_container_add(GTK_CONTAINER(win), sock);
+       gtk_widget_show_all(win);
+
+       //Print id
+       GdkNativeWindow wid = gtk_socket_get_id(GTK_SOCKET(sock));
+       int pid;
+       if ((pid = fork())) {
+               printf("XSOCK_WID=%d\nXSOCK_PID=%d\n", wid, pid);
+               return 0;
+       }
+       fclose(stdout);
+
+       //Run
+       gtk_main();
+       return 0;
+}
diff --git a/c/vizionix/mplaywrap.sh b/c/vizionix/mplaywrap.sh
new file mode 100755 (executable)
index 0000000..02cd3e6
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/bash
+PATH="./:$PATH"
+eval "$(mkxsock)"
+mplayer -fs -wid "$XSOCK_WID" $@
This page took 0.129788 seconds and 4 git commands to generate.