From 02d6e78a2540449d88f8f815b02ea85aad7f6ab1 Mon Sep 17 00:00:00 2001 From: Tomas Mudrunka Date: Thu, 19 Apr 2012 15:23:36 +0200 Subject: [PATCH] First part of vizionix - Linux software for making VJ projections --- c/vizionix/Makefile | 3 ++ c/vizionix/mkxsock.c | 73 +++++++++++++++++++++++++++++++++++++++++ c/vizionix/mplaywrap.sh | 4 +++ 3 files changed, 80 insertions(+) create mode 100644 c/vizionix/Makefile create mode 100644 c/vizionix/mkxsock.c create mode 100755 c/vizionix/mplaywrap.sh diff --git a/c/vizionix/Makefile b/c/vizionix/Makefile new file mode 100644 index 0000000..f737c37 --- /dev/null +++ b/c/vizionix/Makefile @@ -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 index 0000000..afc9beb --- /dev/null +++ b/c/vizionix/mkxsock.c @@ -0,0 +1,73 @@ +#include +#include +#include +#include + +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 index 0000000..02cd3e6 --- /dev/null +++ b/c/vizionix/mplaywrap.sh @@ -0,0 +1,4 @@ +#!/bin/bash +PATH="./:$PATH" +eval "$(mkxsock)" +mplayer -fs -wid "$XSOCK_WID" $@ -- 2.30.2