[gtk+/gtk-2-22] directfb: event manager rewrite



commit 5538315d38ce6a71c94e3c674b723bb272adf9ed
Author: Lionel Landwerlin <llandwerlin gmail com>
Date:   Fri May 14 12:14:08 2010 +0200

    directfb: event manager rewrite
    
    The event translation code used to deal a lot with gdk internals. It
    seems a lot of code has been pushed to the generic gdk code, so we
    needed to rewrite the things a little bit.
    
    Signed-off-by: Lionel Landwerlin <llandwerlin gmail com>

 gdk/directfb/gdkevents-directfb.c |  646 +++++++++++++------------------------
 1 files changed, 224 insertions(+), 422 deletions(-)
---
diff --git a/gdk/directfb/gdkevents-directfb.c b/gdk/directfb/gdkevents-directfb.c
index bf14104..60048a7 100644
--- a/gdk/directfb/gdkevents-directfb.c
+++ b/gdk/directfb/gdkevents-directfb.c
@@ -52,112 +52,80 @@ gboolean gdk_net_wm_supports (GdkAtom property);
 #define EventBuffer _gdk_display->buffer
 #define DirectFB _gdk_display->directfb
 
-
-
-
 #include "gdkaliasdef.c"
 
+D_DEBUG_DOMAIN (GDKDFB_Events, "GDKDFB/Events", "GDK DirectFB Events");
+D_DEBUG_DOMAIN (GDKDFB_MouseEvents, "GDKDFB/Events/Mouse", "GDK DirectFB Mouse Events");
+D_DEBUG_DOMAIN (GDKDFB_WindowEvents, "GDKDFB/Events/Window", "GDK DirectFB Window Events");
+D_DEBUG_DOMAIN (GDKDFB_KeyEvents, "GDKDFB/Events/Key", "GDK DirectFB Key Events");
+
 /*********************************************
  * Functions for maintaining the event queue *
  *********************************************/
 
-static GdkEvent * gdk_event_translate  (DFBWindowEvent  *dfbevent,
-                                        GdkWindow       *window);
+static gboolean gdk_event_translate  (GdkEvent       *event,
+                                      DFBWindowEvent *dfbevent,
+                                      GdkWindow      *window);
 
 /*
  * Private variable declarations
  */
 static GList *client_filters;  /* Filters for client messages */
 
-
-static void
-fixup_event (GdkEvent *event)
-{
-  if (event->any.window)
-    g_object_ref (event->any.window);
-  if (((event->any.type == GDK_ENTER_NOTIFY) ||
-       (event->any.type == GDK_LEAVE_NOTIFY)) &&
-      (event->crossing.subwindow != NULL))
-    g_object_ref (event->crossing.subwindow);
-  event->any.send_event = FALSE;
-}
-
-static GdkFilterReturn
-apply_filters (GdkWindow      *window,
-               DFBWindowEvent *dfbevent,
-               GList          *filters)
+static gint
+gdk_event_apply_filters (DFBWindowEvent *dfbevent,
+                         GdkEvent *event,
+                         GList *filters)
 {
-  GdkFilterReturn result = GDK_FILTER_CONTINUE;
-  GdkEvent *event;
-  GList *node;
   GList *tmp_list;
-
-  event = gdk_event_new (GDK_NOTHING);
-  if (window != NULL)
-    event->any.window = g_object_ref (window);
-  ((GdkEventPrivate *)event)->flags |= GDK_EVENT_PENDING;
-
-  /* I think GdkFilterFunc semantics require the passed-in event
-   * to already be in the queue. The filter func can generate
-   * more events and append them after it if it likes.
-   */
-  node = _gdk_event_queue_append ((GdkDisplay*)_gdk_display, event);
+  GdkFilterReturn result;
 
   tmp_list = filters;
+
   while (tmp_list)
     {
-      GdkEventFilter *filter = (GdkEventFilter *) tmp_list->data;
+      GdkEventFilter *filter = (GdkEventFilter*) tmp_list->data;
 
       tmp_list = tmp_list->next;
       result = filter->function (dfbevent, event, filter->data);
-      if (result != GDK_FILTER_CONTINUE)
-        break;
+      if (result !=  GDK_FILTER_CONTINUE)
+        return result;
     }
 
-  if (result == GDK_FILTER_CONTINUE || result == GDK_FILTER_REMOVE)
-    {
-      _gdk_event_queue_remove_link ((GdkDisplay*)_gdk_display, node);
-      g_list_free_1 (node);
-      gdk_event_free (event);
-    }
-  else /* GDK_FILTER_TRANSLATE */
-    {
-      ((GdkEventPrivate *)event)->flags &= ~GDK_EVENT_PENDING;
-      fixup_event (event);
-    }
-  return result;
+  return GDK_FILTER_CONTINUE;
 }
 
 static void
