aboutsummaryrefslogtreecommitdiff
path: root/libtopmenu-server/topmenu-server.c
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2015-07-26 01:02:12 +0200
committerJavier <dev.git@javispedro.com>2015-07-26 01:02:12 +0200
commitbaef440d424640a6fc99edd8a12a6abcea80c5fc (patch)
tree7fb717c04564618d3c9c7b0db1c46ddde138bf5a /libtopmenu-server/topmenu-server.c
parentf690cd97506f45e02bb6383fde2a7c8f06820408 (diff)
downloadtopmenu-gtk-baef440d424640a6fc99edd8a12a6abcea80c5fc.tar.gz
topmenu-gtk-baef440d424640a6fc99edd8a12a6abcea80c5fc.zip
initial gtk2 "transparent" background attempt
Diffstat (limited to 'libtopmenu-server/topmenu-server.c')
-rw-r--r--libtopmenu-server/topmenu-server.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/libtopmenu-server/topmenu-server.c b/libtopmenu-server/topmenu-server.c
index 1e94398..7e5f3f7 100644
--- a/libtopmenu-server/topmenu-server.c
+++ b/libtopmenu-server/topmenu-server.c
@@ -17,21 +17,29 @@
* along with TopMenu. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <math.h>
+#include <string.h>
+#include <X11/Xatom.h>
#include <gtk/gtk.h>
+#include <gdk/gdkx.h>
+#include <cairo-xlib.h>
#include "topmenu-server.h"
#include "../global.h"
static GdkAtom selection_atom = GDK_NONE;
+static GdkAtom background_atom = GDK_NONE;
static GtkClipboard *selection_clipboard = NULL;
static GList *server_widgets = NULL;
+static G_DEFINE_QUARK(topmenu-server-stub, server_stub)
+
static void handle_selection_owner_change(GtkClipboard *clipboard, GdkEvent *event, gpointer user_data);
static void init_selection_monitor()
{
- if (!selection_clipboard || selection_atom == GDK_NONE) {
+ if (!selection_clipboard || selection_atom == GDK_NONE || background_atom == GDK_NONE) {
selection_atom = gdk_atom_intern_static_string(ATOM_TOPMENU_SERVER_SELECTION);
selection_clipboard = gtk_clipboard_get(selection_atom);
// Used to monitor the current owner of the server selection
@@ -45,7 +53,7 @@ static GdkWindow *get_front_server_stub()
{
if (server_widgets) {
GtkWidget *widget = server_widgets->data;
- gpointer data = g_object_get_data(G_OBJECT(widget), OBJECT_DATA_KEY_SERVER_STUB);
+ gpointer data = g_object_get_qdata(G_OBJECT(widget), server_stub_quark());
g_return_val_if_fail(data, NULL);
return GDK_WINDOW(data);
} else {
@@ -78,14 +86,14 @@ void topmenu_server_register_server_widget(GtkWidget *widget)
init_selection_monitor();
- g_return_if_fail(g_object_get_data(G_OBJECT(widget), OBJECT_DATA_KEY_SERVER_STUB) == NULL);
+ g_return_if_fail(g_object_get_qdata(G_OBJECT(widget), server_stub_quark()) == NULL);
GdkWindowAttr stub_attr = { 0 };
stub_attr.wclass = GDK_INPUT_ONLY;
stub_attr.override_redirect = TRUE;
GdkWindow *stub = gdk_window_new(window, &stub_attr, GDK_WA_NOREDIR);
- g_object_set_data_full(G_OBJECT(widget), OBJECT_DATA_KEY_SERVER_STUB, stub,
+ g_object_set_qdata_full(G_OBJECT(widget), server_stub_quark(), stub,
(GDestroyNotify) &gdk_window_destroy);
server_widgets = g_list_prepend(server_widgets, widget);
@@ -94,9 +102,9 @@ void topmenu_server_register_server_widget(GtkWidget *widget)
void topmenu_server_unregister_server_widget(GtkWidget *widget)
{
- g_return_if_fail(g_object_get_data(G_OBJECT(widget), OBJECT_DATA_KEY_SERVER_STUB) != NULL);
+ g_return_if_fail(g_object_get_qdata(G_OBJECT(widget), server_stub_quark()) != NULL);
server_widgets = g_list_remove_all(server_widgets, widget);
- gpointer data = g_object_steal_data(G_OBJECT(widget), OBJECT_DATA_KEY_SERVER_STUB);
+ gpointer data = g_object_steal_qdata(G_OBJECT(widget), server_stub_quark());
GdkWindow *stub = GDK_WINDOW(data);
gdk_window_destroy(stub);
}