From b0939f71a27a8533b1086864641a0fd6c781f2c2 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sat, 19 May 2007 23:02:32 +0000 Subject: [PATCH] merge r6636-6644 from trunk --- data/rc.xml | 22 ++++++++++++- data/rc.xsd | 1 + doc/rc-mouse-focus.xml | 24 +++++++++++++++ openbox/event.c | 10 ++++-- openbox/frame.c | 70 ++++++++++++++++++++++++++++++++++++------ openbox/frame.h | 5 +++ openbox/framerender.c | 3 +- openbox/keyboard.c | 12 ++++++-- openbox/menuframe.c | 3 +- openbox/menuframe.h | 1 - openbox/misc.h | 1 + openbox/mouse.c | 24 +++++++++++---- openbox/mouse.h | 2 +- openbox/openbox.c | 3 +- openbox/screen.c | 2 +- 15 files changed, 155 insertions(+), 28 deletions(-) diff --git a/data/rc.xml b/data/rc.xml index efe93376..94cc7edf 100644 --- a/data/rc.xml +++ b/data/rc.xml @@ -290,7 +290,25 @@ - + + + + + + left + + + + + + + + + right + + + + @@ -444,7 +462,9 @@ + + client-list-combined-menu diff --git a/data/rc.xsd b/data/rc.xsd index d883e8bf..6244bd8b 100644 --- a/data/rc.xsd +++ b/data/rc.xsd @@ -333,6 +333,7 @@ + diff --git a/doc/rc-mouse-focus.xml b/doc/rc-mouse-focus.xml index ce8ca2a0..c1351cac 100644 --- a/doc/rc-mouse-focus.xml +++ b/doc/rc-mouse-focus.xml @@ -296,6 +296,30 @@ + + + + + + + + + top + + + + + + + + + + + + top + + + diff --git a/openbox/event.c b/openbox/event.c index 8f211202..bf2fd932 100644 --- a/openbox/event.c +++ b/openbox/event.c @@ -772,7 +772,8 @@ static void event_handle_client(ObClient *client, XEvent *e) { /* use where the press occured */ con = frame_context(client, e->xbutton.window, px, py); - con = mouse_button_frame_context(con, e->xbutton.button); + con = mouse_button_frame_context(con, e->xbutton.button, + e->xbutton.state); if (e->type == ButtonRelease && e->xbutton.button == pb) pb = 0, px = py = -1; @@ -1482,8 +1483,11 @@ static gboolean event_handle_menu_keyboard(XEvent *ev) ret = FALSE; else if (keycode == ob_keycode(OB_KEY_ESCAPE) && state == 0) { - /* Escape closes the active menu */ - menu_frame_hide(frame); + /* Escape goes to the parent menu or closes the last one */ + if (frame->parent) + menu_frame_select(frame, NULL, TRUE); + else + menu_frame_hide_all(); } else if (keycode == ob_keycode(OB_KEY_RETURN) && (state == 0 || diff --git a/openbox/frame.c b/openbox/frame.c index a0784d23..e042c4fc 100644 --- a/openbox/frame.c +++ b/openbox/frame.c @@ -138,6 +138,11 @@ ObFrame *frame_new(ObClient *client) self->trtresize = createWindow(self->title, NULL, mask, &attrib); self->trrresize = createWindow(self->title, NULL, mask, &attrib); + attrib.cursor = ob_cursor(OB_CURSOR_WEST); + self->leftresize = createWindow(self->inner, NULL, mask, &attrib); + attrib.cursor = ob_cursor(OB_CURSOR_EAST); + self->rightresize = createWindow(self->inner, NULL, mask, &attrib); + mask &= ~CWCursor; self->label = createWindow(self->title, NULL, mask, &attrib); self->max = createWindow(self->title, NULL, mask, &attrib); @@ -176,6 +181,14 @@ ObFrame *frame_new(ObClient *client) static void set_theme_statics(ObFrame *self) { + gint handle_height; + + if (ob_rr_theme->handle_height > 0) + handle_height = ob_rr_theme->handle_height; + else + handle_height = 1; + + /* set colors/appearance/sizes for stuff that doesn't change */ XResizeWindow(ob_display, self->max, ob_rr_theme->button_size, ob_rr_theme->button_size); @@ -189,12 +202,10 @@ static void set_theme_statics(ObFrame *self) ob_rr_theme->button_size, ob_rr_theme->button_size); XResizeWindow(ob_display, self->shade, ob_rr_theme->button_size, ob_rr_theme->button_size); - if (ob_rr_theme->handle_height > 0) { - XResizeWindow(ob_display, self->lgrip, - ob_rr_theme->grip_width, ob_rr_theme->handle_height); - XResizeWindow(ob_display, self->rgrip, - ob_rr_theme->grip_width, ob_rr_theme->handle_height); - } + XResizeWindow(ob_display, self->lgrip, + ob_rr_theme->grip_width, handle_height); + XResizeWindow(ob_display, self->rgrip, + ob_rr_theme->grip_width, handle_height); XResizeWindow(ob_display, self->tltresize, ob_rr_theme->grip_width, ob_rr_theme->paddingy + 1); XResizeWindow(ob_display, self->trtresize, @@ -351,6 +362,8 @@ void frame_adjust_area(ObFrame *self, gboolean moved, XSetWindowBorderWidth(ob_display, self->handle, self->rbwidth); XSetWindowBorderWidth(ob_display, self->lgrip, self->rbwidth); XSetWindowBorderWidth(ob_display, self->rgrip, self->rbwidth); + XSetWindowBorderWidth(ob_display, self->leftresize, self->bwidth); + XSetWindowBorderWidth(ob_display, self->rightresize, self->bwidth); } if (self->decorations & OB_FRAME_DECOR_TITLEBAR) @@ -385,17 +398,35 @@ void frame_adjust_area(ObFrame *self, gboolean moved, XMoveWindow(ob_display, self->trrresize, self->width - ob_rr_theme->paddingx - 1, 0); + XMoveResizeWindow(ob_display, self->leftresize, + -(ob_rr_theme->fbwidth * 2) - 1, + 0, + 1, + self->client->area.height + + self->cbwidth_y * 2); + XMoveResizeWindow(ob_display, self->rightresize, + self->client->area.width + + self->cbwidth_x * 2, + 0, + 1, + self->client->area.height + + self->cbwidth_y * 2); + XMapWindow(ob_display, self->topresize); XMapWindow(ob_display, self->tltresize); XMapWindow(ob_display, self->tllresize); XMapWindow(ob_display, self->trtresize); XMapWindow(ob_display, self->trrresize); + XMapWindow(ob_display, self->leftresize); + XMapWindow(ob_display, self->rightresize); } else { XUnmapWindow(ob_display, self->topresize); XUnmapWindow(ob_display, self->tltresize); XUnmapWindow(ob_display, self->tllresize); XUnmapWindow(ob_display, self->trtresize); XUnmapWindow(ob_display, self->trrresize); + XUnmapWindow(ob_display, self->leftresize); + XUnmapWindow(ob_display, self->rightresize); } } else XUnmapWindow(ob_display, self->title); @@ -406,12 +437,18 @@ void frame_adjust_area(ObFrame *self, gboolean moved, layout_title(self); if (!fake) { - if (self->decorations & OB_FRAME_DECOR_HANDLE && - ob_rr_theme->handle_height > 0) + if (self->decorations & OB_FRAME_DECOR_HANDLE) { + gint handle_height; + + if (ob_rr_theme->handle_height > 0) + handle_height = ob_rr_theme->handle_height; + else + handle_height = 1; + XMoveResizeWindow(ob_display, self->handle, -self->bwidth, FRAME_HANDLE_Y(self), - self->width, ob_rr_theme->handle_height); + self->width, handle_height); XMapWindow(ob_display, self->handle); if (self->decorations & OB_FRAME_DECOR_GRIPS) { @@ -548,6 +585,7 @@ void frame_grab_client(ObFrame *self) { /* reparent the client to the frame */ XReparentWindow(ob_display, self->client->window, self->plate, 0, 0); + /* When reparenting the client window, it is usually not mapped yet, since this occurs from a MapRequest. However, in the case where Openbox is @@ -586,6 +624,8 @@ void frame_grab_client(ObFrame *self) g_hash_table_insert(window_map, &self->tllresize, self->client); g_hash_table_insert(window_map, &self->trtresize, self->client); g_hash_table_insert(window_map, &self->trrresize, self->client); + g_hash_table_insert(window_map, &self->leftresize, self->client); + g_hash_table_insert(window_map, &self->rightresize, self->client); } void frame_release_client(ObFrame *self) @@ -644,6 +684,8 @@ void frame_release_client(ObFrame *self) g_hash_table_remove(window_map, &self->tllresize); g_hash_table_remove(window_map, &self->trtresize); g_hash_table_remove(window_map, &self->trrresize); + g_hash_table_remove(window_map, &self->leftresize); + g_hash_table_remove(window_map, &self->rightresize); ob_main_loop_timeout_remove_data(ob_main_loop, flash_timeout, self, TRUE); } @@ -819,6 +861,8 @@ ObFrameContext frame_context_from_string(const gchar *name) { if (!g_ascii_strcasecmp("Desktop", name)) return OB_FRAME_CONTEXT_DESKTOP; + else if (!g_ascii_strcasecmp("Root", name)) + return OB_FRAME_CONTEXT_ROOT; else if (!g_ascii_strcasecmp("Client", name)) return OB_FRAME_CONTEXT_CLIENT; else if (!g_ascii_strcasecmp("Titlebar", name)) @@ -839,6 +883,10 @@ ObFrameContext frame_context_from_string(const gchar *name) return OB_FRAME_CONTEXT_BOTTOM; else if (!g_ascii_strcasecmp("Bottom", name)) return OB_FRAME_CONTEXT_BOTTOM; + else if (!g_ascii_strcasecmp("Left", name)) + return OB_FRAME_CONTEXT_LEFT; + else if (!g_ascii_strcasecmp("Right", name)) + return OB_FRAME_CONTEXT_RIGHT; else if (!g_ascii_strcasecmp("Maximize", name)) return OB_FRAME_CONTEXT_MAXIMIZE; else if (!g_ascii_strcasecmp("AllDesktops", name)) @@ -864,7 +912,7 @@ ObFrameContext frame_context(ObClient *client, Window win, gint x, gint y) return OB_FRAME_CONTEXT_MOVE_RESIZE; if (win == RootWindow(ob_display, ob_screen)) - return OB_FRAME_CONTEXT_DESKTOP; + return OB_FRAME_CONTEXT_ROOT ; if (client == NULL) return OB_FRAME_CONTEXT_NONE; if (win == client->window) { /* conceptually, this is the desktop, as far as users are @@ -916,6 +964,8 @@ ObFrameContext frame_context(ObClient *client, Window win, gint x, gint y) if (win == self->tllresize) return OB_FRAME_CONTEXT_TLCORNER; if (win == self->trtresize) return OB_FRAME_CONTEXT_TRCORNER; if (win == self->trrresize) return OB_FRAME_CONTEXT_TRCORNER; + if (win == self->leftresize) return OB_FRAME_CONTEXT_LEFT; + if (win == self->rightresize) return OB_FRAME_CONTEXT_RIGHT; if (win == self->max) return OB_FRAME_CONTEXT_MAXIMIZE; if (win == self->iconify) return OB_FRAME_CONTEXT_ICONIFY; if (win == self->close) return OB_FRAME_CONTEXT_CLOSE; diff --git a/openbox/frame.h b/openbox/frame.h index 0f563432..13e49564 100644 --- a/openbox/frame.h +++ b/openbox/frame.h @@ -32,6 +32,7 @@ typedef void (*ObFrameIconifyAnimateFunc)(gpointer data); typedef enum { OB_FRAME_CONTEXT_NONE, OB_FRAME_CONTEXT_DESKTOP, + OB_FRAME_CONTEXT_ROOT, OB_FRAME_CONTEXT_CLIENT, OB_FRAME_CONTEXT_TITLEBAR, OB_FRAME_CONTEXT_FRAME, @@ -41,6 +42,8 @@ typedef enum { OB_FRAME_CONTEXT_TRCORNER, OB_FRAME_CONTEXT_TOP, OB_FRAME_CONTEXT_BOTTOM, + OB_FRAME_CONTEXT_LEFT, + OB_FRAME_CONTEXT_RIGHT, OB_FRAME_CONTEXT_MAXIMIZE, OB_FRAME_CONTEXT_ALLDESKTOPS, OB_FRAME_CONTEXT_SHADE, @@ -101,6 +104,8 @@ struct _ObFrame Window tllresize; Window trtresize; Window trrresize; + Window leftresize; + Window rightresize; Colormap colormap; diff --git a/openbox/framerender.c b/openbox/framerender.c index 82a98a8e..78c1d02f 100644 --- a/openbox/framerender.c +++ b/openbox/framerender.c @@ -47,11 +47,12 @@ void framerender_frame(ObFrame *self) RrColorPixel(ob_rr_theme->frame_focused_border_color) : RrColorPixel(ob_rr_theme->frame_unfocused_border_color)); XSetWindowBorder(ob_display, self->window, px); - XSetWindowBorder(ob_display, self->inner, px); XSetWindowBorder(ob_display, self->title, px); XSetWindowBorder(ob_display, self->handle, px); XSetWindowBorder(ob_display, self->rgrip, px); XSetWindowBorder(ob_display, self->lgrip, px); + XSetWindowBorder(ob_display, self->leftresize, px); + XSetWindowBorder(ob_display, self->rightresize, px); } if (self->decorations & OB_FRAME_DECOR_TITLEBAR) { diff --git a/openbox/keyboard.c b/openbox/keyboard.c index ab9d05b0..432599e8 100644 --- a/openbox/keyboard.c +++ b/openbox/keyboard.c @@ -31,7 +31,6 @@ #include "config.h" #include "keytree.h" #include "keyboard.h" -#include "translate.h" #include "moveresize.h" #include "popup.h" #include "gettext.h" @@ -293,7 +292,16 @@ void keyboard_event(ObClient *client, const XEvent *e) p = curpos->first_child; while (p) { if (p->key == e->xkey.keycode && - p->state == e->xkey.state) + /* tricksy. + if you have Super_L and Super_R bound to different modXmasks, + this makes either mod mask count as Super + + e.g. Super_L is mod1 and Super_R is mod2, so.. + p->state = 00011 + key state is just Super_L so 00001 + 00011 | 00001 == 00011 == p->state + */ + (p->state | e->xkey.state) == p->state) { /* if we hit a key binding, then close any open menus and run it */ if (menu_frame_visible) diff --git a/openbox/menuframe.c b/openbox/menuframe.c index 68ea4949..b908ad4f 100644 --- a/openbox/menuframe.c +++ b/openbox/menuframe.c @@ -45,6 +45,7 @@ static ObMenuEntryFrame* menu_entry_frame_new(ObMenuEntry *entry, static void menu_entry_frame_free(ObMenuEntryFrame *self); static void menu_frame_update(ObMenuFrame *self); static gboolean menu_entry_frame_submenu_timeout(gpointer data); +static void menu_frame_hide(ObMenuFrame *self); static Window createWindow(Window parent, gulong mask, XSetWindowAttributes *attrib) @@ -1013,7 +1014,7 @@ gboolean menu_frame_show_submenu(ObMenuFrame *self, ObMenuFrame *parent, return TRUE; } -void menu_frame_hide(ObMenuFrame *self) +static void menu_frame_hide(ObMenuFrame *self) { GList *it = g_list_find(menu_frame_visible, self); diff --git a/openbox/menuframe.h b/openbox/menuframe.h index 4f896ec8..e1f4b15b 100644 --- a/openbox/menuframe.h +++ b/openbox/menuframe.h @@ -128,7 +128,6 @@ gboolean menu_frame_show_topmenu(ObMenuFrame *self, gint x, gint y, gint button); gboolean menu_frame_show_submenu(ObMenuFrame *self, ObMenuFrame *parent, ObMenuEntryFrame *parent_entry); -void menu_frame_hide(ObMenuFrame *self); void menu_frame_hide_all(); void menu_frame_hide_all_client(struct _ObClient *client); diff --git a/openbox/misc.h b/openbox/misc.h index 1da94b34..f55feed9 100644 --- a/openbox/misc.h +++ b/openbox/misc.h @@ -23,6 +23,7 @@ typedef enum { OB_CURSOR_NONE, OB_CURSOR_POINTER, + OB_CURSOR_BUSYPOINTER, OB_CURSOR_BUSY, OB_CURSOR_MOVE, OB_CURSOR_NORTH, diff --git a/openbox/mouse.c b/openbox/mouse.c index 78e25d89..850fb337 100644 --- a/openbox/mouse.c +++ b/openbox/mouse.c @@ -48,7 +48,8 @@ typedef struct { static GSList *bound_contexts[OB_FRAME_NUM_CONTEXTS]; ObFrameContext mouse_button_frame_context(ObFrameContext context, - guint button) + guint button, + guint state) { GSList *it; ObFrameContext x = context; @@ -56,7 +57,7 @@ ObFrameContext mouse_button_frame_context(ObFrameContext context, for (it = bound_contexts[context]; it; it = g_slist_next(it)) { ObMouseBinding *b = it->data; - if (b->button == button) + if (b->button == button && b->state == state) return context; } @@ -67,6 +68,11 @@ ObFrameContext mouse_button_frame_context(ObFrameContext context, case OB_FRAME_CONTEXT_TITLEBAR: case OB_FRAME_CONTEXT_FRAME: case OB_FRAME_CONTEXT_MOVE_RESIZE: + case OB_FRAME_CONTEXT_LEFT: + case OB_FRAME_CONTEXT_RIGHT: + break; + case OB_FRAME_CONTEXT_ROOT: + x = OB_FRAME_CONTEXT_DESKTOP; break; case OB_FRAME_CONTEXT_BOTTOM: case OB_FRAME_CONTEXT_BLCORNER: @@ -88,7 +94,11 @@ ObFrameContext mouse_button_frame_context(ObFrameContext context, g_assert_not_reached(); } - return x; + /* allow for multiple levels of fall-through */ + if (x != context) + return mouse_button_frame_context(x, button, state); + else + return x; } void mouse_grab_for_client(ObClient *client, gboolean grab) @@ -190,7 +200,8 @@ void mouse_event(ObClient *client, XEvent *e) case ButtonPress: context = frame_context(client, e->xbutton.window, e->xbutton.x, e->xbutton.y); - context = mouse_button_frame_context(context, e->xbutton.button); + context = mouse_button_frame_context(context, e->xbutton.button, + e->xbutton.state); px = e->xbutton.x_root; py = e->xbutton.y_root; @@ -220,7 +231,8 @@ void mouse_event(ObClient *client, XEvent *e) case ButtonRelease: /* use where the press occured in the window */ context = frame_context(client, e->xbutton.window, pwx, pwy); - context = mouse_button_frame_context(context, e->xbutton.button); + context = mouse_button_frame_context(context, e->xbutton.button, + e->xbutton.state); if (e->xbutton.button == button) pwx = pwy = -1; @@ -287,7 +299,7 @@ void mouse_event(ObClient *client, XEvent *e) case MotionNotify: if (button) { context = frame_context(client, e->xmotion.window, pwx, pwy); - context = mouse_button_frame_context(context, button); + context = mouse_button_frame_context(context, button, state); if (ABS(e->xmotion.x_root - px) >= config_mouse_threshold || ABS(e->xmotion.y_root - py) >= config_mouse_threshold) { diff --git a/openbox/mouse.h b/openbox/mouse.h index 38e01da8..befe1296 100644 --- a/openbox/mouse.h +++ b/openbox/mouse.h @@ -37,6 +37,6 @@ void mouse_event(struct _ObClient *client, XEvent *e); void mouse_grab_for_client(struct _ObClient *client, gboolean grab); ObFrameContext mouse_button_frame_context(ObFrameContext context, - guint button); + guint button, guint state); #endif diff --git a/openbox/openbox.c b/openbox/openbox.c index 996cb227..7270379e 100644 --- a/openbox/openbox.c +++ b/openbox/openbox.c @@ -196,7 +196,8 @@ gint main(gint argc, gchar **argv) /* create available cursors */ cursors[OB_CURSOR_NONE] = None; cursors[OB_CURSOR_POINTER] = load_cursor("left_ptr", XC_left_ptr); - cursors[OB_CURSOR_BUSY] = load_cursor("left_ptr_watch", XC_watch); + cursors[OB_CURSOR_BUSYPOINTER] = load_cursor("left_ptr_watch",XC_left_ptr); + cursors[OB_CURSOR_BUSY] = load_cursor("watch", XC_watch); cursors[OB_CURSOR_MOVE] = load_cursor("fleur", XC_fleur); cursors[OB_CURSOR_NORTH] = load_cursor("top_side", XC_top_side); cursors[OB_CURSOR_NORTHEAST] = load_cursor("top_right_corner", diff --git a/openbox/screen.c b/openbox/screen.c index 6551da81..4ad46af7 100644 --- a/openbox/screen.c +++ b/openbox/screen.c @@ -1270,7 +1270,7 @@ void screen_set_root_cursor() { if (sn_app_starting()) XDefineCursor(ob_display, RootWindow(ob_display, ob_screen), - ob_cursor(OB_CURSOR_BUSY)); + ob_cursor(OB_CURSOR_BUSYPOINTER)); else XDefineCursor(ob_display, RootWindow(ob_display, ob_screen), ob_cursor(OB_CURSOR_POINTER)); -- 2.34.1