Merge branch 'backport' into work
authorMikael Magnusson <mikachu@comhem.se>
Wed, 27 Feb 2008 03:50:41 +0000 (04:50 +0100)
committerDana Jansens <danakj@orodu.net>
Wed, 27 Feb 2008 07:34:08 +0000 (02:34 -0500)
Conflicts:

openbox/client.c
openbox/event.c
openbox/event.h

1  2 
openbox/client.c
openbox/event.c
openbox/event.h
openbox/focus.c

@@@ -458,9 -539,9 +458,9 @@@ void client_manage(Window window, ObPro
                  activate = FALSE;
                  ob_debug_type(OB_DEBUG_FOCUS,
                                "Not focusing the window because the user is "
 -                              "working in another window\n");
 +                              "working in another window");
              }
-             /* If its a transient (and its parents aren't focused) */
+             /* If it's a transient (and its parents aren't focused) */
              else if (client_has_parent(self)) {
                  activate = FALSE;
                  ob_debug_type(OB_DEBUG_FOCUS,
          if (!activate) {
              ob_debug_type(OB_DEBUG_FOCUS,
                            "Focus stealing prevention activated for %s at "
-                           "time %u (last user interactioon time %u)",
 -                          "time %u (last user interaction time %u)\n",
++                          "time %u (last user interaction time %u)",
                            self->title, map_time, event_last_user_time);
              /* if the client isn't focused, then hilite it so the user
                 knows it is there */
@@@ -1214,18 -1296,18 +1214,18 @@@ static void client_get_state(ObClient *
  static void client_get_shaped(ObClient *self)
  {
      self->shaped = FALSE;
- #ifdef   SHAPE
+ #ifdef SHAPE
 -    if (extensions_shape) {
 +    if (obt_display_extension_shape) {
          gint foo;
          guint ufoo;
          gint s;
  
 -        XShapeSelectInput(ob_display, self->window, ShapeNotifyMask);
 +        XShapeSelectInput(obt_display, self->window, ShapeNotifyMask);
  
 -        XShapeQueryExtents(ob_display, self->window, &s, &foo,
 +        XShapeQueryExtents(obt_display, self->window, &s, &foo,
                             &foo, &ufoo, &ufoo, &foo, &foo, &foo, &ufoo,
                             &ufoo);
-         self->shaped = (s != 0);
+         self->shaped = !!s;
      }
  #endif
  }
@@@ -1236,15 -1318,15 +1236,15 @@@ void client_update_transient_for(ObClie
      ObClient *target = NULL;
      gboolean trangroup = FALSE;
  
 -    if (XGetTransientForHint(ob_display, self->window, &t)) {
 +    if (XGetTransientForHint(obt_display, self->window, &t)) {
-         if (t != self->window) { /* cant be transient to itself! */
+         if (t != self->window) { /* can't be transient to itself! */
 -            target = g_hash_table_lookup(window_map, &t);
 +            ObWindow *tw = window_find(t);
-             /* if this happens then we need to check for it*/
+             /* if this happens then we need to check for it */
 -            g_assert(target != self);
 -            if (target && !WINDOW_IS_CLIENT(target)) {
 +            g_assert(tw != CLIENT_AS_WINDOW(self));
 +            if (tw && WINDOW_IS_CLIENT(tw)) {
                  /* watch out for windows with a parent that is something
                     different, like a dockapp for example */
 -                target = NULL;
 +                target = WINDOW_AS_CLIENT(tw);
              }
          }
  
@@@ -1810,10 -1890,10 +1810,10 @@@ void client_update_wmhints(ObClient *se
  {
      XWMHints *hints;
  
-     /* assume a window takes input if it doesnt specify */
+     /* assume a window takes input if it doesn't specify */
      self->can_focus = TRUE;
  
 -    if ((hints = XGetWMHints(ob_display, self->window)) != NULL) {
 +    if ((hints = XGetWMHints(obt_display, self->window)) != NULL) {
          gboolean ur;
  
          if (hints->flags & InputHint)
@@@ -3119,9 -3191,8 +3113,8 @@@ static void client_iconify_recursive(Ob
      GSList *it;
      gboolean changed = FALSE;
  
      if (self->iconic != iconic) {
 -        ob_debug("%sconifying window: 0x%lx\n", (iconic ? "I" : "Uni"),
 +        ob_debug("%sconifying window: 0x%lx", (iconic ? "I" : "Uni"),
                   self->window);
  
          if (iconic) {
@@@ -3735,16 -3813,10 +3736,9 @@@ gboolean client_focus(ObClient *self
         go moving on us */
      event_halt_focus_delay();
  
-     /* if there is a grab going on, then we need to cancel it. if we move
-        focus during the grab, applications will get NotifyWhileGrabbed events
-        and ignore them !
-        actions should not rely on being able to move focus during an
-        interactive grab.
-     */
      event_cancel_all_key_grabs();
  
 -    xerror_set_ignore(TRUE);
 -    xerror_occured = FALSE;
 +    obt_display_ignore_errors(TRUE);
  
      if (self->can_focus) {
          /* This can cause a BadMatch error with CurrentTime, or if an app
diff --cc openbox/event.c
@@@ -841,6 -836,57 +841,57 @@@ void event_enter_client(ObClient *clien
      }
  }
  
 -    while (XCheckTypedWindowEvent(ob_display, window, e->type, ce)) {
+ static gboolean *context_to_button(ObFrame *f, ObFrameContext con, gboolean press)
+ {
+     if (press) {
+         switch (con) {
+         case OB_FRAME_CONTEXT_MAXIMIZE:
+             return &f->max_press;
+         case OB_FRAME_CONTEXT_CLOSE:
+             return &f->close_press;
+         case OB_FRAME_CONTEXT_ICONIFY:
+             return &f->iconify_press;
+         case OB_FRAME_CONTEXT_ALLDESKTOPS:
+             return &f->desk_press;
+         case OB_FRAME_CONTEXT_SHADE:
+             return &f->shade_press;
+         default:
+             return NULL;
+         }
+     } else {
+         switch (con) {
+         case OB_FRAME_CONTEXT_MAXIMIZE:
+             return &f->max_hover;
+         case OB_FRAME_CONTEXT_CLOSE:
+             return &f->close_hover;
+         case OB_FRAME_CONTEXT_ICONIFY:
+             return &f->iconify_hover;
+         case OB_FRAME_CONTEXT_ALLDESKTOPS:
+             return &f->desk_hover;
+         case OB_FRAME_CONTEXT_SHADE:
+             return &f->shade_hover;
+         default:
+             return NULL;
+         }
+     }
+ }
+ static void compress_client_message_event(XEvent *e, XEvent *ce, Window window,
+                                           Atom msgtype)
+ {
+     /* compress changes into a single change */
 -            XPutBackEvent(ob_display, ce);
++    while (XCheckTypedWindowEvent(obt_display, window, e->type, ce)) {
+         /* XXX: it would be nice to compress ALL messages of a
+            type, not just messages in a row without other
+            message types between. */
+         if (ce->xclient.message_type != msgtype) {
++            XPutBackEvent(obt_display, ce);
+             break;
+         }
+         e->xclient = ce->xclient;
+     }
+ }
  static void event_handle_client(ObClient *client, XEvent *e)
  {
      XEvent ce;
          RECT_TO_DIMS(client->area, x, y, w, h);
  
          ob_debug("ConfigureRequest for \"%s\" desktop %d wmstate %d "
-                  "visibile %d",
 -                 "visible %d\n"
 -                 "                     x %d y %d w %d h %d b %d\n",
++                 "visible %d",
                   client->title,
 -                 screen_desktop, client->wmstate, client->frame->visible,
 +                 screen_desktop, client->wmstate, client->frame->visible);
 +        ob_debug("                     x %d y %d w %d h %d b %d",
                   x, y, w, h, client->border_width);
  
          if (e->xconfigurerequest.value_mask & CWBorderWidth)
          if (e->xclient.format != 32) return;
  
          msgtype = e->xclient.message_type;
 -        if (msgtype == prop_atoms.wm_change_state) {
 +        if (msgtype == OBT_PROP_ATOM(WM_CHANGE_STATE)) {
-             /* compress changes into a single change */
-             while (XCheckTypedWindowEvent(obt_display, client->window,
-                                           e->type, &ce)) {
-                 /* XXX: it would be nice to compress ALL messages of a
-                    type, not just messages in a row without other
-                    message types between. */
-                 if (ce.xclient.message_type != msgtype) {
-                     XPutBackEvent(obt_display, &ce);
-                     break;
-                 }
-                 e->xclient = ce.xclient;
-             }
+             compress_client_message_event(e, &ce, client->window, msgtype);
              client_set_wm_state(client, e->xclient.data.l[0]);
 -        } else if (msgtype == prop_atoms.net_wm_desktop) {
 +        } else if (msgtype == OBT_PROP_ATOM(NET_WM_DESKTOP)) {
-             /* compress changes into a single change */
-             while (XCheckTypedWindowEvent(obt_display, client->window,
-                                           e->type, &ce)) {
-                 /* XXX: it would be nice to compress ALL messages of a
-                    type, not just messages in a row without other
-                    message types between. */
-                 if (ce.xclient.message_type != msgtype) {
-                     XPutBackEvent(obt_display, &ce);
-                     break;
-                 }
-                 e->xclient = ce.xclient;
-             }
+             compress_client_message_event(e, &ce, client->window, msgtype);
              if ((unsigned)e->xclient.data.l[0] < screen_num_desktops ||
                  (unsigned)e->xclient.data.l[0] == DESKTOP_ALL)
                  client_set_desktop(client, (unsigned)e->xclient.data.l[0],
              client_update_protocols(client);
              client_setup_decor_and_functions(client, TRUE);
          }
-         else if (msgtype == OBT_PROP_ATOM(NET_WM_STRUT)) {
-             client_update_strut(client);
-         }
-         else if (msgtype == OBT_PROP_ATOM(NET_WM_STRUT_PARTIAL)) {
 -        else if (msgtype == prop_atoms.net_wm_strut ||
 -                 msgtype == prop_atoms.net_wm_strut_partial) {
++        else if (msgtype == OBT_PROP_ATOM(NET_WM_STRUT) ||
++                 msgtype == OBT_PROP_ATOM(NET_WM_STRUT_PARTIAL)) {
              client_update_strut(client);
          }
 -        else if (msgtype == prop_atoms.net_wm_icon) {
 +        else if (msgtype == OBT_PROP_ATOM(NET_WM_ICON)) {
              client_update_icons(client);
          }
 -        else if (msgtype == prop_atoms.net_wm_icon_geometry) {
 +        else if (msgtype == OBT_PROP_ATOM(NET_WM_ICON_GEOMETRY)) {
              client_update_icon_geometry(client);
          }
 -        else if (msgtype == prop_atoms.net_wm_user_time) {
 +        else if (msgtype == OBT_PROP_ATOM(NET_WM_USER_TIME)) {
              guint32 t;
              if (client == focus_client &&
 -                PROP_GET32(client->window, net_wm_user_time, cardinal, &t) &&
 -                t && !event_time_after(t, e->xproperty.time) &&
 +                OBT_PROP_GET32(client->window, NET_WM_USER_TIME, CARDINAL, &t)
 +                && t && !event_time_after(t, e->xproperty.time) &&
                  (!event_last_user_time ||
                   event_time_after(t, event_last_user_time)))
              {
@@@ -1674,13 -1605,11 +1610,11 @@@ static void event_handle_dockapp(ObDock
              app->ignore_unmaps--;
              break;
          }
 -        dock_remove(app, TRUE);
 +        dock_unmanage(app, TRUE);
          break;
      case DestroyNotify:
-         dock_unmanage(app, FALSE);
-         break;
      case ReparentNotify:
 -        dock_remove(app, FALSE);
 +        dock_unmanage(app, FALSE);
          break;
      case ConfigureNotify:
          dock_app_configure(app, e->xconfigure.width, e->xconfigure.height);
diff --cc openbox/event.h
@@@ -41,21 -46,27 +41,27 @@@ void event_shutdown(gboolean reconfig)
  void event_enter_client(struct _ObClient *client);
  
  /*! Make mouse focus not move at all from the stuff that happens between these
-  two function calls. */
+     two function calls. */
 -gulong event_start_ignore_all_enters();
 +gulong event_start_ignore_all_enters(void);
  void event_end_ignore_all_enters(gulong start);
  
- /*! End *all* active and passive grabs on the keyboard */
+ /*! End *all* active and passive grabs on the keyboard
+     This is called in situations where if there is a grab going on, then
+     we need to cancel it. If we move focus during the grab, applications
+     will get NotifyWhileGrabbed events and ignore them!
+     Actions should not rely on being able to move focus during an
+     interactive grab. */
 -void event_cancel_all_key_grabs();
 +void event_cancel_all_key_grabs(void);
  
  /* Halts any focus delay in progress, use this when the user is selecting a
     window for focus */
 -void event_halt_focus_delay();
 +void event_halt_focus_delay(void);
  
  /*! Compare t1 and t2, taking into account wraparound. True if t1
-   comes at the same time or later than t2. */
+     comes at the same time or later than t2. */
  gboolean event_time_after(Time t1, Time t2);
  
 -Time event_get_server_time();
 +Time event_get_server_time(void);
  
  #endif
diff --cc openbox/focus.c
Simple merge