Newer
Older
Olivier Fourdan
committed
else if(!(c->transient_for))
Olivier Fourdan
committed
{
clientSetWorkspace(c, ev->data.l[0], TRUE);
Olivier Fourdan
committed
}
}
else if((ev->message_type == net_close_window) && (ev->format == 32))
Olivier Fourdan
committed
{
DBG("client \"%s\" (%#lx) has received a net_close_window event\n", c->name, c->window);
Olivier Fourdan
committed
clientClose(c);
}
else if((ev->message_type == net_wm_state) && (ev->format == 32))
{
DBG("client \"%s\" (%#lx) has received a net_wm_state event\n", c->name, c->window);
Olivier Fourdan
committed
clientUpdateNetState(c, ev);
}
else if((ev->message_type == net_wm_moveresize) && (ev->format == 32))
{
DBG("client \"%s\" (%#lx) has received a net_wm_moveresize event\n", c->name, c->window);
g_message(_("%s: Operation not supported (yet)\n"), g_get_prgname());
Olivier Fourdan
committed
/* TBD */
}
else if((ev->message_type == net_active_window) && (ev->format == 32))
{
DBG("client \"%s\" (%#lx) has received a net_active_window event\n", c->name, c->window);
Olivier Fourdan
committed
workspaceSwitch(c->win_workspace, NULL);
clientShow(c, True);
clientRaise(c);
clientSetFocus(c, True);
}
}
else
{
if(((ev->message_type == win_workspace) || (ev->message_type == net_current_desktop)) && (ev->format == 32))
Olivier Fourdan
committed
{
DBG("root has received a win_workspace or a net_current_desktop event\n");
workspaceSwitch(ev->data.l[0], NULL);
}
Olivier Fourdan
committed
else if(((ev->message_type == win_workspace_count) || (ev->message_type == net_number_of_desktops)) && (ev->format == 32))
{
DBG("root has received a win_workspace_count event\n");
workspaceSetCount(ev->data.l[0]);
Olivier Fourdan
committed
}
else
{
Olivier Fourdan
committed
DBG("unidentified client message for window 0x%lx\n", ev->window);
}
static inline void handleShape(XShapeEvent * ev)
{
Client *c;
DBG("entering handleShape\n");
c = clientGetFromWindow(ev->window, WINDOW);
if(c)
{
frameDraw(c, FALSE, TRUE);
Olivier Fourdan
committed
static inline void handleColormapNotify(XColormapEvent * ev)
Olivier Fourdan
committed
DBG("entering handleColormapNotify\n");
Olivier Fourdan
committed
c = clientGetFromWindow(ev->window, WINDOW);
Olivier Fourdan
committed
if((c) && (ev->window == c->window) && (ev->new))
Olivier Fourdan
committed
if(c == clientGetFocus())
{
clientInstallColormaps(c);
}
void handleEvent(XEvent * ev)
{
DBG("entering handleEvent\n");
sn_process_event(ev);
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
switch (ev->type)
{
case KeyPress:
handleKeyPress((XKeyEvent *) ev);
break;
case ButtonPress:
handleButtonPress((XButtonEvent *) ev);
break;
case ButtonRelease:
handleButtonRelease((XButtonEvent *) ev);
break;
case DestroyNotify:
handleDestroyNotify((XDestroyWindowEvent *) ev);
break;
case UnmapNotify:
handleUnmapNotify((XUnmapEvent *) ev);
break;
case MapRequest:
handleMapRequest((XMapRequestEvent *) ev);
break;
case ConfigureRequest:
handleConfigureRequest((XConfigureRequestEvent *) ev);
break;
case EnterNotify:
handleEnterNotify((XCrossingEvent *) ev);
break;
case FocusIn:
handleFocusIn((XFocusChangeEvent *) ev);
break;
case FocusOut:
handleFocusOut((XFocusChangeEvent *) ev);
break;
case PropertyNotify:
handlePropertyNotify((XPropertyEvent *) ev);
break;
case ClientMessage:
handleClientMessage((XClientMessageEvent *) ev);
break;
case ColormapNotify:
handleColormapNotify((XColormapEvent *) ev);
break;
default:
if(shape && (ev->type == shape_event))
Olivier Fourdan
committed
{
Olivier Fourdan
committed
}
Olivier Fourdan
committed
if(!gdk_events_pending() && !XPending(dpy))
Olivier Fourdan
committed
if(reload)
{
Olivier Fourdan
committed
}
else if(quit)
{
Olivier Fourdan
committed
}
Olivier Fourdan
committed
GtkToXEventFilterStatus xfwm4_event_filter(XEvent * xevent, gpointer data)
{
DBG("entering xfwm4_event_filter\n");
handleEvent(xevent);
DBG("leaving xfwm4_event_filter\n");
return XEV_FILTER_STOP;
}
/* GTK stuff (menu, etc...) */
Olivier Fourdan
committed
static void menu_callback(Menu * menu, MenuOp op, Window client_xwindow, gpointer menu_data, gpointer item_data)
Olivier Fourdan
committed
Olivier Fourdan
committed
if(menu_event_window)
Olivier Fourdan
committed
removeTmpEventWin(menu_event_window);
Olivier Fourdan
committed
if(menu_data)
Olivier Fourdan
committed
c = (Client *) menu_data;
c = clientGetFromWindow(c->window, WINDOW);
if(c)
{
Olivier Fourdan
committed
}
Olivier Fourdan
committed
Olivier Fourdan
committed
case MENU_OP_QUIT:
gtk_main_quit();
break;
case MENU_OP_MAXIMIZE:
case MENU_OP_UNMAXIMIZE:
if((c) && CLIENT_CAN_MAXIMIZE_WINDOW(c))
Olivier Fourdan
committed
{
clientToggleMaximized(c, WIN_STATE_MAXIMIZED);
}
break;
case MENU_OP_MINIMIZE:
if((c) && CLIENT_CAN_HIDE_WINDOW(c))
Olivier Fourdan
committed
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
{
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)
{
frameDraw(c, FALSE, FALSE);
Olivier Fourdan
committed
}
break;
case MENU_OP_DELETE:
if(c)
{
frameDraw(c, FALSE, FALSE);
Olivier Fourdan
committed
}
break;
default:
if(c)
{
frameDraw(c, FALSE, FALSE);
Olivier Fourdan
committed
}
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, FALSE, FALSE);
Olivier Fourdan
committed
y = c->y;
ops = MENU_OP_DELETE | MENU_OP_MINIMIZE_ALL;
Olivier Fourdan
committed
insensitive = 0;
if(!CLIENT_FLAG_TEST(c, CLIENT_FLAG_HAS_CLOSE))
Olivier Fourdan
committed
{
Olivier Fourdan
committed
}
Olivier Fourdan
committed
if(CLIENT_FLAG_TEST(c, CLIENT_FLAG_MAXIMIZED))
Olivier Fourdan
committed
{
ops |= MENU_OP_UNMAXIMIZE;
if(!CLIENT_CAN_MAXIMIZE_WINDOW(c))
Olivier Fourdan
committed
{
insensitive |= MENU_OP_UNMAXIMIZE;
}
Olivier Fourdan
committed
}
Olivier Fourdan
committed
else
Olivier Fourdan
committed
{
ops |= MENU_OP_MAXIMIZE;
if(!CLIENT_CAN_MAXIMIZE_WINDOW(c))
Olivier Fourdan
committed
{
insensitive |= MENU_OP_MAXIMIZE;
}
Olivier Fourdan
committed
}
if(CLIENT_FLAG_TEST(c, CLIENT_FLAG_HIDDEN))
Olivier Fourdan
committed
{
ops |= MENU_OP_UNMINIMIZE;
if(!CLIENT_CAN_HIDE_WINDOW(c))
Olivier Fourdan
committed
{
insensitive |= MENU_OP_UNMINIMIZE;
}
Olivier Fourdan
committed
}
Olivier Fourdan
committed
{
ops |= MENU_OP_MINIMIZE;
if(!CLIENT_CAN_HIDE_WINDOW(c))
Olivier Fourdan
committed
{
insensitive |= MENU_OP_MINIMIZE;
}
Olivier Fourdan
committed
}
if(CLIENT_FLAG_TEST(c, CLIENT_FLAG_SHADED))
Olivier Fourdan
committed
{
ops |= MENU_OP_UNSHADE;
}
Olivier Fourdan
committed
{
ops |= MENU_OP_SHADE;
}
if(CLIENT_FLAG_TEST(c, CLIENT_FLAG_STICKY))
Olivier Fourdan
committed
{
ops |= MENU_OP_UNSTICK;
Olivier Fourdan
committed
if(!CLIENT_FLAG_TEST(c, CLIENT_FLAG_HAS_STICK))
Olivier Fourdan
committed
{
insensitive |= MENU_OP_UNSTICK;
Olivier Fourdan
committed
}
Olivier Fourdan
committed
}
Olivier Fourdan
committed
{
ops |= MENU_OP_STICK;
Olivier Fourdan
committed
if(!CLIENT_FLAG_TEST(c, CLIENT_FLAG_HAS_STICK))
Olivier Fourdan
committed
{
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;
frameDraw(c, FALSE, FALSE);
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 dbl_click_time(void)
Olivier Fourdan
committed
Olivier Fourdan
committed
g_value_init(&tmp_val, G_TYPE_INT);
if(gdk_setting_get("gtk-double-click-time", &tmp_val))
params.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(dbl_click_time), NULL);