-dfb_events_process_window_event (DFBWindowEvent *event)
+dfb_events_process_window_event (DFBWindowEvent *dfbevent)
 {
-  GdkWindow *window;
-
-  /*
-   * Apply global filters
-   *
-   * If result is GDK_FILTER_CONTINUE, we continue as if nothing
-   * happened. If it is GDK_FILTER_REMOVE or GDK_FILTER_TRANSLATE,
-   * we return TRUE and won't dispatch the event.
-   */
-  if (_gdk_default_filters)
-    {
-      switch (apply_filters (NULL, event, _gdk_default_filters))
-        {
-        case GDK_FILTER_REMOVE:
-        case GDK_FILTER_TRANSLATE:
-          return;
-
-        default:
-          break;
-        }
-    }
+  GdkDisplay *display = gdk_display_get_default ();
+  GdkWindow  *window;
+  GdkEvent   *event;
+  GList      *node;
 
-  window = gdk_directfb_window_id_table_lookup (event->window_id);
+  window = gdk_directfb_window_id_table_lookup (dfbevent->window_id);
   if (!window)
     return;
 
-  gdk_event_translate (event, window);
+  event = gdk_event_new (GDK_NOTHING);
+
+  event->any.window = NULL;
+
+  ((GdkEventPrivate *)event)->flags |= GDK_EVENT_PENDING;
+
+  node = _gdk_event_queue_append (display, event);
+
+  if (gdk_event_translate (event, dfbevent, window))
+    {
+      ((GdkEventPrivate *)event)->flags &= ~GDK_EVENT_PENDING;
+      _gdk_windowing_got_event (display, node, event, 0);
+    }
+  else
+    {
+      _gdk_event_queue_remove_link (display, node);
+      g_list_free_1 (node);
+      gdk_event_free (event);
+    }
 }
 
 static gboolean
@@ -471,437 +439,271 @@ gdk_directfb_child_at (GdkWindow *window,
   return window;
 }
 
