]> Dogcows Code - chaz/openbox/blobdiff - openbox/event.c
add the --replace command line option, and support for the WM_Sn selection
[chaz/openbox] / openbox / event.c
index cdac868332602645faa20592fea84995a0ff68e5..018218fcef61dbf08951187127add37559385b27 100644 (file)
@@ -186,6 +186,9 @@ static Window event_get_window(XEvent *e)
 
     /* pick a window */
     switch (e->type) {
+    case SelectionClear:
+        window = RootWindow(ob_display, ob_screen);
+        break;
     case MapRequest:
        window = e->xmap.window;
        break;
@@ -548,6 +551,11 @@ static void event_handle_root(XEvent *e)
     Atom msgtype;
      
     switch(e->type) {
+    case SelectionClear:
+        g_message("Another WM has requested to replace us. Exiting.");
+        ob_exit();
+        break;
+
     case ClientMessage:
        if (e->xclient.format != 32) break;
 
@@ -966,27 +974,37 @@ static void event_handle_menu(ObClient *client, XEvent *e)
     static ObMenuEntry *over = NULL;
     ObMenuEntry *entry;
     ObMenu *top;
-    GSList *it;
+    GList *it = NULL;
 
-    top = g_slist_nth_data(menu_visible, 0);
+    top = g_list_nth_data(menu_visible, 0);
 
     g_message("EVENT %d", e->type);
     switch (e->type) {
     case KeyPress:
-        if (over) {
-            if (over->parent->mouseover)
-                over->parent->mouseover(over, FALSE);
-            else
-                menu_control_mouseover(over, FALSE);
-            menu_entry_render(over);
-            over = NULL;
-        }
+        if (e->xkey.keycode == ob_keycode(OB_KEY_DOWN))
+            over = menu_control_keyboard_nav(over, OB_KEY_DOWN);
+        else if (e->xkey.keycode == ob_keycode(OB_KEY_UP))
+            over = menu_control_keyboard_nav(over, OB_KEY_UP);
+        else if (e->xkey.keycode == ob_keycode(OB_KEY_RETURN))
+            over = menu_control_keyboard_nav(over, OB_KEY_RETURN);
+        else if (e->xkey.keycode == ob_keycode(OB_KEY_ESCAPE))
+            over = menu_control_keyboard_nav(over, OB_KEY_ESCAPE);
+        else {
+            if (over) {
+                if (over->parent->mouseover)
+                    over->parent->mouseover(over, FALSE);
+                else
+                    menu_control_mouseover(over, FALSE);
+                menu_entry_render(over);
+                over = NULL;
+            }
 /*
-        if (top->hide)
-            top->hide(top);
-        else
+  if (top->hide)
+  top->hide(top);
+  else
 */
             menu_hide(top);
+        }
         break;
     case ButtonPress:
         if (e->xbutton.button > 3) break;
@@ -998,7 +1016,7 @@ static void event_handle_menu(ObClient *client, XEvent *e)
 
        g_message("BUTTON RELEASED");
 
-        for (it = menu_visible; it; it = g_slist_next(it)) {
+        for (it = menu_visible; it; it = g_list_next(it)) {
             ObMenu *m = it->data;
             if (e->xbutton.x_root >= m->location.x - ob_rr_theme->bwidth &&
                 e->xbutton.y_root >= m->location.y - ob_rr_theme->bwidth &&
@@ -1045,7 +1063,7 @@ static void event_handle_menu(ObClient *client, XEvent *e)
         break;
     case MotionNotify:
         g_message("motion");
-        for (it = menu_visible; it; it = g_slist_next(it)) {
+        for (it = menu_visible; it; it = g_list_next(it)) {
             ObMenu *m = it->data;
             if ((entry = menu_find_entry_by_pos(it->data,
                                                 e->xmotion.x_root -
This page took 0.026423 seconds and 4 git commands to generate.