]> Dogcows Code - chaz/openbox/blobdiff - openbox/event.c
hover theme elements for window titlebar buttons
[chaz/openbox] / openbox / event.c
index 69c85100c9c89909ddf26a45376e5a660a6576b8..e1ab8fef63f75fca06b565ae4c092952e687809c 100644 (file)
@@ -600,6 +600,7 @@ static void event_handle_client(ObClient *client, XEvent *e)
     XEvent ce;
     Atom msgtype;
     int i=0;
+    ObFrameContext con;
      
     switch (e->type) {
     case ButtonPress:
@@ -657,23 +658,77 @@ static void event_handle_client(ObClient *client, XEvent *e)
             client_iconify(client, TRUE, TRUE);
         frame_adjust_focus(client->frame, FALSE);
        break;
+    case LeaveNotify:
+        con = frame_context(client, e->xcrossing.window);
+        switch (con) {
+        case OB_FRAME_CONTEXT_MAXIMIZE:
+            client->frame->max_hover = FALSE;
+            frame_adjust_state(client->frame);
+            break;
+        case OB_FRAME_CONTEXT_ALLDESKTOPS:
+            client->frame->desk_hover = FALSE;
+            frame_adjust_state(client->frame);
+            break;
+        case OB_FRAME_CONTEXT_SHADE:
+            client->frame->shade_hover = FALSE;
+            frame_adjust_state(client->frame);
+            break;
+        case OB_FRAME_CONTEXT_ICONIFY:
+            client->frame->iconify_hover = FALSE;
+            frame_adjust_state(client->frame);
+            break;
+        case OB_FRAME_CONTEXT_CLOSE:
+            client->frame->close_hover = FALSE;
+            frame_adjust_state(client->frame);
+            break;
+        default:
+            break;
+        }
+        break;
     case EnterNotify:
-        if (client_normal(client)) {
-            if (ob_state() == OB_STATE_STARTING) {
-                /* move it to the top of the focus order */
-                guint desktop = client->desktop;
-                if (desktop == DESKTOP_ALL) desktop = screen_desktop;
-                focus_order[desktop] = g_list_remove(focus_order[desktop],
-                                                     client);
-                focus_order[desktop] = g_list_prepend(focus_order[desktop],
-                                                      client);
-            } else if (config_focus_follow) {
+        con = frame_context(client, e->xcrossing.window);
+        switch (con) {
+        case OB_FRAME_CONTEXT_MAXIMIZE:
+            client->frame->max_hover = TRUE;
+            frame_adjust_state(client->frame);
+            break;
+        case OB_FRAME_CONTEXT_ALLDESKTOPS:
+            client->frame->desk_hover = TRUE;
+            frame_adjust_state(client->frame);
+            break;
+        case OB_FRAME_CONTEXT_SHADE:
+            client->frame->shade_hover = TRUE;
+            frame_adjust_state(client->frame);
+            break;
+        case OB_FRAME_CONTEXT_ICONIFY:
+            client->frame->iconify_hover = TRUE;
+            frame_adjust_state(client->frame);
+            break;
+        case OB_FRAME_CONTEXT_CLOSE:
+            client->frame->close_hover = TRUE;
+            frame_adjust_state(client->frame);
+            break;
+        case OB_FRAME_CONTEXT_FRAME:
+            if (client_normal(client)) {
+                if (ob_state() == OB_STATE_STARTING) {
+                    /* move it to the top of the focus order */
+                    guint desktop = client->desktop;
+                    if (desktop == DESKTOP_ALL) desktop = screen_desktop;
+                    focus_order[desktop] = g_list_remove(focus_order[desktop],
+                                                         client);
+                    focus_order[desktop] = g_list_prepend(focus_order[desktop],
+                                                          client);
+                } else if (config_focus_follow) {
 #ifdef DEBUG_FOCUS
-                ob_debug("EnterNotify on %lx, focusing window\n",
-                         client->window);
+                    ob_debug("EnterNotify on %lx, focusing window\n",
+                             client->window);
 #endif
-                client_focus(client);
+                    client_focus(client);
+                }
             }
+            break;
+        default:
+            break;
         }
         break;
     case ConfigureRequest:
@@ -711,7 +766,7 @@ static void event_handle_client(ObClient *client, XEvent *e)
                                               CWX | CWY)) {
            int x, y, w, h;
            ObCorner corner;
-              
+
            x = (e->xconfigurerequest.value_mask & CWX) ?
                e->xconfigurerequest.x : client->area.x;
            y = (e->xconfigurerequest.value_mask & CWY) ?
@@ -720,6 +775,16 @@ static void event_handle_client(ObClient *client, XEvent *e)
                e->xconfigurerequest.width : client->area.width;
            h = (e->xconfigurerequest.value_mask & CWHeight) ?
                e->xconfigurerequest.height : client->area.height;
+
+            {
+                int newx = x;
+                int newy = y;
+                client_find_onscreen(client, &newx, &newy, w, h, TRUE);
+                if (e->xconfigurerequest.value_mask & CWX)
+                    x = newx;
+                if (e->xconfigurerequest.value_mask & CWY)
+                    y = newy;
+            }
               
            switch (client->gravity) {
            case NorthEastGravity:
@@ -908,8 +973,20 @@ static void event_handle_client(ObClient *client, XEvent *e)
             else
                 h = client->area.y;
             client->gravity = tmpg;
+
+            {
+                int newx = x;
+                int newy = y;
+                client_find_onscreen(client, &newx, &newy, w, h, TRUE);
+                if (e->xclient.data.l[0] & 1 << 8)
+                    x = newx;
+                if (e->xclient.data.l[0] & 1 << 9)
+                    y = newy;
+            }
+              
             client_configure(client, OB_CORNER_TOPLEFT,
                              x, y, w, h, FALSE, TRUE);
+
             client->gravity = oldg;
         }
        break;
@@ -1008,6 +1085,7 @@ static void event_handle_menu(ObClient *client, XEvent *e)
                                 e->xbutton.y_root);
                     break;
                 }
+                break;
             }
         }
 
This page took 0.026664 seconds and 4 git commands to generate.