-static GdkEvent *
-gdk_event_translate (DFBWindowEvent *dfbevent,
+static gboolean
+gdk_event_translate (GdkEvent       *event,
+                     DFBWindowEvent *dfbevent,
                      GdkWindow      *window)
 {
   GdkWindowObject *private;
   GdkDisplay      *display;
-  GdkEvent        *event    = NULL;
+  /* GdkEvent        *event    = NULL; */
+  gboolean return_val = FALSE;
 
-  g_return_val_if_fail (dfbevent != NULL, NULL);
-  g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
+  g_return_val_if_fail (event != NULL, FALSE);
+  g_return_val_if_fail (dfbevent != NULL, FALSE);
+  g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE);
+
+  D_DEBUG_AT (GDKDFB_Events, "%s( %p, %p, %p )\n", G_STRFUNC,
+              event, dfbevent, window);
 
   private = GDK_WINDOW_OBJECT (window);
 
   g_object_ref (G_OBJECT (window));
 
+  event->any.window = NULL;
+  event->any.send_event = FALSE;
+
   /*
-   * Apply per-window filters
+   * Apply global filters
    *
    * If result is GDK_FILTER_CONTINUE, we continue as if nothing
    * happened. If it is GDK_FILTER_REMOVE or GDK_FILTER_TRANSLATE,
    * we return TRUE and won't dispatch the event.
    */
-  if (private->filters)
+  if (_gdk_default_filters)
     {
-      switch (apply_filters (window, dfbevent, private->filters))
-        {
-        case GDK_FILTER_REMOVE:
-        case GDK_FILTER_TRANSLATE:
-          g_object_unref (G_OBJECT (window));
-          return NULL;
+      GdkFilterReturn result;
+      result = gdk_event_apply_filters (dfbevent, event, _gdk_default_filters);
 
-        default:
-          break;
+      if (result != GDK_FILTER_CONTINUE)
+        {
+          return_val = (result == GDK_FILTER_TRANSLATE) ? TRUE : FALSE;
+          goto done;
         }
     }
 
+  /* Apply per-window filters */
+  if (GDK_IS_WINDOW (window))
+    {
+      GdkFilterReturn result;
+
+      if (private->filters)
+	{
+	  result = gdk_event_apply_filters (dfbevent, event, private->filters);
+
+	  if (result != GDK_FILTER_CONTINUE)
+	    {
+	      return_val = (result == GDK_FILTER_TRANSLATE) ? TRUE : FALSE;
+	      goto done;
+	    }
+	}
+    }
+
   display = gdk_drawable_get_display (GDK_DRAWABLE (window));
 
+  return_val = TRUE;
+
   switch (dfbevent->type)
     {
     case DWET_BUTTONDOWN:
     case DWET_BUTTONUP:
-      {
-        static gboolean  click_grab = FALSE;
-        GdkWindow       *child;
-        gint             wx, wy;
-        guint            mask;
-        guint            button;
+      /* Backend store */
+      _gdk_directfb_mouse_x = dfbevent->cx;
+      _gdk_directfb_mouse_y = dfbevent->cy;
 
-        _gdk_directfb_mouse_x = wx = dfbevent->cx;
-        _gdk_directfb_mouse_y = wy = dfbevent->cy;
+      /* Event translation */
+      gdk_directfb_event_fill (event, window,
+                               dfbevent->type == DWET_BUTTONDOWN ?
+                               GDK_BUTTON_PRESS : GDK_BUTTON_RELEASE);
+      switch (dfbevent->button)
+        {
+        case DIBI_LEFT:
+          event->button.button = 1;
+          break;
 
-        switch (dfbevent->button)
-          {
-          case DIBI_LEFT:
-            button = 1;
-            mask   = GDK_BUTTON1_MASK;
+        case DIBI_MIDDLE:
+            event->button.button = 2;
             break;
-          case DIBI_MIDDLE:
-            button = 2;
-            mask   = GDK_BUTTON2_MASK;
-            break;
-          case DIBI_RIGHT:
-            button = 3;
-            mask   = GDK_BUTTON3_MASK;
-            break;
-          default:
-            button = dfbevent->button + 1;
-            mask   = 0;
-            break;
-          }
-
-        child = gdk_directfb_child_at (_gdk_parent_root, &wx, &wy);
-
-        if (_gdk_directfb_pointer_grab_window &&
-            (_gdk_directfb_pointer_grab_events & (dfbevent->type ==
-                                                  DWET_BUTTONDOWN ?
-                                                  GDK_BUTTON_PRESS_MASK :
-                                                  GDK_BUTTON_RELEASE_MASK)) &&
-            (_gdk_directfb_pointer_grab_owner_events == FALSE ||
-             child == _gdk_parent_root) )
-          {
-            GdkDrawableImplDirectFB *impl;
-
-            child = _gdk_directfb_pointer_grab_window;
-            impl  = GDK_DRAWABLE_IMPL_DIRECTFB (GDK_WINDOW_OBJECT (child)->impl);
-
-            dfbevent->x = dfbevent->cx - impl->abs_x;
-            dfbevent->y = dfbevent->cy - impl->abs_y;
-          }
-        else if (!_gdk_directfb_pointer_grab_window ||
-                 (_gdk_directfb_pointer_grab_owner_events == TRUE))
-          {
-            dfbevent->x = wx;
-            dfbevent->y = wy;
-          }
-        else
-          {
-            child = NULL;
-          }
 
-        if (dfbevent->type == DWET_BUTTONDOWN)
-          _gdk_directfb_modifiers |= mask;
-        else
-          _gdk_directfb_modifiers &= ~mask;
+        case DIBI_RIGHT:
+          event->button.button = 3;
+          break;
 
-        if (child)
-          {
-            event =
-              gdk_directfb_event_make (child,
-                                       dfbevent->type == DWET_BUTTONDOWN ?
-                                       GDK_BUTTON_PRESS : GDK_BUTTON_RELEASE);
-
-            event->button.x_root = _gdk_directfb_mouse_x;
-            event->button.y_root = _gdk_directfb_mouse_y;
-
-            event->button.x = dfbevent->x;
-            event->button.y = dfbevent->y;
-
-            event->button.state  = _gdk_directfb_modifiers;
-            event->button.button = button;
-            event->button.device = display->core_pointer;
-
-            GDK_NOTE (EVENTS,
-                      g_message ("button: %d at %d,%d %s with state 0x%08x",
-                                 event->button.button,
-                                 (int)event->button.x, (int)event->button.y,
-                                 dfbevent->type == DWET_BUTTONDOWN ?
-                                 "pressed" : "released",
-                                 _gdk_directfb_modifiers));
-
-            if (dfbevent->type == DWET_BUTTONDOWN)
-              _gdk_event_button_generate (display, event);
-          }
+          default:
+            event->button.button = dfbevent->button + 1;
+            break;
+        }
 
-        /* Handle implicit button grabs: */
-        if (dfbevent->type == DWET_BUTTONDOWN  &&  !click_grab  &&  child)
-          {
-            if (gdk_directfb_pointer_grab (child, FALSE,
-                                           gdk_window_get_events (child),
-                                           NULL, NULL,
-                                           GDK_CURRENT_TIME,
-                                           TRUE) == GDK_GRAB_SUCCESS)
-              click_grab = TRUE;
-          }
-        else if (dfbevent->type == DWET_BUTTONUP &&
-                 !(_gdk_directfb_modifiers & (GDK_BUTTON1_MASK |
-                                              GDK_BUTTON2_MASK |
-                                              GDK_BUTTON3_MASK)) && click_grab)
-          {
-            gdk_directfb_pointer_ungrab (GDK_CURRENT_TIME, TRUE);
-            click_grab = FALSE;
-          }
-      }
+      event->button.window = window;
+      event->button.x_root = dfbevent->cx;
+      event->button.y_root = dfbevent->cy;
+      event->button.x      = dfbevent->x;
+      event->button.y      = dfbevent->y;
+      event->button.state  = _gdk_directfb_modifiers;
+      event->button.device = display->core_pointer;
+      gdk_event_set_screen (event, _gdk_screen);
+
+      D_DEBUG_AT (GDKDFB_MouseEvents, "  -> %s at %ix%i\n",
+                  event->type == GDK_BUTTON_PRESS ? "buttonpress" : "buttonrelease",
+                  (gint) event->button.x, (gint) event->button.y);
       break;
 
     case DWET_MOTION:
-      {
-        GdkWindow *event_win=NULL;
-        GdkWindow *child;
-
-        _gdk_directfb_mouse_x = dfbevent->cx;
-        _gdk_directfb_mouse_y = dfbevent->cy;
-
-	//child = gdk_directfb_child_at (window, &dfbevent->x, &dfbevent->y);
-        /* Go all the way to root to catch popup menus */
-        int wx=_gdk_directfb_mouse_x;
-        int wy=_gdk_directfb_mouse_y;
-	child = gdk_directfb_child_at (_gdk_parent_root, &wx, &wy);
-
-        /* first let's see if any cossing event has to be send */
-        gdk_directfb_window_send_crossing_events (NULL, child, GDK_CROSSING_NORMAL);
-
-        /* then dispatch the motion event to the window the cursor it's inside */
-        event_win = gdk_directfb_pointer_event_window (child, GDK_MOTION_NOTIFY);
-
-
-        if (event_win)
-          {
-            if (event_win == _gdk_directfb_pointer_grab_window) {
-              GdkDrawableImplDirectFB *impl;
-
-              child = _gdk_directfb_pointer_grab_window;
-              impl = GDK_DRAWABLE_IMPL_DIRECTFB (GDK_WINDOW_OBJECT (child)->impl);
-
-              dfbevent->x = _gdk_directfb_mouse_x - impl->abs_x;
-              dfbevent->y = _gdk_directfb_mouse_y - impl->abs_y;
-            }
-
-            event = gdk_directfb_event_make (child, GDK_MOTION_NOTIFY);
-
-            event->motion.x_root = _gdk_directfb_mouse_x;
-            event->motion.y_root = _gdk_directfb_mouse_y;
-
-            //event->motion.x = dfbevent->x;
-            //event->motion.y = dfbevent->y;
-            event->motion.x = wx;
-            event->motion.y = wy;
-
-            event->motion.state   = _gdk_directfb_modifiers;
-            event->motion.is_hint = FALSE;
-            event->motion.device  = display->core_pointer;
+      /* Backend store */
+      _gdk_directfb_mouse_x = dfbevent->cx;
+      _gdk_directfb_mouse_y = dfbevent->cy;
 
-            if (GDK_WINDOW_OBJECT (event_win)->event_mask &
-                GDK_POINTER_MOTION_HINT_MASK)
-              {
-                while (EventBuffer->PeekEvent (EventBuffer,
-                                               DFB_EVENT (dfbevent)) == DFB_OK
-                       && dfbevent->type == DWET_MOTION)
-                  {
-                    EventBuffer->GetEvent (EventBuffer, DFB_EVENT (dfbevent));
-                    event->motion.is_hint = TRUE;
-                  }
-              }
-          }
-        /* make sure crossing events go to the event window found */
-        /*        GdkWindow *ev_win = (event_win == NULL) ? gdk_window_at_pointer (NULL,NULL) :event_win;
-                  gdk_directfb_window_send_crossing_events (NULL,ev_win,GDK_CROSSING_NORMAL);
-        */
-      }
+      /* Event translation */
+      gdk_directfb_event_fill (event, window, GDK_MOTION_NOTIFY);
+      event->motion.x_root  = dfbevent->cx;
+      event->motion.y_root  = dfbevent->cy;
+      event->motion.x       = dfbevent->x;
+      event->motion.y       = dfbevent->y;
+      event->motion.axes    = NULL;
+      event->motion.state   = _gdk_directfb_modifiers;
+      event->motion.is_hint = FALSE;
+      event->motion.device  = display->core_pointer;
+      gdk_event_set_screen (event, _gdk_screen);
+
+      D_DEBUG_AT (GDKDFB_MouseEvents, "  -> move pointer to %ix%i\n",
+                  (gint) event->button.x, (gint) event->button.y);
       break;
 
     case DWET_GOTFOCUS:
-      gdk_directfb_change_focus (window);
+      gdk_directfb_event_fill (event, window, GDK_FOCUS_CHANGE);
+      event->focus_change.window = window;
+      event->focus_change.in     = TRUE;
       break;
 
     case DWET_LOSTFOCUS:
-      gdk_directfb_change_focus (_gdk_parent_root);
-
+      gdk_directfb_event_fill (event, window, GDK_FOCUS_CHANGE);
+      event->focus_change.window = window;
+      event->focus_change.in     = FALSE;
       break;
 
     case DWET_POSITION:
-      {
-        GdkWindow *event_win;
-
-        private->x = dfbevent->x;
-        private->y = dfbevent->y;
-
-        event_win = gdk_directfb_other_event_window (window, GDK_CONFIGURE);
-
-        if (event_win)
-          {
-            event = gdk_directfb_event_make (event_win, GDK_CONFIGURE);
-            event->configure.x = dfbevent->x;
-            event->configure.y = dfbevent->y;
-            event->configure.width =
-              GDK_DRAWABLE_IMPL_DIRECTFB (private->impl)->width;
-            event->configure.height =
-              GDK_DRAWABLE_IMPL_DIRECTFB (private->impl)->height;
-          }
-
-      }
+      gdk_directfb_event_fill (event, window, GDK_CONFIGURE);
+      event->configure.x      = dfbevent->x;
+      event->configure.y      = dfbevent->y;
+      event->configure.width  = private->width;
+      event->configure.height = private->height;
       break;
 
     case DWET_POSITION_SIZE:
-      private->x = dfbevent->x;
-      private->y = dfbevent->y;
+      event->configure.x = dfbevent->x;
+      event->configure.y = dfbevent->y;
       /* fallthru */
 
     case DWET_SIZE:
-      {
-        GdkDrawableImplDirectFB *impl;
-        GdkWindow               *event_win;
-        GList                   *list;
-
-        impl = GDK_DRAWABLE_IMPL_DIRECTFB (private->impl);
-
-        event_win = gdk_directfb_other_event_window (window, GDK_CONFIGURE);
-
-        if (event_win)
-          {
-            event = gdk_directfb_event_make (event_win, GDK_CONFIGURE);
-            event->configure.x      = private->x;
-            event->configure.y      = private->y;
-            event->configure.width  = dfbevent->w;
-            event->configure.height = dfbevent->h;
-          }
-
-        impl->width  = dfbevent->w;
-        impl->height = dfbevent->h;
-
-        for (list = private->children; list; list = list->next)
-          {
-            GdkWindowObject         *win;
-            GdkDrawableImplDirectFB *impl;
-
-            win  = GDK_WINDOW_OBJECT (list->data);
-            impl = GDK_DRAWABLE_IMPL_DIRECTFB (win->impl);
-
-            _gdk_directfb_move_resize_child (GDK_WINDOW (win),
-                                             win->x, win->y,
-                                             impl->width, impl->height);
-          }
-
-        gdk_window_clear (window);
-        gdk_window_invalidate_rect (window, NULL, TRUE);
-      }
+      gdk_directfb_event_fill (event, window, GDK_CONFIGURE);
+      event->configure.window = window;
+      event->configure.width  = dfbevent->w;
+      event->configure.height = dfbevent->h;
+
+      D_DEBUG_AT (GDKDFB_WindowEvents,
+                  "  -> configure window %p at %ix%i-%ix%i\n",
+                  window, event->configure.x, event->configure.y,
+                  event->configure.width, event->configure.height);
       break;
 
     case DWET_KEYDOWN:
     case DWET_KEYUP:
-      {
-
-        GdkEventType type = (dfbevent->type == DWET_KEYUP ?
-                             GDK_KEY_RELEASE : GDK_KEY_PRESS);
-        GdkWindow *event_win =
-          gdk_directfb_keyboard_event_window (gdk_directfb_window_find_focus (),
-                                              type);
-        if (event_win)
-          {
-            event = gdk_directfb_event_make (event_win, type);
-            gdk_directfb_translate_key_event (dfbevent, &event->key);
-          }
-      }
+      gdk_directfb_event_fill (event, window,
+                               dfbevent->type == DWET_KEYUP ?
+                               GDK_KEY_RELEASE : GDK_KEY_PRESS);
+      event->key.window = window;
+      gdk_directfb_translate_key_event (dfbevent, (GdkEventKey *) event);
+
+      D_DEBUG_AT (GDKDFB_KeyEvents, "  -> key window=%p val=%x code=%x str=%s\n",
+                  window,  event->key.keyval, event->key.hardware_keycode,
+                  event->key.string);
       break;
 
+    case DWET_ENTER:
     case DWET_LEAVE:
+      /* Backend store */
       _gdk_directfb_mouse_x = dfbevent->cx;
       _gdk_directfb_mouse_y = dfbevent->cy;
 
-      gdk_directfb_window_send_crossing_events (NULL, _gdk_parent_root,
-                                                GDK_CROSSING_NORMAL);
-
+      /* Event translation */
+      gdk_directfb_event_fill (event, window,
+                               dfbevent->type == DWET_ENTER ?
+                               GDK_ENTER_NOTIFY : GDK_LEAVE_NOTIFY);
+      event->crossing.window    = g_object_ref (window);
+      event->crossing.subwindow = NULL;
+      event->crossing.time      = GDK_CURRENT_TIME;
+      event->crossing.x         = dfbevent->x;
+      event->crossing.y         = dfbevent->y;
+      event->crossing.x_root    = dfbevent->cx;
+      event->crossing.y_root    = dfbevent->cy;
+      event->crossing.mode      = GDK_CROSSING_NORMAL;
+      event->crossing.detail    = GDK_NOTIFY_ANCESTOR;
+      event->crossing.state     = 0;
+
+      /**/
       if (gdk_directfb_apply_focus_opacity)
         {
-          if (GDK_WINDOW_IS_MAPPED (window))
-            GDK_WINDOW_IMPL_DIRECTFB (private->impl)->window->SetOpacity
-              (GDK_WINDOW_IMPL_DIRECTFB (private->impl)->window,
-               (GDK_WINDOW_IMPL_DIRECTFB (private->impl)->opacity >> 1) +
-               (GDK_WINDOW_IMPL_DIRECTFB (private->impl)->opacity >> 2));
+          if (dfbevent->type == DWET_ENTER)
+            {
+              if (GDK_WINDOW_IS_MAPPED (window))
+                GDK_WINDOW_IMPL_DIRECTFB (private->impl)->window->SetOpacity
+                  (GDK_WINDOW_IMPL_DIRECTFB (private->impl)->window,
+                   (GDK_WINDOW_IMPL_DIRECTFB (private->impl)->opacity >> 1) +
+                   (GDK_WINDOW_IMPL_DIRECTFB (private->impl)->opacity >> 2));
+            }
+          else
+            {
+              GDK_WINDOW_IMPL_DIRECTFB (private->impl)->window->SetOpacity
+                (GDK_WINDOW_IMPL_DIRECTFB (private->impl)->window,
+                 GDK_WINDOW_IMPL_DIRECTFB (private->impl)->opacity);
+            }
         }
-      break;
 
-    case DWET_ENTER:
-      {
-        GdkWindow *child;
-
-        _gdk_directfb_mouse_x = dfbevent->cx;
-        _gdk_directfb_mouse_y = dfbevent->cy;
-
-        child = gdk_directfb_child_at (window, &dfbevent->x, &dfbevent->y);
-
-        /* this makes sure pointer is set correctly when it previously left
-         * a window being not standard shaped
-         */
-        gdk_window_set_cursor (window, NULL);
-        gdk_directfb_window_send_crossing_events (NULL, child,
-                                                  GDK_CROSSING_NORMAL);
-
-        if (gdk_directfb_apply_focus_opacity)
-          {
-            GDK_WINDOW_IMPL_DIRECTFB (private->impl)->window->SetOpacity
-              (GDK_WINDOW_IMPL_DIRECTFB (private->impl)->window,
-               GDK_WINDOW_IMPL_DIRECTFB (private->impl)->opacity);
-          }
-      }
+      D_DEBUG_AT (GDKDFB_WindowEvents, "  -> %s window %p at relative=%ix%i absolute=%ix%i\n",
+                  dfbevent->type == DWET_ENTER ? "enter" : "leave",
+                  window, (gint) event->crossing.x, (gint) event->crossing.y,
+                  (gint) event->crossing.x_root, (gint) event->crossing.y_root);
       break;
 
     case DWET_CLOSE:
-      {
-
-        GdkWindow *event_win;
-
-        event_win = gdk_directfb_other_event_window (window, GDK_DELETE);
-
-        if (event_win)
-          event = gdk_directfb_event_make (event_win, GDK_DELETE);
-      }
+      gdk_directfb_event_fill (event, window, GDK_DELETE);
       break;
 
     case DWET_DESTROYED:
-      {
-        GdkWindow *event_win;
-
-        event_win = gdk_directfb_other_event_window (window, GDK_DESTROY);
-
-        if (event_win)
-          event = gdk_directfb_event_make (event_win, GDK_DESTROY);
-
-	gdk_window_destroy_notify (window);
-      }
+      gdk_directfb_event_fill (event, window, GDK_DESTROY);
+      gdk_window_destroy_notify (window);
       break;
 
     case DWET_WHEEL:
-      {
-        GdkWindow *event_win;
-
-        _gdk_directfb_mouse_x = dfbevent->cx;
-        _gdk_directfb_mouse_y = dfbevent->cy;
-
-        if (_gdk_directfb_pointer_grab_window)
-          {
-            GdkDrawableImplDirectFB *impl;
-
-            event_win = _gdk_directfb_pointer_grab_window;
-            impl =
-              GDK_DRAWABLE_IMPL_DIRECTFB (GDK_WINDOW_OBJECT (event_win)->impl);
-
-            dfbevent->x = dfbevent->cx - impl->abs_x;
-            dfbevent->y = dfbevent->cy - impl->abs_y;
-          }
-        else
-          {
-            event_win = gdk_directfb_child_at (window,
-                                               &dfbevent->x, &dfbevent->y);
-          }
-
-        if (event_win)
-          {
-            event = gdk_directfb_event_make (event_win, GDK_SCROLL);
-
-            event->scroll.direction = (dfbevent->step < 0 ?
-                                       GDK_SCROLL_DOWN : GDK_SCROLL_UP);
+      /* Backend store */
+      _gdk_directfb_mouse_x = dfbevent->cx;
+      _gdk_directfb_mouse_y = dfbevent->cy;
 
-            event->scroll.x_root = _gdk_directfb_mouse_x;
-            event->scroll.y_root = _gdk_directfb_mouse_y;
-            event->scroll.x      = dfbevent->x;
-            event->scroll.y      = dfbevent->y;
-            event->scroll.state  = _gdk_directfb_modifiers;
-            event->scroll.device = display->core_pointer;
-          }
-      }
+      /* Event translation */
+      gdk_directfb_event_fill (event, window, GDK_SCROLL);
+      event->scroll.direction = (dfbevent->step > 0 ?
+                                 GDK_SCROLL_UP : GDK_SCROLL_DOWN);
+      event->scroll.x_root    = dfbevent->cx;
+      event->scroll.y_root    = dfbevent->cy;
+      event->scroll.x         = dfbevent->x;
+      event->scroll.y         = dfbevent->y;
+      event->scroll.state     = _gdk_directfb_modifiers;
+      event->scroll.device    = display->core_pointer;
+
+      D_DEBUG_AT (GDKDFB_MouseEvents, "  -> mouse scroll %s at %ix%i\n",
+                  event->scroll.direction == GDK_SCROLL_UP ? "up" : "down",
+                  (gint) event->scroll.x, (gint) event->scroll.y);
       break;
 
     default:
       g_message ("unhandled DirectFB windowing event 0x%08x", dfbevent->type);
     }
 
+ done:
+
   g_object_unref (G_OBJECT (window));
 
-  return event;
+  return return_val;
 }
 
 gboolean



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]