Newer
Older
Olivier Fourdan
committed
clientShow(c, True);
}
break;
case MENU_OP_SHADE:
case MENU_OP_UNSHADE:
if(c)
{
clientToggleShaded(c);
}
break;
case MENU_OP_STICK:
case MENU_OP_UNSTICK:
if(c)
{
frameDraw(c);
Olivier Fourdan
committed
}
break;
case MENU_OP_DELETE:
if(c)
{
frameDraw(c);
Olivier Fourdan
committed
}
break;
default:
if(c)
{
frameDraw(c);
}
break;
}
menu_free(menu);
Olivier Fourdan
committed
static gboolean show_popup_cb(GtkWidget * widget, GdkEventButton * ev, gpointer data)
Olivier Fourdan
committed
Menu *menu;
MenuOp ops;
MenuOp insensitive;
Client *c = NULL;
gint x = ev->x_root;
gint y = ev->y_root;
DBG("entering show_popup_cb\n");
if(((ev->button == 1) || (ev->button == 3)) && (c = (Client *) data))
{
c->button_pressed[MENU_BUTTON] = True;
frameDraw(c);
y = c->y;
ops = MENU_OP_DELETE | MENU_OP_MINIMIZE_ALL;
Olivier Fourdan
committed
insensitive = 0;
Olivier Fourdan
committed
if(!(c->has_close))
{
Olivier Fourdan
committed
}
Olivier Fourdan
committed
Olivier Fourdan
committed
if(c->win_state & (WIN_STATE_MAXIMIZED | WIN_STATE_MAXIMIZED_HORIZ | WIN_STATE_MAXIMIZED_VERT))
Olivier Fourdan
committed
{
ops |= MENU_OP_UNMAXIMIZE;
Olivier Fourdan
committed
if(!CAN_MAXIMIZE_WINDOW(c))
{
insensitive |= MENU_OP_UNMAXIMIZE;
}
Olivier Fourdan
committed
}
Olivier Fourdan
committed
else
Olivier Fourdan
committed
{
ops |= MENU_OP_MAXIMIZE;
Olivier Fourdan
committed
if(!CAN_MAXIMIZE_WINDOW(c))
{
insensitive |= MENU_OP_MAXIMIZE;
}
Olivier Fourdan
committed
}
Olivier Fourdan
committed
{
ops |= MENU_OP_UNMINIMIZE;
Olivier Fourdan
committed
if(!CAN_HIDE_WINDOW(c))
{
insensitive |= MENU_OP_UNMINIMIZE;
}
Olivier Fourdan
committed
}
Olivier Fourdan
committed
{
ops |= MENU_OP_MINIMIZE;
Olivier Fourdan
committed
if(!CAN_HIDE_WINDOW(c))
{
insensitive |= MENU_OP_MINIMIZE;
}
Olivier Fourdan
committed
}
if(c->win_state & WIN_STATE_SHADED)
{
ops |= MENU_OP_UNSHADE;
}
Olivier Fourdan
committed
{
ops |= MENU_OP_SHADE;
}
if(c->sticky)
{
ops |= MENU_OP_UNSTICK;
Olivier Fourdan
committed
if(!(c->has_menu))
{
insensitive |= MENU_OP_UNSTICK;
Olivier Fourdan
committed
}
Olivier Fourdan
committed
}
Olivier Fourdan
committed
{
ops |= MENU_OP_STICK;
Olivier Fourdan
committed
if(!(c->has_menu))
{
Olivier Fourdan
committed
}
Olivier Fourdan
committed
}
}
else
{
return (TRUE);
}
if(button_handler_id)
{
g_signal_handler_disconnect(GTK_OBJECT(getDefaultGtkWidget()), button_handler_id);
}
button_handler_id = g_signal_connect(GTK_OBJECT(getDefaultGtkWidget()), "button_press_event", GTK_SIGNAL_FUNC(show_popup_cb), (gpointer) NULL);
Olivier Fourdan
committed
if(menu_event_window)
Olivier Fourdan
committed
removeTmpEventWin(menu_event_window);
/*
Since all button press/release events are catched by the windows frames, there is some
side effect with GTK menu. When a menu is opened, any click on the window frame is not
detected as a click outside the menu, and the menu doesn't close.
To avoid this (painless but annoying) behaviour, we just setup a no event window that
"hides" the events to regular windows.
That might look tricky, but it's very efficient and save plenty of lines of complicated
code.
Don't forget to delete that window once the menu is closed, though, or we'll get in
trouble.
*/
menu_event_window = setTmpEventWin(NoEventMask);
Olivier Fourdan
committed
menu = menu_default(ops, insensitive, menu_callback, c);
if(!menu_popup(menu, x, y, ev->button, ev->time))
Olivier Fourdan
committed
{
DBG("Cannot open menu\n");
gdk_beep();
c->button_pressed[MENU_BUTTON] = False;
Olivier Fourdan
committed
frameDraw(c);
Olivier Fourdan
committed
removeTmpEventWin(menu_event_window);
Olivier Fourdan
committed
menu_free(menu);
}
Olivier Fourdan
committed
return (TRUE);
static gboolean set_reload(void)
{
DBG("setting reload flag so all prefs will be reread at next event loop\n");
reload = True;
return (TRUE);
}
static gboolean set_dbl_click_time(void)
{
GValue tmp_val = { 0, };
Olivier Fourdan
committed
Olivier Fourdan
committed
g_value_init(&tmp_val, G_TYPE_INT);
if(gdk_setting_get("gtk-double-click-time", &tmp_val))
Olivier Fourdan
committed
dbl_click_time = abs(g_value_get_int(&tmp_val));
}
return (TRUE);
}
Olivier Fourdan
committed
static gboolean client_event_cb(GtkWidget * widget, GdkEventClient * ev)
Olivier Fourdan
committed
DBG("entering client_event_cb\n");
if(!atom_rcfiles)
{
atom_rcfiles = gdk_atom_intern("_GTK_READ_RCFILES", FALSE);
}
if(ev->message_type == atom_rcfiles)
{
Olivier Fourdan
committed
}
return (FALSE);
Olivier Fourdan
committed
void initGtkCallbacks(void)
Olivier Fourdan
committed
Olivier Fourdan
committed
button_handler_id = g_signal_connect(GTK_OBJECT(getDefaultGtkWidget()), "button_press_event", GTK_SIGNAL_FUNC(show_popup_cb), (gpointer) NULL);
Olivier Fourdan
committed
g_signal_connect(GTK_OBJECT(getDefaultGtkWidget()), "client_event", GTK_SIGNAL_FUNC(client_event_cb), (gpointer) NULL);
settings = gtk_settings_get_default();
Olivier Fourdan
committed
if(settings)
Olivier Fourdan
committed
g_signal_connect(settings, "notify::gtk-theme-name", G_CALLBACK(set_reload), NULL);
g_signal_connect(settings, "notify::gtk-font-name", G_CALLBACK(set_reload), NULL);
g_signal_connect(settings, "notify::gtk-double-click-time", G_CALLBACK(set_dbl_click_time), NULL);