Client menus
Add "client_menu" to pluginrc to use.
This commit is contained in:
parent
955d9d8e30
commit
71d2605e1c
7 changed files with 120 additions and 34 deletions
1
data/rc3
1
data/rc3
|
@ -188,3 +188,4 @@ mbind Frame Click C-A-Up SendToNextDesktopWrap
|
|||
mbind Frame Click C-A-Down SendToPreviousDesktopWrap
|
||||
|
||||
mbind Root Click Right ShowMenu "root"
|
||||
mbind Frame Click Right ShowMenu "client-menu"
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "openbox.h"
|
||||
#include "group.h"
|
||||
#include "config.h"
|
||||
#include "menu.h"
|
||||
#include "render/render.h"
|
||||
|
||||
#include <glib.h>
|
||||
|
@ -311,6 +312,13 @@ void client_unmanage_all()
|
|||
client_unmanage(client_list->data);
|
||||
}
|
||||
|
||||
/* called by client_unmanage() to close any menus referencing this client */
|
||||
void client_close_menus(gpointer key, gpointer value, gpointer self)
|
||||
{
|
||||
if (((Menu *)value)->client == (Client *)self)
|
||||
menu_hide((Menu *)value);
|
||||
}
|
||||
|
||||
void client_unmanage(Client *self)
|
||||
{
|
||||
int j;
|
||||
|
@ -364,6 +372,10 @@ void client_unmanage(Client *self)
|
|||
if (moveresize_client == self)
|
||||
moveresize_end(TRUE);
|
||||
|
||||
/* close any windows that are attached to this window */
|
||||
g_hash_table_foreach(menu_hash, client_close_menus, self);
|
||||
|
||||
|
||||
if (focus_client == self) {
|
||||
XEvent e;
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ static void event_handle_root(XEvent *e);
|
|||
static void event_handle_dock(Dock *s, XEvent *e);
|
||||
static void event_handle_dockapp(DockApp *app, XEvent *e);
|
||||
static void event_handle_client(Client *c, XEvent *e);
|
||||
static void event_handle_menu(Menu *menu, XEvent *e);
|
||||
static void event_handle_menu(Menu *menu, Client *c, XEvent *e);
|
||||
|
||||
#define INVALID_FOCUSIN(e) ((e)->xfocus.detail == NotifyInferior || \
|
||||
(e)->xfocus.detail > NotifyNonlinearVirtual)
|
||||
|
@ -436,7 +436,7 @@ static void event_process(XEvent *e)
|
|||
|
||||
/* deal with it in the kernel */
|
||||
if (menu) {
|
||||
event_handle_menu(menu, e);
|
||||
event_handle_menu(menu, client, e);
|
||||
return;
|
||||
} else if (client)
|
||||
event_handle_client(client, e);
|
||||
|
@ -909,7 +909,7 @@ static void event_handle_client(Client *client, XEvent *e)
|
|||
}
|
||||
}
|
||||
|
||||
static void event_handle_menu(Menu *menu, XEvent *e)
|
||||
static void event_handle_menu(Menu *menu, Client *client, XEvent *e)
|
||||
{
|
||||
MenuEntry *entry;
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "geom.h"
|
||||
#include "plugin.h"
|
||||
|
||||
static GHashTable *menu_hash = NULL;
|
||||
GHashTable *menu_hash = NULL;
|
||||
|
||||
#define FRAME_EVENTMASK (ButtonPressMask |ButtonMotionMask | EnterWindowMask | \
|
||||
LeaveWindowMask)
|
||||
|
@ -17,9 +17,9 @@ static GHashTable *menu_hash = NULL;
|
|||
|
||||
void menu_control_show(Menu *self, int x, int y, Client *client);
|
||||
|
||||
void menu_destroy_hash_key(gpointer data)
|
||||
void menu_destroy_hash_key(Menu *menu)
|
||||
{
|
||||
g_free(data);
|
||||
g_free(menu);
|
||||
}
|
||||
|
||||
void menu_destroy_hash_value(Menu *self)
|
||||
|
@ -73,7 +73,7 @@ void menu_startup()
|
|||
menu_destroy_hash_key,
|
||||
(GDestroyNotify)menu_destroy_hash_value);
|
||||
|
||||
m = menu_new(NULL, "root", NULL);
|
||||
m = menu_new("sex menu", "root", NULL);
|
||||
|
||||
a = action_from_string("execute");
|
||||
a->data.execute.path = g_strdup("xterm");
|
||||
|
@ -83,6 +83,8 @@ void menu_startup()
|
|||
menu_add_entry(m, menu_entry_new_separator("--"));
|
||||
a = action_from_string("exit");
|
||||
menu_add_entry(m, menu_entry_new("exit", a));
|
||||
|
||||
/*
|
||||
s = menu_new("subsex menu", "submenu", m);
|
||||
a = action_from_string("execute");
|
||||
a->data.execute.path = g_strdup("xclock");
|
||||
|
@ -90,19 +92,6 @@ void menu_startup()
|
|||
|
||||
menu_add_entry(m, menu_entry_new_submenu("subz", s));
|
||||
|
||||
t = (Menu *)plugin_create("timed_menu");
|
||||
if (t) {
|
||||
a = action_from_string("execute");
|
||||
a->data.execute.path = g_strdup("xeyes");
|
||||
menu_add_entry(t, menu_entry_new("xeyes", a));
|
||||
menu_add_entry(m, menu_entry_new_submenu("timed", t));
|
||||
}
|
||||
|
||||
t = (Menu *)plugin_create("fifo_menu");
|
||||
if (t) {
|
||||
menu_add_entry(m, menu_entry_new_submenu("fifo", t));
|
||||
}
|
||||
|
||||
s = menu_new("empty", "chub", m);
|
||||
menu_add_entry(m, menu_entry_new_submenu("empty", s));
|
||||
|
||||
|
@ -124,17 +113,7 @@ void menu_startup()
|
|||
menu_add_entry(s, menu_entry_new("exit", a));
|
||||
|
||||
menu_add_entry(m, menu_entry_new_submenu("long", s));
|
||||
|
||||
m = menu_new(NULL, "client", NULL);
|
||||
a = action_from_string("iconify");
|
||||
menu_add_entry(m, menu_entry_new("iconify", a));
|
||||
a = action_from_string("toggleshade");
|
||||
menu_add_entry(m, menu_entry_new("(un)shade", a));
|
||||
a = action_from_string("togglemaximizefull");
|
||||
menu_add_entry(m, menu_entry_new("(un)maximize", a));
|
||||
a = action_from_string("close");
|
||||
menu_add_entry(m, menu_entry_new("close", a));
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
void menu_shutdown()
|
||||
|
@ -395,7 +374,8 @@ void menu_control_mouseover(MenuEntry *self, gboolean enter) {
|
|||
theme_bevel;
|
||||
|
||||
menu_show_full(self->submenu, x,
|
||||
self->parent->location.y + self->y, NULL);
|
||||
self->parent->location.y + self->y,
|
||||
self->parent->client);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@ typedef void(*menu_controller_update)(struct Menu *self);
|
|||
typedef void(*menu_controller_mouseover)(struct MenuEntry *self,
|
||||
gboolean enter);
|
||||
|
||||
extern GHashTable *menu_hash;
|
||||
|
||||
typedef struct Menu {
|
||||
ObWindow obwin;
|
||||
|
||||
|
@ -135,6 +137,7 @@ void menu_entry_render(MenuEntry *self);
|
|||
void menu_entry_fire(MenuEntry *self);
|
||||
|
||||
void menu_render(Menu *self);
|
||||
void menu_render_full(Menu *self);
|
||||
|
||||
void menu_control_mouseover(MenuEntry *entry, gboolean enter);
|
||||
#endif
|
||||
|
|
|
@ -5,7 +5,7 @@ CPPFLAGS=$(XFT_CFLAGS) $(GLIB_CFLAGS) $(LIBSN_CFLAGS) @CPPFLAGS@ \
|
|||
|
||||
INCLUDES=-I../..
|
||||
|
||||
plugin_LTLIBRARIES=timed_menu.la fifo_menu.la
|
||||
plugin_LTLIBRARIES=timed_menu.la fifo_menu.la client_menu.la
|
||||
|
||||
timed_menu_la_LDFLAGS=-module -avoid-version
|
||||
timed_menu_la_SOURCES=timed_menu.c
|
||||
|
@ -13,6 +13,9 @@ timed_menu_la_SOURCES=timed_menu.c
|
|||
fifo_menu_la_LDFLAGS=-module -avoid-version
|
||||
fifo_menu_la_SOURCES=fifo_menu.c
|
||||
|
||||
client_menu_la_LDFLAGS=-module -avoid-version
|
||||
client_menu_la_SOURCES=client_menu.c
|
||||
|
||||
noinst_HEADERS=timed_menu.h fifo_menu.h
|
||||
|
||||
MAINTAINERCLEANFILES=Makefile.in
|
||||
|
|
87
plugins/menu/client_menu.c
Normal file
87
plugins/menu/client_menu.c
Normal file
|
@ -0,0 +1,87 @@
|
|||
#include <glib.h>
|
||||
|
||||
#include "kernel/menu.h"
|
||||
#include "kernel/screen.h"
|
||||
|
||||
static char *PLUGIN_NAME = "client_menu";
|
||||
static Menu *send_to_menu;
|
||||
|
||||
typedef struct {
|
||||
|
||||
} Client_Menu_Data;
|
||||
|
||||
#define CLIENT_MENU(m) ((Menu *)m)
|
||||
#define CLIENT_MENU_DATA(m) ((Client_Menu_Data *)((Menu *)m)->plugin_data)
|
||||
|
||||
|
||||
void client_menu_clean_up(Menu *m) {
|
||||
}
|
||||
|
||||
void client_send_to_update(Menu *self)
|
||||
{
|
||||
guint i;
|
||||
g_message("yo!");
|
||||
|
||||
for (i = 0; i < screen_num_desktops; ++i) {
|
||||
MenuEntry *e;
|
||||
Action *a = action_from_string("sendtodesktop");
|
||||
a->data.sendto.desk = i;
|
||||
a->data.sendto.follow = FALSE;
|
||||
e = menu_entry_new(screen_desktop_names[i], a);
|
||||
menu_add_entry(self, e);
|
||||
}
|
||||
|
||||
menu_render_full(self);
|
||||
}
|
||||
|
||||
void plugin_setup_config() { }
|
||||
|
||||
void plugin_shutdown() { }
|
||||
|
||||
void plugin_destroy (Menu *m)
|
||||
{
|
||||
}
|
||||
|
||||
void *plugin_create() /* TODO: need config */
|
||||
{
|
||||
Menu *m = menu_new(NULL, "client-menu", NULL);
|
||||
menu_add_entry(m, menu_entry_new_submenu("Send To Workspace",
|
||||
send_to_menu));
|
||||
send_to_menu->parent = m;
|
||||
|
||||
menu_add_entry(m, menu_entry_new("Iconify",
|
||||
action_from_string("iconify")));
|
||||
menu_add_entry(m, menu_entry_new("Raise",
|
||||
action_from_string("raise")));
|
||||
menu_add_entry(m, menu_entry_new("Lower",
|
||||
action_from_string("lower")));
|
||||
menu_add_entry(m, menu_entry_new("Close",
|
||||
action_from_string("close")));
|
||||
menu_add_entry(m, menu_entry_new("Shade",
|
||||
action_from_string("toggleshade")));
|
||||
menu_add_entry(m, menu_entry_new("Omnipresent",
|
||||
action_from_string("toggleomnipresent")));
|
||||
|
||||
/* send to desktop
|
||||
iconify
|
||||
raise
|
||||
lower
|
||||
close
|
||||
kill
|
||||
shade
|
||||
omnipresent
|
||||
decorations
|
||||
*/
|
||||
return (void *)m;
|
||||
}
|
||||
|
||||
void plugin_startup()
|
||||
{
|
||||
Menu *t;
|
||||
/* create a Send To Workspace Menu */
|
||||
send_to_menu = menu_new_full("Send To Workspace", "send-to-workspace",
|
||||
NULL, NULL, client_send_to_update);
|
||||
|
||||
t = (Menu *)plugin_create("client_menu");
|
||||
}
|
||||
|
Loading…
Reference in a new issue