changeset 590:6584e697e6da trunk

[svn] - aosd: extended ghosd source with ghosd_set_event_button_cb to capture and handle button events in osd
author giacomo
date Wed, 31 Jan 2007 11:50:36 -0800
parents 7ad870f10241
children 8be45c22b20a
files ChangeLog src/aosd/ghosd-internal.h src/aosd/ghosd-main.c src/aosd/ghosd.c src/aosd/ghosd.h
diffstat 5 files changed, 64 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Jan 31 09:39:22 2007 -0800
+++ b/ChangeLog	Wed Jan 31 11:50:36 2007 -0800
@@ -1,3 +1,10 @@
+2007-01-31 17:39:22 +0000  Giacomo Lozito <james@develia.org>
+  revision [1264]
+  - aosd: added 'none' decoration, just displays text and optional shadow
+  trunk/src/aosd/aosd_style.c |   52 ++++++++++++++++++++++++++++++++++++++++----
+  1 file changed, 48 insertions(+), 4 deletions(-)
+
+
 2007-01-31 17:00:15 +0000  Giacomo Lozito <james@develia.org>
   revision [1262]
   - aosd: fix typo
--- a/src/aosd/ghosd-internal.h	Wed Jan 31 09:39:22 2007 -0800
+++ b/src/aosd/ghosd-internal.h	Wed Jan 31 11:50:36 2007 -0800
@@ -1,5 +1,8 @@
 /* ghosd -- OSD with fake transparency, cairo, and pango.
  * Copyright (C) 2006 Evan Martin <martine@danga.com>
+ *
+ * With further development by Giacomo Lozito <james@develia.org>
+ * for the ghosd-based Audacious OSD
  */
 
 #include <X11/Xlib.h>
@@ -12,6 +15,11 @@
   void (*data_destroy)(void*);
 } RenderCallback;
 
+typedef struct {
+  GhosdEventButtonCb func;
+  void *data;
+} EventButtonCallback;
+
 struct _Ghosd {
   Display *dpy;
   Window win;
@@ -20,6 +28,7 @@
   
   Pixmap background;
   RenderCallback render;
+  EventButtonCallback eventbutton;
 };
 
 /* vim: set ts=2 sw=2 et cino=(0 : */
--- a/src/aosd/ghosd-main.c	Wed Jan 31 09:39:22 2007 -0800
+++ b/src/aosd/ghosd-main.c	Wed Jan 31 11:50:36 2007 -0800
@@ -1,5 +1,8 @@
 /* ghosd -- OSD with fake transparency, cairo, and pango.
  * Copyright (C) 2006 Evan Martin <martine@danga.com>
+ *
+ * With further development by Giacomo Lozito <james@develia.org>
+ * for the ghosd-based Audacious OSD
  */
 
 #include "config.h"
@@ -12,6 +15,7 @@
 #include <time.h>
 #include <unistd.h>
 #include <errno.h>
+#include <gdk/gdk.h>
 
 #include "ghosd.h"
 #include "ghosd-internal.h"
@@ -47,6 +51,21 @@
       }
     }
     break;
+  case ButtonPress:
+    /* create a GhosdEventButton event and pass it to callback function */
+    if ( ghosd->eventbutton.func != NULL )
+    {
+      GhosdEventButton gevb;
+      gevb.x = ev.xbutton.x;
+      gevb.y = ev.xbutton.y;
+      gevb.x_root = ev.xbutton.x_root;
+      gevb.y_root = ev.xbutton.y_root;
+      gevb.button = ev.xbutton.button;
+      gevb.send_event = ev.xbutton.send_event;
+      gevb.time = ev.xbutton.time;
+      ghosd->eventbutton.func( ghosd , &gevb , ghosd->eventbutton.data );
+    }
+    break;
   }
 }
 
--- a/src/aosd/ghosd.c	Wed Jan 31 09:39:22 2007 -0800
+++ b/src/aosd/ghosd.c	Wed Jan 31 11:50:36 2007 -0800
@@ -1,5 +1,8 @@
 /* ghosd -- OSD with fake transparency, cairo, and pango.
  * Copyright (C) 2006 Evan Martin <martine@danga.com>
+ *
+ * With further development by Giacomo Lozito <james@develia.org>
+ * for the ghosd-based Audacious OSD
  */
 
 #include "config.h"
@@ -127,7 +130,7 @@
   att.border_pixel = 0;
   att.background_pixmap = None;
   att.save_under = True;
-  att.event_mask = ExposureMask | StructureNotifyMask;
+  att.event_mask = ExposureMask | StructureNotifyMask | ButtonPressMask;
   att.override_redirect = True;
 
   win = XCreateWindow(dpy, DefaultRootWindow(dpy),
@@ -201,6 +204,13 @@
                     ghosd->x, ghosd->y, ghosd->width, ghosd->height);
 }
 
+void
+ghosd_set_event_button_cb(Ghosd *ghosd, GhosdEventButtonCb func, void *user_data)
+{
+  ghosd->eventbutton.func = func;
+  ghosd->eventbutton.data = user_data;
+}
+
 #if 0
 static int
 x_error_handler(Display *dpy, XErrorEvent* evt) {
@@ -229,6 +239,7 @@
   ghosd->dpy = dpy;
   ghosd->win = win;
   ghosd->transparent = 1;
+  ghosd->eventbutton.func = NULL;
 
   return ghosd;
 }
--- a/src/aosd/ghosd.h	Wed Jan 31 09:39:22 2007 -0800
+++ b/src/aosd/ghosd.h	Wed Jan 31 11:50:36 2007 -0800
@@ -1,5 +1,8 @@
 /* ghosd -- OSD with fake transparency, cairo, and pango.
  * Copyright (C) 2006 Evan Martin <martine@danga.com>
+ *
+ * With further development by Giacomo Lozito <james@develia.org>
+ * for the ghosd-based Audacious OSD
  */
 
 #ifndef __GHOSD_H__
@@ -12,7 +15,19 @@
 
 typedef struct _Ghosd Ghosd;
 
+/* minimal struct to handle button events */
+typedef struct
+{
+  int x, y;
+  int send_event;
+  int x_root, y_root;
+  unsigned int button;
+  unsigned long time;
+}
+GhosdEventButton;
+
 typedef void (*GhosdRenderFunc)(Ghosd *ghosd, cairo_t *cr, void *user_data);
+typedef void (*GhosdEventButtonCb)(Ghosd *ghosd, GhosdEventButton *event, void *user_data);
 
 Ghosd *ghosd_new(void);
 void   ghosd_destroy(Ghosd* ghosd);
@@ -27,6 +42,8 @@
 void ghosd_show(Ghosd *ghosd);
 void ghosd_hide(Ghosd *ghosd);
 
+void ghosd_set_event_button_cb(Ghosd *ghosd, GhosdEventButtonCb cb, void *user_data );
+
 void ghosd_main_iterations(Ghosd *ghosd);
 void ghosd_main_until(Ghosd *ghosd, struct timeval *until);
 void ghosd_flash(Ghosd *ghosd, int fade_ms, int total_display_ms);