Back to index

easystroke  0.5.5.1
water.cc
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2008-2009, Thomas Jaeger <ThJaeger@gmail.com>
00003  *
00004  * Permission to use, copy, modify, and/or distribute this software for any
00005  * purpose with or without fee is hereby granted, provided that the above
00006  * copyright notice and this permission notice appear in all copies.
00007  *
00008  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
00009  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
00010  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
00011  * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
00012  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
00013  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
00014  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
00015  */
00016 #include "water.h"
00017 #include <X11/Xlib.h>
00018 #include <stdio.h>
00019 
00020 Water::Water() {
00021        const char *ofc = "org.freedesktop.compiz";
00022        GError *error = 0;
00023        bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
00024        if (!bus) {
00025               g_error_free(error);
00026               throw DBusException();
00027        }
00028        char line[256];
00029        snprintf(line, sizeof(line), "/org/freedesktop/compiz/water/screen%d/line", DefaultScreen(dpy));
00030        line_proxy = dbus_g_proxy_new_for_name(bus, ofc, line, ofc);
00031 }
00032 
00033 void Water::draw(Point p, Point q) {
00034        dbus_g_proxy_call_no_reply(line_proxy, "activate",
00035                      G_TYPE_STRING, "root", G_TYPE_INT, gint(ROOT),
00036                      G_TYPE_STRING, "x0",   G_TYPE_INT, gint32(p.x),
00037                      G_TYPE_STRING, "y0",   G_TYPE_INT, gint32(p.y),
00038                      G_TYPE_STRING, "x1",   G_TYPE_INT, gint32(q.x),
00039                      G_TYPE_STRING, "y1",   G_TYPE_INT, gint32(q.y),
00040                      G_TYPE_INVALID);
00041 }