Newer
Older
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
if (c)
{
TRACE ("client %s (0x%lx) is attempting to manipulate its frame!",
c->name, c->window);
if (ev->value_mask & CWX)
{
wc.x += frameLeft (c);
}
if (ev->value_mask & CWY)
{
wc.y += frameTop (c);
}
if (ev->value_mask & CWWidth)
{
wc.width -= frameLeft (c) + frameRight (c);
}
if (ev->value_mask & CWHeight)
{
wc.height -= frameTop (c) + frameBottom (c);
}
/* We don't allow changing stacking order by accessing the frame
window because that would break the layer management in xfwm4
*/
ev->value_mask &= ~(CWSibling | CWStackMode);
}
}
if (c)
{
gboolean constrained = FALSE;
TRACE ("handleConfigureRequest managed window \"%s\" (0x%lx)",
c->name, c->window);
if (CLIENT_FLAG_TEST (c, CLIENT_FLAG_MOVING_RESIZING))
{
/* Sorry, but it's not the right time for configure request */
return;
}
if (c->type == WINDOW_DESKTOP)
{
/* Ignore stacking request for DESKTOP windows */
ev->value_mask &= ~(CWSibling | CWStackMode);
}
clientCoordGravitate (c, APPLY, &wc.x, &wc.y);
/* Clean up buggy requests that set all flags */
if ((ev->value_mask & CWX) && (wc.x == c->x))
{
ev->value_mask &= ~CWX;
}
if ((ev->value_mask & CWY) && (wc.y == c->y))
{
ev->value_mask &= ~CWY;
}
if ((ev->value_mask & CWWidth) && (wc.width == c->width))
{
ev->value_mask &= ~CWWidth;
}
if ((ev->value_mask & CWHeight) && (wc.height == c->height))
{
ev->value_mask &= ~CWHeight;
}
/* Still a move/resize after cleanup? */
if (ev->value_mask & (CWX | CWY | CWWidth | CWHeight))
{
if (CLIENT_FLAG_TEST (c, CLIENT_FLAG_MAXIMIZED))
{
clientRemoveMaximizeFlag (c);
}
constrained = TRUE;
}
Olivier Fourdan
committed
#if 0
/* Let's say that if the client performs a XRaiseWindow, we show the window if hidden */
if ((ev->value_mask & CWStackMode) && (wc.stack_mode == Above))
{
if ((c->win_workspace == workspace) ||
(CLIENT_FLAG_TEST (c, CLIENT_FLAG_STICKY)))
{
if (CLIENT_FLAG_TEST (c, CLIENT_FLAG_HIDDEN))
{
clientShow (c, TRUE);
}
}
}
Olivier Fourdan
committed
#endif
clientConfigure (c, &wc, ev->value_mask,
(constrained ? CFG_CONSTRAINED : 0) | CFG_REQUEST);
TRACE ("unmanaged configure request for win 0x%lx", ev->window);
XConfigureWindow (dpy, ev->window, ev->value_mask, &wc);
static inline void
handleEnterNotify (XCrossingEvent * ev)
TRACE ("entering handleEnterNotify");
if ((ev->mode == NotifyGrab) || (ev->mode == NotifyUngrab)
|| (ev->detail > NotifyNonlinearVirtual))
/* We're not interested in such notifications */
return;
TRACE ("EnterNotify on window (0x%lx)", ev->window);
c = clientGetFromWindow (ev->window, FRAME);
if (c && !(params.click_to_focus) && (clientAcceptFocus (c)))
TRACE ("EnterNotify window is \"%s\"", c->name);
if ((c->type != WINDOW_DOCK) && (c->type != WINDOW_DESKTOP))
{
static inline void
handleLeaveNotify (XCrossingEvent * ev)
Olivier Fourdan
committed
{
TRACE ("entering handleLeaveNotify");
Olivier Fourdan
committed
Olivier Fourdan
committed
if ((ev->mode == NotifyGrab) || (ev->mode == NotifyUngrab)
|| (ev->detail > NotifyNonlinearVirtual))
{
/* We're not interested in such notifications */
return;
}
if ((ev->window == sidewalk[0]) || (ev->window == sidewalk[1]))
Olivier Fourdan
committed
{
TRACE ("Reset edge_scroll_x");
edge_scroll_x = 0;
}
Olivier Fourdan
committed
}
static inline void
handleFocusIn (XFocusChangeEvent * ev)
TRACE ("entering handleFocusIn");
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
TRACE ("handleFocusOut (0x%lx) mode = %s",
ev->window,
(ev->mode == NotifyNormal) ?
"NotifyNormal" :
(ev->mode == NotifyWhileGrabbed) ?
"NotifyWhileGrabbed" :
"(unknown)");
TRACE ("handleFocusOut (0x%lx) detail = %s",
ev->window,
(ev->detail == NotifyAncestor) ?
"NotifyAncestor" :
(ev->detail == NotifyVirtual) ?
"NotifyVirtual" :
(ev->detail == NotifyInferior) ?
"NotifyInferior" :
(ev->detail == NotifyNonlinear) ?
"NotifyNonlinear" :
(ev->detail == NotifyNonlinearVirtual) ?
"NotifyNonlinearVirtual" :
(ev->detail == NotifyPointer) ?
"NotifyPointer" :
(ev->detail == NotifyPointerRoot) ?
"NotifyPointerRoot" :
(ev->detail == NotifyDetailNone) ?
"NotifyDetailNone" :
"(unknown)");
if ((ev->mode == NotifyGrab) || (ev->mode == NotifyUngrab)
|| (ev->detail > NotifyNonlinearVirtual))
{
/* We're not interested in such notifications */
return;
}
c = clientGetFromWindow (ev->window, WINDOW);
TRACE ("FocusIn on window (0x%lx)", ev->window);
TRACE ("focus set to \"%s\" (0x%lx)", c->name, c->window);
clientUpdateFocus (c);
if (params.raise_on_focus && !params.click_to_focus)
{
reset_timeout ();
}
static inline void
handleFocusOut (XFocusChangeEvent * ev)
Olivier Fourdan
committed
Client *c;
TRACE ("entering handleFocusOut");
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
TRACE ("handleFocusOut (0x%lx) mode = %s",
ev->window,
(ev->mode == NotifyNormal) ?
"NotifyNormal" :
(ev->mode == NotifyWhileGrabbed) ?
"NotifyWhileGrabbed" :
"(unknown)");
TRACE ("handleFocusOut (0x%lx) detail = %s",
ev->window,
(ev->detail == NotifyAncestor) ?
"NotifyAncestor" :
(ev->detail == NotifyVirtual) ?
"NotifyVirtual" :
(ev->detail == NotifyInferior) ?
"NotifyInferior" :
(ev->detail == NotifyNonlinear) ?
"NotifyNonlinear" :
(ev->detail == NotifyNonlinearVirtual) ?
"NotifyNonlinearVirtual" :
(ev->detail == NotifyPointer) ?
"NotifyPointer" :
(ev->detail == NotifyPointerRoot) ?
"NotifyPointerRoot" :
(ev->detail == NotifyDetailNone) ?
"NotifyDetailNone" :
"(unknown)");
Olivier Fourdan
committed
if ((ev->mode == NotifyGrab) || (ev->mode == NotifyUngrab)
|| (ev->detail != NotifyNonlinear))
Olivier Fourdan
committed
{
/* We're not interested in such notifications */
return;
Olivier Fourdan
committed
}
c = clientGetFromWindow (ev->window, WINDOW);
TRACE ("FocusOut on window (0x%lx)", ev->window);
if (c && (c == clientGetFocus ()))
Olivier Fourdan
committed
{
TRACE ("focus lost from \"%s\" (0x%lx)", c->name, c->window);
clientUpdateFocus (NULL);
/* Clear timeout */
clear_timeout ();
Olivier Fourdan
committed
}
static inline void
handlePropertyNotify (XPropertyEvent * ev)
TRACE ("entering handlePropertyNotify");
c = clientGetFromWindow (ev->window, WINDOW);
if (c)
{
if (ev->atom == XA_WM_NORMAL_HINTS)
{
TRACE
("client \"%s\" (0x%lx) has received a XA_WM_NORMAL_HINTS notify",
c->name, c->window);
}
else if ((ev->atom == XA_WM_NAME) || (ev->atom == net_wm_name))
{
TRACE ("client \"%s\" (0x%lx) has received a XA_WM_NAME notify",
c->name, c->window);
if (c->name)
{
free (c->name);
}
getWindowName (dpy, c->window, &c->name);
CLIENT_FLAG_SET (c, CLIENT_FLAG_NAME_CHANGED);
frameDraw (c, TRUE, FALSE);
}
else if (ev->atom == motif_wm_hints)
{
TRACE
("client \"%s\" (0x%lx) has received a motif_wm_hints notify",
c->name, c->window);
}
else if (ev->atom == XA_WM_HINTS)
{
TRACE ("client \"%s\" (0x%lx) has received a XA_WM_HINTS notify",
c->name, c->window);
c->wmhints = XGetWMHints (dpy, c->window);
if (c->wmhints)
{
if (c->wmhints->flags & WindowGroupHint)
{
c->group_leader = c->wmhints->window_group;
}
}
}
else if (ev->atom == win_hints)
{
TRACE ("client \"%s\" (0x%lx) has received a win_hints notify",
c->name, c->window);
getHint (dpy, c->window, win_hints, &c->win_hints);
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
}
else if (ev->atom == net_wm_window_type)
{
TRACE
("client \"%s\" (0x%lx) has received a net_wm_window_type notify",
c->name, c->window);
clientGetNetWmType (c);
frameDraw (c, TRUE, FALSE);
}
else if (ev->atom == net_wm_strut)
{
TRACE ("client \"%s\" (0x%lx) has received a net_wm_strut notify",
c->name, c->window);
clientGetNetStruts (c);
}
else if (ev->atom == wm_colormap_windows)
{
clientUpdateColormaps (c);
if (c == clientGetFocus ())
{
clientInstallColormaps (c);
}
}
#ifdef HAVE_STARTUP_NOTIFICATION
else if (ev->atom == net_startup_id)
{
if (c->startup_id)
{
free (c->startup_id);
c->startup_id = NULL;
}
getWindowStartupId (dpy, c->window, &c->startup_id);
}
#endif
else if (ev->atom == gnome_panel_desktop_area)
TRACE ("root has received a gnome_panel_desktop_area notify");
getGnomeDesktopMargins (dpy, screen, gnome_margins);
workspaceUpdateArea (margins, gnome_margins);
static inline void
handleClientMessage (XClientMessageEvent * ev)
TRACE ("entering handleClientMessage");
/* Don't get surprised with the multiple "if (!clientIsTransientOrModal(c))" tests
xfwm4 really treats transient differently
*/
c = clientGetFromWindow (ev->window, WINDOW);
if (c)
{
if ((ev->message_type == wm_change_state) && (ev->format == 32)
&& (ev->data.l[0] == IconicState))
{
TRACE
("client \"%s\" (0x%lx) has received a wm_change_state event",
c->name, c->window);
if (!CLIENT_FLAG_TEST (c, CLIENT_FLAG_HIDDEN) &&
CLIENT_CAN_HIDE_WINDOW (c))
{
clientHide (c, c->win_workspace, TRUE);
}
}
else if ((ev->message_type == win_state) && (ev->format == 32))
{
TRACE ("client \"%s\" (0x%lx) has received a win_state event",
c->name, c->window);
clientUpdateWinState (c, ev);
}
else if ((ev->message_type == win_layer) && (ev->format == 32))
{
TRACE ("client \"%s\" (0x%lx) has received a win_layer event",
c->name, c->window);
if ((ev->data.l[0] != c->win_layer) && !clientIsTransientOrModal (c))
{
clientSetLayer (c, ev->data.l[0]);
clientSetNetState (c);
}
}
else if ((ev->message_type == win_workspace) && (ev->format == 32))
{
TRACE ("client \"%s\" (0x%lx) has received a win_workspace event",
c->name, c->window);
if ((ev->data.l[0] != c->win_workspace) && !clientIsTransientOrModal (c))
{
clientSetWorkspace (c, ev->data.l[0], TRUE);
}
}
else if ((ev->message_type == net_wm_desktop) && (ev->format == 32))
{
TRACE
("client \"%s\" (0x%lx) has received a net_wm_desktop event",
c->name, c->window);
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
{
if (ev->data.l[0] == ALL_WORKSPACES)
{
if (CLIENT_FLAG_TEST_AND_NOT (c, CLIENT_FLAG_HAS_STICK,
CLIENT_FLAG_STICKY))
{
clientStick (c, TRUE);
frameDraw (c, FALSE, FALSE);
}
}
else
{
if (CLIENT_FLAG_TEST_ALL (c,
CLIENT_FLAG_HAS_STICK | CLIENT_FLAG_STICKY))
{
clientUnstick (c, TRUE);
frameDraw (c, FALSE, FALSE);
}
if (ev->data.l[0] != c->win_workspace)
{
clientSetWorkspace (c, ev->data.l[0], TRUE);
}
}
}
}
else if ((ev->message_type == net_close_window) && (ev->format == 32))
{
TRACE
("client \"%s\" (0x%lx) has received a net_close_window event",
c->name, c->window);
clientClose (c);
}
else if ((ev->message_type == net_wm_state) && (ev->format == 32))
{
TRACE ("client \"%s\" (0x%lx) has received a net_wm_state event",
c->name, c->window);
clientUpdateNetState (c, ev);
}
else if ((ev->message_type == net_wm_moveresize)
&& (ev->format == 32))
{
TRACE
("client \"%s\" (0x%lx) has received a net_wm_moveresize event",
c->name, c->window);
g_message (_("%s: Operation not supported (yet)\n"),
g_get_prgname ());
/* TBD */
}
else if ((ev->message_type == net_active_window)
&& (ev->format == 32))
{
TRACE
("client \"%s\" (0x%lx) has received a net_active_window event",
c->name, c->window);
workspaceSwitch (c->win_workspace, NULL);
clientShow (c, TRUE);
clientRaise (c);
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
if (((ev->message_type == win_workspace)
|| (ev->message_type == net_current_desktop))
&& (ev->format == 32))
{
TRACE
("root has received a win_workspace or a net_current_desktop event");
if (ev->data.l[0] != workspace)
{
workspaceSwitch (ev->data.l[0], NULL);
}
}
else if (((ev->message_type == win_workspace_count)
|| (ev->message_type == net_number_of_desktops))
&& (ev->format == 32))
{
TRACE ("root has received a win_workspace_count event");
if (ev->data.l[0] != params.workspace_count)
{
workspaceSetCount (ev->data.l[0]);
}
}
else
{
TRACE ("unidentified client message for window 0x%lx",
ev->window);
}
static inline void
handleShape (XShapeEvent * ev)
TRACE ("entering handleShape");
c = clientGetFromWindow (ev->window, WINDOW);
if (c)
frameDraw (c, FALSE, TRUE);
static inline void
handleColormapNotify (XColormapEvent * ev)
Olivier Fourdan
committed
TRACE ("entering handleColormapNotify");
Olivier Fourdan
committed
c = clientGetFromWindow (ev->window, WINDOW);
if ((c) && (ev->window == c->window) && (ev->new))
if (c == clientGetFocus ())
{
clientInstallColormaps (c);
}
void
handleEvent (XEvent * ev)
TRACE ("entering handleEvent");
sn_process_event (ev);
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
case MotionNotify:
handleMotionNotify ((XMotionEvent *) ev);
break;
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 MapNotify:
handleMapNotify ((XMapEvent *) ev);
break;
case ConfigureNotify:
handleConfigureNotify ((XConfigureEvent *) ev);
break;
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
case ConfigureRequest:
handleConfigureRequest ((XConfigureRequestEvent *) ev);
break;
case EnterNotify:
handleEnterNotify ((XCrossingEvent *) ev);
break;
case LeaveNotify:
handleLeaveNotify ((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))
{
handleShape ((XShapeEvent *) ev);
}
}
if (!gdk_events_pending () && !XPending (dpy))
{
if (reload)
{
reloadSettings (UPDATE_ALL);
reload = FALSE;
}
else if (quit)
{
gtk_main_quit ();
}
GtkToXEventFilterStatus
xfwm4_event_filter (XEvent * xevent, gpointer data)
TRACE ("entering xfwm4_event_filter");
handleEvent (xevent);
TRACE ("leaving xfwm4_event_filter");
/* GTK specific stuff */
static void
menu_callback (Menu * menu, MenuOp op, Window client_xwindow,
gpointer menu_data, gpointer item_data)
Olivier Fourdan
committed
TRACE ("entering menu_callback");
if (menu_event_window)
removeTmpEventWin (menu_event_window);
menu_event_window = None;
if (menu_data)
c = (Client *) menu_data;
c = clientGetFromWindow (c->window, WINDOW);
if (!c)
{
menu_free (menu);
return;
}
c->button_pressed[MENU_BUTTON] = FALSE;
Olivier Fourdan
committed
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
case MENU_OP_QUIT:
gtk_main_quit ();
break;
case MENU_OP_MAXIMIZE:
case MENU_OP_UNMAXIMIZE:
if (CLIENT_CAN_MAXIMIZE_WINDOW (c))
{
clientToggleMaximized (c, WIN_STATE_MAXIMIZED);
}
break;
case MENU_OP_MINIMIZE:
if (CLIENT_CAN_HIDE_WINDOW (c))
{
clientHide (c, c->win_workspace, TRUE);
}
frameDraw (c, FALSE, FALSE);
break;
case MENU_OP_MINIMIZE_ALL:
clientHideAll (c, c->win_workspace);
frameDraw (c, FALSE, FALSE);
break;
case MENU_OP_UNMINIMIZE:
clientShow (c, TRUE);
break;
case MENU_OP_SHADE:
case MENU_OP_UNSHADE:
clientToggleShaded (c);
break;
case MENU_OP_STICK:
case MENU_OP_UNSTICK:
clientToggleSticky (c, TRUE);
frameDraw (c, FALSE, FALSE);
break;
case MENU_OP_WORKSPACES:
clientSetWorkspace (c, GPOINTER_TO_INT (item_data), TRUE);
frameDraw (c, FALSE, FALSE);
break;
case MENU_OP_DELETE:
frameDraw (c, FALSE, FALSE);
clientClose (c);
break;
default:
frameDraw (c, FALSE, FALSE);
break;
}
menu_free (menu);
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;
TRACE ("entering show_popup_cb");
if (((ev->button == 1) || (ev->button == 3)) && (c = (Client *) data))
{
c->button_pressed[MENU_BUTTON] = TRUE;
frameDraw (c, FALSE, FALSE);
y = c->y;
ops = MENU_OP_DELETE | MENU_OP_MINIMIZE_ALL | MENU_OP_WORKSPACES;
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
insensitive = 0;
if (!CLIENT_FLAG_TEST (c, CLIENT_FLAG_HAS_CLOSE))
{
insensitive |= MENU_OP_DELETE;
}
if (CLIENT_FLAG_TEST (c, CLIENT_FLAG_MAXIMIZED))
{
ops |= MENU_OP_UNMAXIMIZE;
if (!CLIENT_CAN_MAXIMIZE_WINDOW (c))
{
insensitive |= MENU_OP_UNMAXIMIZE;
}
}
else
{
ops |= MENU_OP_MAXIMIZE;
if (!CLIENT_CAN_MAXIMIZE_WINDOW (c))
{
insensitive |= MENU_OP_MAXIMIZE;
}
}
if (CLIENT_FLAG_TEST (c, CLIENT_FLAG_HIDDEN))
{
ops |= MENU_OP_UNMINIMIZE;
if (!CLIENT_CAN_HIDE_WINDOW (c))
{
insensitive |= MENU_OP_UNMINIMIZE;
}
}
else
{
ops |= MENU_OP_MINIMIZE;
if (!CLIENT_CAN_HIDE_WINDOW (c))
{
insensitive |= MENU_OP_MINIMIZE;
}
}
if (CLIENT_FLAG_TEST (c, CLIENT_FLAG_SHADED))
{
ops |= MENU_OP_UNSHADE;
}
else
{
ops |= MENU_OP_SHADE;
}
if (CLIENT_FLAG_TEST (c, CLIENT_FLAG_STICKY))
{
ops |= MENU_OP_UNSTICK;
if (!CLIENT_FLAG_TEST (c, CLIENT_FLAG_HAS_STICK))
{
insensitive |= MENU_OP_UNSTICK;
}
}
else
{
ops |= MENU_OP_STICK;
if (!CLIENT_FLAG_TEST (c, CLIENT_FLAG_HAS_STICK))
{
insensitive |= MENU_OP_STICK;
}
}
|| !CLIENT_FLAG_TEST (c, CLIENT_FLAG_HAS_STICK)
|| CLIENT_FLAG_TEST (c, CLIENT_FLAG_STICKY))
{
insensitive |= MENU_OP_WORKSPACES;
}
Olivier Fourdan
committed
}
else
{
Olivier Fourdan
committed
}
if (button_handler_id)
Olivier Fourdan
committed
{
g_signal_handler_disconnect (GTK_OBJECT (getDefaultGtkWidget ()),
button_handler_id);
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
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
Don't forget to delete that window once the menu is closed, though, or we'll get in
Olivier Fourdan
committed
menu_event_window = setTmpEventWin (0, 0,
MyDisplayFullWidth (dpy, screen),
MyDisplayFullHeight (dpy, screen),
NoEventMask);
menu =
menu_default (ops, insensitive, menu_callback, c->win_workspace,
params.workspace_count, c);
if (!menu_popup (menu, x, y, ev->button, ev->time))
{
TRACE ("Cannot open menu");
gdk_beep ();
c->button_pressed[MENU_BUTTON] = FALSE;
frameDraw (c, FALSE, FALSE);
removeTmpEventWin (menu_event_window);
menu_event_window = None;
menu_free (menu);
Olivier Fourdan
committed
}
Olivier Fourdan
committed
return (TRUE);
static gboolean
set_reload (void)
("setting reload flag so all prefs will be reread at next event loop");
reload = TRUE;
static gboolean
dbl_click_time (void)
Olivier Fourdan
committed
TRACE ("setting dbl_click_time");
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);
}
static gboolean
client_event_cb (GtkWidget * widget, GdkEventClient * ev)
TRACE ("entering client_event_cb");
Olivier Fourdan
committed
if (!atom_rcfiles)
Olivier Fourdan
committed
{
atom_rcfiles = gdk_atom_intern ("_GTK_READ_RCFILES", FALSE);
Olivier Fourdan
committed
}
if (ev->message_type == atom_rcfiles)
Olivier Fourdan
committed
{
Olivier Fourdan
committed
}
return (FALSE);
void
initGtkCallbacks (void)
Olivier Fourdan
committed
button_handler_id =
g_signal_connect (GTK_OBJECT (getDefaultGtkWidget ()),
"button_press_event", GTK_SIGNAL_FUNC (show_popup_cb),
(gpointer) NULL);
g_signal_connect (GTK_OBJECT (getDefaultGtkWidget ()), "client_event",
GTK_SIGNAL_FUNC (client_event_cb), (gpointer) NULL);
settings = gtk_settings_get_default ();
if (settings)
{
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);