Newer
Older
Olivier Fourdan
committed
c = (Client *) menu_data;
c = clientGetFromWindow(c->window, WINDOW);
if(c)
{
Olivier Fourdan
committed
}
Olivier Fourdan
committed
Olivier Fourdan
committed
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
case MENU_OP_QUIT:
gtk_main_quit();
break;
case MENU_OP_MAXIMIZE:
case MENU_OP_UNMAXIMIZE:
if(c)
{
clientToggleMaximized(c, WIN_STATE_MAXIMIZED);
}
break;
case MENU_OP_MINIMIZE:
if(c)
{
clientHide(c, True);
}
break;
case MENU_OP_MINIMIZE_ALL:
clientHideAll(c);
break;
case MENU_OP_UNMINIMIZE:
if(c)
{
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)
{
clientToggleSticky(c);
frameDraw(c);
}
break;
case MENU_OP_DELETE:
if(c)
{
clientClose(c);
frameDraw(c);
}
break;
case MENU_OP_DESTROY:
if(c)
{
clientKill(c);
frameDraw(c);
}
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_DESTROY | MENU_OP_MINIMIZE_ALL;
insensitive = 0;
if (!(c->has_close))
{
insensitive |= MENU_OP_DELETE | MENU_OP_DESTROY;
}
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;
if (!CAN_MAXIMIZE_WINDOW(c))
{
insensitive |= MENU_OP_UNMAXIMIZE;
}
Olivier Fourdan
committed
}
Olivier Fourdan
committed
{
ops |= MENU_OP_MAXIMIZE;
if (!CAN_MAXIMIZE_WINDOW(c))
{
insensitive |= MENU_OP_MAXIMIZE;
}
Olivier Fourdan
committed
}
Olivier Fourdan
committed
{
ops |= MENU_OP_UNMINIMIZE;
if (!CAN_HIDE_WINDOW(c))
{
insensitive |= MENU_OP_UNMINIMIZE;
}
Olivier Fourdan
committed
}
Olivier Fourdan
committed
{
ops |= MENU_OP_MINIMIZE;
if (!CAN_HIDE_WINDOW(c))
{
insensitive |= MENU_OP_MINIMIZE;
}
Olivier Fourdan
committed
}
if(c->win_state & WIN_STATE_SHADED)
{
ops |= MENU_OP_UNSHADE;
if (!(c->has_menu))
{
insensitive |= MENU_OP_UNSHADE;
}
Olivier Fourdan
committed
}
Olivier Fourdan
committed
{
ops |= MENU_OP_SHADE;
if (!(c->has_menu))
{
insensitive |= MENU_OP_SHADE;
}
Olivier Fourdan
committed
}
if(c->sticky)
{
ops |= MENU_OP_UNSTICK;
if (!(c->has_menu))
{
insensitive |= MENU_OP_UNSTICK;
}
Olivier Fourdan
committed
}
Olivier Fourdan
committed
{
ops |= MENU_OP_STICK;
if (!(c->has_menu))
{
insensitive |= MENU_OP_STICK;
}
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);
if (menu_event_window)
{
removeTmpEventWin (menu_event_window);
menu_event_window = None;
}
/*
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);
removeTmpEventWin (menu_event_window);
menu_event_window = None;
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, };
DBG("setting dbl_click_time\n");
g_value_init (&tmp_val, G_TYPE_INT);
if (gdk_setting_get ("gtk-double-click-time", &tmp_val))
{
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);