33#include <X11/extensions/shape.h>
39#include "ctwm_atoms.h"
46#include "functions_defs.h"
89 modifier &=
~Scr->IgnoreModifier;
109 XColormapEvent *cevent = (XColormapEvent *) &
Event;
112 int lost, won, n, number_cwins;
116 (XPointer *)&cwin) == XCNOENT) {
123 (XPointer *)&cwin->
colormap) == XCNOENT) {
132 if(cevent->state == ColormapUninstalled) {
151 if(cevent->state == ColormapUninstalled &&
163 if(cevent->serial >=
Scr->cmapInfo.first_req) {
164 number_cwins =
Scr->cmapInfo.cmaps->number_cwins;
170 cwins =
Scr->cmapInfo.cmaps->cwins;
171 for(lost = won = -1, n = 0;
172 (lost == -1 || won == -1) && n < number_cwins;
174 if(lost == -1 && cwins[n] == cwin) {
180 cwins[n]->colormap->install_req == cevent->serial) {
219 n = lost * (lost - 1) / 2 + won;
222 n = won * (won - 1) / 2 + lost;
224 Scr->cmapInfo.cmaps->scoreboard[n] = 1;
239 else if(lost != -1) {
248 else if(cevent->state == ColormapUninstalled) {
252 else if(cevent->state == ColormapInstalled) {
265 static XEvent current;
272 if((
new.type == FocusIn ||
new.type == FocusOut)
273 &&
new.xfocus.mode == NotifyNormal
274 && (
new.xfocus.detail == NotifyNonlinear
275 ||
new.xfocus.detail == NotifyPointer
276 ||
new.xfocus.detail == NotifyAncestor
277 || (
new.xfocus.detail == NotifyNonlinearVirtual)
284 fprintf(stderr,
"%s(): Focus%s 0x%x mode=%d, detail=%d\n",
285 __func__,
new.xfocus.type == FocusIn ?
"In" :
"Out",
286 Tmp_win,
new.xfocus.mode,
new.xfocus.detail);
290 while(XCheckWindowEvent(
dpy, w, FocusChangeMask, &
new));
351 fprintf(stderr,
"HandleFocus%s(): 0x%x (0x%x, 0x%x), mode=%d, "
353 (event->type == FocusIn ?
"In" :
"Out"),
359 if(event->type == FocusIn) {
371 if(!
Tmp_win->wmhints->input) {
410 if(
Scr->SloppyFocus) {
443 fprintf(stderr,
"HandleCirculateNotify\n");
444 fprintf(stderr,
"event=%x window=%x place=%d\n",
445 (
unsigned)
Event.xcirculate.event,
446 (
unsigned)
Event.xcirculate.window,
447 Event.xcirculate.place);
450 for(vs =
Scr->vScreenList; vs; vs = vs->
next) {
457 if(
Event.xcirculate.window == twm_win->
frame) {
460 else if(twm_win->
icon &&
461 Event.xcirculate.window == twm_win->
icon->
w) {
470 Event.xcirculate.place);
490 XVisibilityEvent *vevent = (XVisibilityEvent *) &
Event;
495 (XPointer *)&cwin) == XCNOENT) {
506 (vevent->state == VisibilityFullyObscured ||
507 cwin->
visibility == VisibilityFullyObscured) &&
508 cmap->
w == cwin->
w) {
551 if(
Scr->InfoWindow.mapped) {
552 XUnmapWindow(
dpy,
Scr->InfoWindow.win);
553 Scr->InfoWindow.mapped =
false;
571 keysym = XLookupKeysym((XKeyEvent *) &
Event, 0);
575 keynam = XKeysymToString(keysym);
586 if(keysym == XK_Down || keysym == XK_space) {
595 int xx =
Event.xkey.x;
596 int yy =
Event.xkey.y +
Scr->EntryHeight;
598 XTranslateCoordinates(
dpy,
Scr->Root,
ActiveMenu->w, xx, yy, &wx, &wy, &junkW);
600 yy -= (wy - (
Scr->EntryHeight / 2) - 2);
615 else if(keysym == XK_Up || keysym == XK_BackSpace) {
620 int xx =
Event.xkey.x;
621 int yy =
Event.xkey.y -
Scr->EntryHeight;
623 XTranslateCoordinates(
dpy,
Scr->Root,
ActiveMenu->w, xx, yy, &wx, &wy, &junkW);
625 yy -= (wy -
ActiveMenu->height + (
Scr->EntryHeight / 2) + 2);
634 else if(keysym == XK_Right || keysym == XK_Return) {
646 else if(keysym == XK_Left || keysym == XK_Escape) {
661 XUngrabPointer(
dpy, CurrentTime);
670 int xx =
Event.xkey.x;
671 int yy =
Event.xkey.y;
674 XTranslateCoordinates(
dpy,
Scr->Root, menu->
w, xx, yy, &wx, &wy, &junkW);
675 xx -= (wx - (menu->
width / 2));
678 (
Scr->EntryHeight / 2) - 2);
680 yy -= (wy - (
Scr->EntryHeight / 2) - 2);
690 else if(strlen(keynam) == 1) {
697 int xx =
Event.xkey.x;
698 int yy =
Event.xkey.y;
702 item = startitem->
next;
709 while(item != startitem) {
710 bool matched =
false;
712 switch(item->
item [0]) {
714 if((keymod & ControlMask) &&
720 if((keymod & Mod1Mask) &&
728 if(((
Scr->IgnoreCaseInMenuSelection) &&
731 ((keymod & ShiftMask) &&
Isupper(item->
item [offset]) &&
734 (!(keymod & ShiftMask) &&
Islower(item->
item [offset]) &&
735 (keynam [0] == item->
item [offset]))) {
748 if(item == startitem) {
752 wy = (item->
item_num *
Scr->EntryHeight) + (
Scr->EntryHeight / 2) + 2;
753 XTranslateCoordinates(
dpy,
ActiveMenu->w,
Scr->Root, wx, wy, &xx, &yy, &junkW);
790 if(!strcmp(keynam,
"Return")) {
802 XUngrabPointer(
dpy, CurrentTime);
830 int xx =
Event.xkey.x;
831 int yy =
Event.xkey.y;
841 yy -= (wy - item->
item_num *
Scr->EntryHeight - (
Scr->EntryHeight / 2) - 2);
842 Event.xkey.x_root = xx;
843 Event.xkey.y_root = yy;
859 if(item->
func != F_PIN) {
872 XUngrabPointer(
dpy, CurrentTime);
890 if(
Event.xany.window ==
Scr->Root) {
892 XUngrabPointer(
dpy, CurrentTime);
893 XUngrabKeyboard(
dpy, CurrentTime);
911#ifdef EWMH_DESKTOP_ROOT
913 fprintf(stderr,
"HandleKeyPress: wt_Desktop -> C_ROOT\n");
929 else if(
Tmp_win->iconmanagerlist) {
947 XUngrabPointer(
dpy, CurrentTime);
948 XUngrabKeyboard(
dpy, CurrentTime);
957 for(
FuncKey *key =
Scr->FuncKeyRoot.next; key != NULL; key = key->next) {
968 if(key->keycode !=
Event.xkey.keycode ||
969 key->mods != modifier ||
983 if(key->func == F_MOVE || key->func == F_RESIZE) {
989 if(key->func == F_MENU) {
1001#ifdef EWMH_DESKTOP_ROOT
1004 fprintf(stderr,
"HandleKeyPress: wt_Desktop -> C_WINDOW\n");
1010 XUngrabPointer(
dpy, CurrentTime);
1026 bool matched =
false;
1027 const size_t len = strlen(key->win_name);
1032 if(!strncmp(key->win_name,
Tmp_win->name,
len)) {
1037 XUngrabPointer(
dpy, CurrentTime);
1046 if(!strncmp(key->win_name,
Tmp_win->class.res_name,
len)) {
1051 XUngrabPointer(
dpy, CurrentTime);
1061 if(!strncmp(key->win_name,
Tmp_win->class.res_class,
len)) {
1066 XUngrabPointer(
dpy, CurrentTime);
1129 unsigned long nitems, bytesafter;
1130 unsigned long valuemask;
1131 XSetWindowAttributes attributes;
1137 if(
Event.xproperty.window ==
Scr->Root) {
1139 if(
Event.xproperty.atom == XA_WM_CURRENTWORKSPACE) {
1140 unsigned char *prop;
1141 switch(
Event.xproperty.state) {
1142 case PropertyNewValue:
1143 if(XGetWindowProperty(
dpy,
Scr->Root, XA_WM_CURRENTWORKSPACE,
1144 0L, 200L, False, XA_STRING, &actual, &actual_format,
1145 &nitems, &bytesafter, &prop) == Success) {
1158 switch(
Event.xproperty.state) {
1159 case PropertyNewValue: {
1160 XStandardColormap *maps = NULL;
1163 if(XGetRGBColormaps(
dpy,
Scr->Root, &maps, &nmaps,
1164 Event.xproperty.atom)) {
1171 case PropertyDelete:
1181#define MAX_NAME_LEN 200L
1183 switch(
Event.xproperty.atom) {
1189 Tmp_win->names.wm_name = NULL;
1194 if(
Tmp_win->names.wm_name != NULL
1195 && strcmp(
Tmp_win->names.wm_name, prop) == 0) {
1203 Tmp_win->names.wm_name = prop;
1211 case XA_WM_ICON_NAME: {
1216 Tmp_win->names.wm_icon_name = NULL;
1222 if(
Tmp_win->names.wm_icon_name != NULL
1223 && strcmp(
Tmp_win->names.wm_icon_name, prop) == 0) {
1230 Tmp_win->names.wm_icon_name = prop;
1240 XWMHints *nhints = XGetWMHints(
dpy,
Event.xany.window);
1266 Tmp_win->wmhints->flags &= ~(IconWindowHint | IconPixmapHint | IconMaskHint);
1269 if(
Tmp_win->wmhints->flags & IconWindowHint) {
1270 if(icon && icon->
w) {
1283 XMoveWindow(
dpy,
Tmp_win->wmhints->icon_window, icon_x,
1291 XMapWindow(
dpy,
Tmp_win->wmhints->icon_window);
1299 if(icon->
w !=
Tmp_win->wmhints->icon_window) {
1300 XUnmapWindow(
dpy, icon->
w);
1304 XDestroyWindow(
dpy, icon->
w);
1319 icon->
w =
Tmp_win->wmhints->icon_window;
1320 XSelectInput(
dpy, icon->
w,
1321 KeyPressMask | ButtonPressMask | ButtonReleaseMask);
1324 XDefineCursor(
dpy, icon->
w,
Scr->IconCursor);
1328 if(icon && icon->
w &&
1329 (
Tmp_win->wmhints->flags & IconPixmapHint)) {
1331 unsigned int IconDepth;
1345 if(IconDepth ==
Scr->d_depth)
1346 XCopyArea(
dpy,
Tmp_win->wmhints->icon_pixmap, pm,
Scr->NormalGC,
1349 XCopyPlane(
dpy,
Tmp_win->wmhints->icon_pixmap, pm,
Scr->NormalGC,
1360 icon->
image = image;
1364 valuemask = CWBackPixmap;
1365 attributes.background_pixmap = pm;
1368 XDestroyWindow(
dpy, icon->
bm_w);
1373 XCreateWindow(
dpy, icon->
w,
x, 0,
1377 CopyFromParent,
Scr->d_visual,
1378 valuemask, &attributes);
1380 if(!(
Tmp_win->wmhints->flags & IconMaskHint)) {
1385 rect.width = icon->
width;
1386 rect.height = icon->
height;
1387 XShapeCombineRectangles(
dpy, icon->
w, ShapeBounding, 0,
1388 0, &rect, 1, ShapeUnion, 0);
1390 XMapSubwindows(
dpy, icon->
w);
1393 if(icon && icon->
w &&
1394 (
Tmp_win->wmhints->flags & IconMaskHint) &&
1402 unsigned int IconWidth, IconHeight, IconDepth;
1409 if(IconDepth != 1) {
1413 mask = XCreatePixmap(
dpy,
Scr->Root, IconWidth, IconHeight, 1);
1417 gc = XCreateGC(
dpy, mask, 0, NULL);
1421 XCopyArea(
dpy,
Tmp_win->wmhints->icon_mask, mask, gc,
1422 0, 0, IconWidth, IconHeight, 0, 0);
1425 XShapeCombineMask(
dpy, icon->
bm_w, ShapeBounding, 0, 0, mask,
1427 XShapeCombineMask(
dpy, icon->
w, ShapeBounding,
x, 0, mask,
1437 if(
Tmp_win->wmhints->flags & IconPixmapHint) {
1444 case XA_WM_NORMAL_HINTS: {
1449 if(
Event.xproperty.atom == XA_WM_COLORMAP_WINDOWS) {
1453 else if(
Event.xproperty.atom == XA_WM_PROTOCOLS) {
1457 else if(
Event.xproperty.atom == XA_WM_OCCUPATION) {
1458 unsigned char *prop;
1461 XA_STRING, &actual, &actual_format, &nitems,
1462 &bytesafter, &prop) != Success ||
1469 else if(
Event.xproperty.atom == XA_CTWM_WM_NAME) {
1474 Tmp_win->names.ctwm_wm_name = NULL;
1479 if(
Tmp_win->names.ctwm_wm_name != NULL
1480 && strcmp(
Tmp_win->names.ctwm_wm_name,
1489 Tmp_win->names.ctwm_wm_name = prop;
1496 else if(
Event.xproperty.atom == XA_CTWM_WM_ICON_NAME) {
1498 XA_CTWM_WM_ICON_NAME);
1502 Tmp_win->names.ctwm_wm_icon_name = NULL;
1507 if(
Tmp_win->names.ctwm_wm_icon_name != NULL
1508 && strcmp(
Tmp_win->names.ctwm_wm_icon_name,
1517 Tmp_win->names.ctwm_wm_icon_name = prop;
1546 if(
Event.xclient.message_type == XA_WM_CHANGE_STATE) {
1548 if(
Event.xclient.data.l[0] == IconicState && !
Tmp_win->isicon) {
1551 &(button.xmotion.x_root),
1552 &(button.xmotion.y_root),
1556 Tmp_win, &button, FRAME,
false);
1557 XUngrabPointer(
dpy, CurrentTime);
1569 else if((
Event.xclient.message_type == XA_WM_PROTOCOLS) &&
1570 (
Event.xclient.data.l[0] == XA_WM_END_OF_ANIMATION)) {
1575 fprintf(stderr,
"!! end of unknown animation !!\n");
1601 if(
Event.xexpose.count != 0) {
1605 if(
Event.xany.window ==
Scr->InfoWindow.win &&
Scr->InfoWindow.mapped) {
1621 !
Scr->NoIconTitlebar &&
1627 else if(
Tmp_win->titlebuttons) {
1630 Window w =
Event.xany.window;
1631 int nb =
Scr->TBInfo.nleft +
Scr->TBInfo.nright;
1639 for(i = 0, tbw =
Tmp_win->titlebuttons; i < nb; i++, tbw++) {
1647 for(vs =
Scr->vScreenList; vs != NULL; vs = vs->
next) {
1654 if(
Tmp_win ==
Scr->workSpaceMgr.occupyWindow->twm_win) {
1667 if(
Event.xany.window ==
Scr->workSpaceMgr.occupyWindow->w) {
1673 else if(
Tmp_win->iconmanagerlist) {
1676 if(
Event.xany.window == iconmanagerlist->
w) {
1681 else if(
Event.xany.window == iconmanagerlist->
icon) {
1748 if(
Scr->SaveWorkspaceFocus) {
1750 for(ws =
Scr->workSpaceMgr.workSpaceList; ws != NULL; ws = ws->
next) {
1765 int nb =
Scr->TBInfo.nleft +
Scr->TBInfo.nright;
1788 for(i = 0; i < nb; i++) {
1789 XDeleteContext(
dpy,
Tmp_win->titlebuttons[i].window,
1791 XDeleteContext(
dpy,
Tmp_win->titlebuttons[i].window,
1856 Scr->NumAutoRaises--;
1859 Scr->NumAutoLowers--;
1873 XFree(
Tmp_win->class.res_name);
1876 XFree(
Tmp_win->class.res_class);
1885 if(
Tmp_win->squeeze_info_copied) {
1894 if(
Scr->ClickToFocus ||
Scr->SloppyFocus) {
1904 fprintf(stderr,
"CreateNotify w = 0x%x\n",
1905 (
unsigned)
Event.xcreatewindow.window);
1925 Event.xany.window =
Event.xmaprequest.window;
1954 if(
Tmp_win->iconmanagerlist == NULL) {
1966 if(
Scr->WindowMask) {
1967 XRaiseWindow(
dpy,
Scr->WindowMask);
1975 state = NormalState;
1978 (state == NormalState || state == IconicState || state == InactiveState))) {
1979 if(
Tmp_win->wmhints->flags & StateHint) {
1980 state =
Tmp_win->wmhints->initial_state;
1997 if(
Scr->ClickToFocus &&
Tmp_win->wmhints->input) {
2001 if(
Scr->AutoFocusToTransients &&
2012 if(!
Scr->NoRaiseDeicon) {
2018 if(
Tmp_win->UnmapByMovingFarAway) {
2029 zoom_save =
Scr->DoZoom;
2030 Scr->DoZoom =
false;
2032 Scr->DoZoom = zoom_save;
2173 if(XTranslateCoordinates(
dpy,
Event.xunmap.window,
Tmp_win->attr.root,
2174 0, 0, &dstx, &dsty, &dumwin)) {
2176 Bool reparented = XCheckTypedWindowEvent(
dpy,
Event.xunmap.window,
2177 ReparentNotify, &ev);
2182 XSetWindowBorderWidth(
dpy,
2183 Event.xunmap.window,
2186 if(
Tmp_win->wmhints->flags & IconWindowHint) {
2187 XUnmapWindow(
dpy,
Tmp_win->wmhints->icon_window);
2198 XRemoveFromSaveSet(
dpy,
Event.xunmap.window);
2199 XSelectInput(
dpy,
Event.xunmap.window, NoEventMask);
2218 XQueryPointer(
dpy,
Event.xany.window,
2220 &(
Event.xmotion.x_root), &(
Event.xmotion.y_root),
2235 XTranslateCoordinates(
dpy,
Scr->Root,
Tmp_win->winbox->window,
2260 if(
Scr->InfoWindow.mapped) {
2262 XUnmapWindow(
dpy,
Scr->InfoWindow.win);
2263 Scr->InfoWindow.mapped =
false;
2274 XTranslateCoordinates(
dpy,
Scr->Root,
Tmp_win->winbox->window,
2339 if(xl < 0 || yt < 0 || xl >
Scr->rootw || yt >
Scr->rooth) {
2345 XTranslateCoordinates(
dpy,
Tmp_win->vs->window,
2346 Scr->XineramaRoot, xl, yt, &odestx, &odesty, &cr);
2348 newvs = findIfVScreenOf(odestx, odesty);
2351 XTranslateCoordinates(
dpy,
Scr->XineramaRoot,
2352 newvs->
window, odestx, odesty,
2353 &destx, &desty, &cr);
2373 if(!
Scr->NoRaiseMove) {
2381 fprintf(stderr,
"ERROR -- events.c:2815\n");
2385 if(!
Scr->OpaqueMove) {
2392 if(
Scr->NumAutoRaises) {
2402 if(
Scr->NumAutoLowers) {
2424 if(
Scr->StayUpMenus) {
2426 if(
Scr->WarpToDefaultMenuEntry &&
ActiveMenu->defaultitem) {
2436 case F_DELETEORDESTROY:
2442 case F_WARPTOSCREEN:
2448 if(func != F_PIN && func != F_MENU) {
2466 if(
Scr->WarpToDefaultMenuEntry &&
ActiveMenu->defaultitem) {
2476 mask = (Button1Mask | Button2Mask | Button3Mask | Button4Mask | Button5Mask);
2477 switch(
Event.xbutton.button) {
2479 mask &= ~Button1Mask;
2482 mask &= ~Button2Mask;
2485 mask &= ~Button3Mask;
2488 mask &= ~Button4Mask;
2491 mask &= ~Button5Mask;
2507 (
Event.xbutton.state & mask) == 0 &&
2510 XUngrabPointer(
dpy, CurrentTime);
2518 if(
Scr->Highlight) {
2534 int x =
Event.xbutton.x_root;
2535 int y =
Event.xbutton.y_root;
2538 if(!
Scr->NoGrabServer) {
2542 int h =
Scr->TBInfo.width -
Scr->TBInfo.border;
2545 XTranslateCoordinates(
dpy, w,
Scr->Root, 0, h, &
x, &
y, &child);
2567 int x =
Event.xkey.x_root;
2568 int y =
Event.xkey.y_root;
2575 int h =
Scr->TBInfo.width -
Scr->TBInfo.border;
2578 XTranslateCoordinates(
dpy, w,
Scr->Root, 0, h, &
x, &
y, &child);
2608 unsigned int modifier;
2619 (XPointer *) &mr) != XCSUCCESS) {
2650 XUnmapWindow(
dpy,
Scr->SizeWindow);
2651 if(!
Scr->OpaqueMove) {
2657 if(
Event.xbutton.button == Button2) {
2660 else if(
Event.xbutton.button >= Button3) {
2664 XGrabPointer(
dpy,
Scr->Root, True,
2665 ButtonReleaseMask | ButtonPressMask,
2666 GrabModeAsync, GrabModeAsync,
2667 Scr->Root, cur, CurrentTime);
2699 int nb =
Scr->TBInfo.nleft +
Scr->TBInfo.nright;
2704 for(i = 0, tbw =
Tmp_win->titlebuttons; i < nb; i++, tbw++) {
2708 && tbf->
mods == modifier) {
2735 if(
Event.xany.window ==
Scr->InfoWindow.win) {
2739 if(
Event.xany.window ==
Scr->Root) {
2741 XUngrabPointer(
dpy, CurrentTime);
2742 XUngrabKeyboard(
dpy, CurrentTime);
2750 w =
Event.xbutton.subwindow;
2755 Event.xbutton.x,
Event.xbutton.y, &dx, &dy, &child);
2756 Event.xbutton.x = dx;
2757 Event.xbutton.x = dy;
2758 Event.xbutton.subwindow = child;
2767 ((
Event.xany.window ==
Tmp_win->iconmanagerlist->icon) ||
2781#ifdef EWMH_DESKTOP_ROOT
2783 fprintf(stderr,
"HandleButtonPress: wt_Desktop -> C_ROOT\n");
2788 if(
Scr->ClickToFocus &&
Tmp_win->wmhints->input) {
2794 if(
Scr->ClickToFocus ||
Scr->RaiseOnClick) {
2795 if(
Scr->ClickToFocus &&
Tmp_win->wmhints->input) {
2798 if(
Scr->RaiseOnClick) {
2803 XAllowEvents(
dpy, ReplayPointer, CurrentTime);
2809 printf(
"ERROR! ERROR! ERROR! YOU SHOULD NOT BE HERE!!!\n");
2834 if(
Tmp_win->iswinbox && chwin) {
2837 XTranslateCoordinates(
dpy,
Tmp_win->w, chwin,
2841 Event.xany.window = chwin;
2850 else if(
Event.xbutton.subwindow
2858 if(
Scr->ClickToFocus &&
Tmp_win->wmhints->input) {
2863 (
Tmp_win ==
Scr->workSpaceMgr.occupyWindow->twm_win)) {
2867 else if(
Tmp_win->iconmanagerlist) {
2868 if((
Event.xany.window ==
Tmp_win->iconmanagerlist->icon) ||
2870 Tmp_win->iconmanagerlist->down =
true;
2871 if(
Scr->Highlight) {
2884 if(
Event.xany.window ==
Scr->Root) {
2891 XTranslateCoordinates(
dpy,
Scr->Root,
Scr->Root,
2896 if(
Event.xany.window != 0 &&
2901 XTranslateCoordinates(
dpy,
Scr->Root,
Event.xany.window,
2902 x,
y, &
x, &
y, &win);
2903 XTranslateCoordinates(
dpy,
Event.xany.window, win,
2904 x,
y, &
x, &
y, &win);
2906 Event.xany.window = win;
2911 if(
Event.xany.window == 0 ||
2917 XTranslateCoordinates(
dpy,
Scr->Root,
Event.xany.window,
2926 else if(mr != NULL) {
2933 if(
Event.xany.window !=
Scr->InfoWindow.win) {
2954 XUngrabPointer(
dpy, CurrentTime);
2955 XUngrabKeyboard(
dpy, CurrentTime);
2965 for(tmp =
Scr->FuncButtonRoot.next; tmp != NULL; tmp = tmp->
next) {
2966 if((tmp->
num ==
Event.xbutton.button) &&
2985#ifdef EWMH_DESKTOP_ROOT
2988 fprintf(stderr,
"HandleButtonPress: wt_Desktop -> C_WINDOW\n");
2997 if(
Tmp_win ==
Scr->currentvs->wsw->twm_win) {
3002 if(
Tmp_win ==
Scr->workSpaceMgr.occupyWindow->twm_win) {
3005 else if(func == 0 &&
Scr->DefaultFunction.func != 0) {
3006 if(
Scr->DefaultFunction.func == F_MENU) {
3007 do_menu(
Scr->DefaultFunction.menu, (Window) None);
3011 Scr->DefaultFunction.item->action : NULL;
3044 if(ev->type == LeaveNotify) {
3045 if(ev->xcrossing.window == args->
w &&
3046 ev->xcrossing.mode == NotifyNormal) {
3052 (ev->xcrossing.detail == NotifyInferior);
3055 else if(ev->type == EnterNotify) {
3056 if(ev->xcrossing.mode == NotifyUngrab) {
3076 XEnterWindowEvent *ewp = &
Event.xcrossing;
3089 if(ewp->mode == NotifyGrab) {
3097 scanArgs.
w = ewp->window;
3105 if(ewp->window ==
Scr->Root) {
3109 if(!scanArgs.leaves && !scanArgs.enters) {
3112 if(!
Scr->FocusRoot) {
3115 XGetInputFocus(
dpy, &forus_ret, &focus_rev);
3116 if((forus_ret != PointerRoot) && (forus_ret != None)) {
3121 for(vs =
Scr->vScreenList; vs != NULL; vs = vs->
next) {
3122 if(ewp->window == vs->
window) {
3125 Scr->rootx =
Scr->crootx + vs->
x;
3126 Scr->rooty =
Scr->crooty + vs->
y;
3133 Scr->currentvs = vs;
3135 fprintf(stderr,
"entering new vs : %p, 0x%lx, %d, %d, %d, %d\n",
3136 vs,
Scr->Root, vs->
x, vs->
y, vs->
w, vs->
h);
3147 Tmp_win->iconmanagerlist->w != ewp->window)) {
3149 static struct timeval tout, timeout = {0, 12500};
3152 (XPointer *)&cwin) == XCNOENT) {
3156 if((ewp->detail != NotifyInferior
3157 ||
Tmp_win->frame == ewp->window)
3158 && (!cwin || cwin->
visibility != VisibilityUnobscured)) {
3159 int x,
y, px, py, d, i;
3162 XQueryPointer(
dpy,
Scr->Root, &w, &w, &px, &py,
3163 &d, &d, (
unsigned int *)&d);
3172 select(0, NULL, NULL, NULL, &tout);
3174 scanArgs.w = ewp->window;
3175 scanArgs.leaves = scanArgs.enters = False;
3177 (
void *) &scanArgs);
3178 if(scanArgs.leaves && !scanArgs.inferior) {
3182 XQueryPointer(
dpy,
Scr->Root, &w, &w, &
x, &
y,
3183 &d, &d, (
unsigned int *)&d);
3189 if(
x != px ||
y != py) {
3202 scanArgs.w = ewp->window;
3203 scanArgs.leaves = scanArgs.enters = False;
3210 if(ewp->window ==
Scr->Root) {
3211 if(!scanArgs.leaves && !scanArgs.enters) {
3227 if(
Scr->FocusRoot && (!scanArgs.leaves || scanArgs.inferior)) {
3230 if(
Scr->ShrinkIconTitles &&
3232 ewp->window ==
Tmp_win->icon->w &&
3233 ewp->detail != NotifyInferior) {
3234 if(
Scr->AutoRaiseIcons) {
3241 if(
Tmp_win->iconmanagerlist) {
3246 if(
Tmp_win->iconmanagerlist &&
3247 ewp->window ==
Tmp_win->iconmanagerlist->w &&
3249 Tmp_win->iconmanagerlist->iconmgr &&
3250 Tmp_win->iconmanagerlist->iconmgr->twm_win) {
3272 if(
Scr->BorderCursors && ewp->window ==
Tmp_win->frame) {
3275 if(ewp->window ==
Tmp_win->frame ||
3276 (
Scr->IconManagerFocus &&
3278 ewp->window ==
Tmp_win->iconmanagerlist->w)) {
3280 if(!scanArgs.leaves && !scanArgs.enters) {
3282 &
Scr->RootColormaps);
3301 if(
Scr->TitleFocus ||
3303 (
Tmp_win->iconmanagerlist->w == ewp->window))) {
3308 if(
Scr->TitleFocus &&
3314 else if(!
Scr->TitleFocus
3316 &&
Event.xcrossing.focus) {
3321 else if(ewp->window ==
Tmp_win->w) {
3326 if(
Scr->BorderCursors) {
3329 if(!scanArgs.leaves || scanArgs.inferior) {
3333 if(
Event.xcrossing.focus) {
3340 if(!(
Scr->TitleFocus) &&
3356 if(ewp->window ==
Tmp_win->wmhints->icon_window &&
3357 (!scanArgs.leaves || scanArgs.inferior)) {
3361 else if(
Scr->BorderCursors && (ewp->window ==
Tmp_win->w)) {
3390 if(XFindContext(
dpy, ewp->window,
MenuContext, (XPointer *)&mr) != XCSUCCESS) {
3427 int i,
x,
y, x_root, y_root, entry;
3433 entry =
y /
Scr->EntryHeight;
3434 for(i = 0, mi =
ActiveMenu->first; mi != NULL; i++, mi = mi->
next) {
3447 XUngrabPointer(
dpy, CurrentTime);
3477 if(ev->type == EnterNotify && ev->xcrossing.mode != NotifyGrab) {
3479 if(ev->xcrossing.window == args->
w) {
3514 if(
Event.xcrossing.mode != NotifyNormal) {
3518 if(
Scr->ShrinkIconTitles &&
3521 Event.xcrossing.detail != NotifyInferior) {
3528 inicon = (
Tmp_win->iconmanagerlist &&
3529 Tmp_win->iconmanagerlist->w ==
Event.xcrossing.window);
3532 (
Event.xcrossing.detail != NotifyInferior &&
3536 "HandleLeaveNotify: Event.xcrossing.window %x != Tmp_win->w %x\n",
3541 Tmp_win->ring.cursor_valid =
false;
3543 fprintf(stderr,
"HandleLeaveNotify: cursor_valid = false\n");
3547 Tmp_win->ring.cursor_valid =
true;
3554 "HandleLeaveNotify: cursor_valid = true; x = %d (%d-%d), y = %d (%d-%d)\n",
3560 Scr->RingLeader = NULL;
3599 &&
Event.xcrossing.detail != NotifyInferior
3600 &&
Event.xcrossing.detail != NotifyVirtual
3601 &&
Event.xcrossing.detail != NotifyNonlinearVirtual
3610 scanArgs.
w =
Event.xcrossing.window;
3613 (
char *) &scanArgs);
3615 if((inicon &&
Scr->IconManagerFocus)
3644 if(
Event.xcrossing.focus) {
3683 int x,
y, width, height, bw;
3685 XConfigureRequestEvent *cre = &
Event.xconfigurerequest;
3689 fprintf(stderr,
"ConfigureRequest\n");
3690 if(cre->value_mask & CWX) {
3691 fprintf(stderr,
" x = %d\n", cre->x);
3693 if(cre->value_mask & CWY) {
3694 fprintf(stderr,
" y = %d\n", cre->y);
3696 if(cre->value_mask & CWWidth) {
3697 fprintf(stderr,
" width = %d\n", cre->width);
3699 if(cre->value_mask & CWHeight) {
3700 fprintf(stderr,
" height = %d\n", cre->height);
3702 if(cre->value_mask & CWSibling) {
3703 fprintf(stderr,
" above = 0x%x\n", (
unsigned)cre->above);
3705 if(cre->value_mask & CWStackMode) {
3706 fprintf(stderr,
" stack = %d\n", cre->detail);
3714 Event.xany.window = cre->window;
3724 xwcm = cre->value_mask &
3725 (CWX | CWY | CWWidth | CWHeight | CWBorderWidth);
3728 xwc.width = cre->width;
3729 xwc.height = cre->height;
3730 xwc.border_width = cre->border_width;
3731 XConfigureWindow(
dpy,
Event.xany.window, xwcm, &xwc);
3736 if((cre->value_mask & CWStackMode) &&
Tmp_win->stackmode) {
3739 if(cre->value_mask & CWSibling) {
3745 fprintf(stderr,
"XConfigureRequest: unkown otherwin\n");
3749 switch(cre->detail) {
3773 height =
Tmp_win->frame_height;
3788 if(cre->value_mask & CWBorderWidth) {
3789 int bwdelta = cre->border_width -
Tmp_win->old_bw;
3790 if(bwdelta &&
Scr->ClientBorderWidth) {
3791 x += gravx * bwdelta;
3792 y += gravy * bwdelta;
3793 bw = cre->border_width;
3797 x += (gravx < 0) ? bwdelta : -bwdelta;
3798 y += (gravy < 0) ? bwdelta : -bwdelta;
3800 Tmp_win->old_bw = cre->border_width;
3803 if((cre->value_mask & CWX)) {
3805 x -= ((gravx < 0) ? 0 :
Tmp_win->frame_bw3D);
3807 if((cre->value_mask & CWY)) {
3808 y = cre->y - ((gravy < 0) ? 0 :
Tmp_win->title_height) - bw;
3809 y -= ((gravy < 0) ? 0 :
Tmp_win->frame_bw3D);
3812 if(cre->value_mask & CWWidth) {
3813 width = cre->width + 2 *
Tmp_win->frame_bw3D;
3815 if(cre->value_mask & CWHeight) {
3816 height = cre->height +
Tmp_win->title_height + 2 *
Tmp_win->frame_bw3D;
3819 if(width !=
Tmp_win->frame_width || height !=
Tmp_win->frame_height) {
3839 fprintf(stderr,
"SetupFrame(x=%d, y=%d, width=%d, height=%d, bw=%d)\n",
3840 x,
y, width, height, bw);
3856 XShapeEvent *sev = (XShapeEvent *) &
Event;
3861 if(sev->kind != ShapeBounding) {
3864 if(!
Tmp_win->wShaped && sev->shaped) {
3865 XShapeCombineMask(
dpy,
Tmp_win->frame, ShapeClip, 0, 0, None,
3868 Tmp_win->wShaped = sev->shaped;
3881HandleSelectionClear(
void)
3883 XSelectionClearEvent *sev = (XSelectionClearEvent *) &
Event;
3885 if(sev->window ==
Scr->icccm_Window) {
3903 fprintf(stderr,
"HandleUnknown: Event.type = %d\n",
Event.type);
3912 while(XCheckTypedWindowEvent(
dpy, w, Expose, &dummy)) {
TwmWindow * AddWindow(Window w, AWType wtype, IconMgr *iconp, VirtualScreen *vs)
void set_last_window(WorkSpace *current)
void FetchWmColormapWindows(TwmWindow *tmp)
bool InstallWindowColormaps(int type, TwmWindow *tmp)
void free_cwins(TwmWindow *tmp)
void RemoveRGBColormap(Atom a)
bool InstallColormaps(int type, Colormaps *cmaps)
void UninstallRootColormap(void)
TwmColormap * CreateTwmColormap(Colormap c)
void InsertRGBColormap(Atom a, XStandardColormap *maps, int nmaps, bool replace)
bool RestartPreviousState
#define FB(fix_fore, fix_back)
void RestoreWinConfig(TwmWindow *tmp)
Put a window back where it should be if we don't (any longer) control it and reparent it back up to t...
event_proc EventHandler[256]
void HandleVisibilityNotify(void)
void HandleKeyRelease(void)
void HandleEnterNotify(void)
void HandleUnmapNotify(void)
static unsigned int set_mask_ignore(unsigned int modifier)
static void HandleFocusOut(void)
void HandleMapRequest(void)
void HandleClientMessage(void)
void HandleConfigureRequest(void)
void HandlePropertyNotify(void)
void HandleFocusChange(void)
void HandleCreateNotify(void)
static void HandleFocusIn(void)
static XEvent * LastFocusEvent(Window w, XEvent *first)
void HandleMapNotify(void)
static void flush_expose(Window w)
static void SendTakeFocusMessage(TwmWindow *tmp, Time timestamp)
void HandleDestroyNotify(void)
void HandleCirculateNotify(void)
static void remove_window_from_ring(TwmWindow *tmp)
void HandleKeyPress(void)
static void do_menu(MenuRoot *menu, Window w)
void HandleLeaveNotify(void)
void HandleButtonRelease(void)
void HandleShapeNotify(void)
void HandleButtonPress(void)
static TwmWindow * ButtonWindow
void HandleColormapNotify(void)
static void do_key_menu(MenuRoot *menu, Window w)
void HandleMotionNotify(void)
static Bool HENQueueScanner(Display *display, XEvent *ev, char *_args)
static Bool HLNQueueScanner(Display *display, XEvent *ev, char *_args)
void SynthesiseFocusOut(Window w)
void SetRaiseWindow(TwmWindow *tmp)
void SynthesiseFocusIn(Window w)
void AutoLowerWindow(TwmWindow *tmp)
void AutoPopupMaybe(TwmWindow *tmp)
void FixRootEvent(XEvent *e)
void AutoRaiseWindow(TwmWindow *tmp)
void EwmhUnmapNotify(TwmWindow *twm_win)
bool EwmhClientMessage(XClientMessageEvent *msg)
void EwmhSelectionClear(XSelectionClearEvent *sev)
int EwmhHandlePropertyNotify(XPropertyEvent *event, TwmWindow *twm_win)
void EwmhAddClientWindow(TwmWindow *new_win)
void EwmhDeleteClientWindow(TwmWindow *old_win)
void EwmhSet_NET_WM_STATE(TwmWindow *twm_win, int changes)
void EwmhSet_NET_CLIENT_LIST_STACKING(void)
void ExecuteFunction(int func, void *action, Window w, TwmWindow *tmp_win, XEvent *eventp, int context, bool pulldown)
void draw_info_window(void)
Window frame
The X window for the overall frame.
void DrawIconManagerBorder(WList *tmp, bool fill)
void RemoveIconManager(TwmWindow *tmp_win)
void ShowIconifiedIcon(TwmWindow *tmp_win)
void CurrentIconManagerEntry(WList *current)
void DrawIconManagerIconName(TwmWindow *tmp_win)
WList * AddIconManager(TwmWindow *tmp_win)
void ReleaseIconImage(Icon *icon)
void DeleteIcon(Icon *icon)
void DeleteIconsList(TwmWindow *tmp_win)
void RedoIconName(TwmWindow *win)
void ExpandIconTitle(TwmWindow *tmp_win)
void IconDown(TwmWindow *tmp_win)
void ShrinkIconTitle(TwmWindow *tmp_win)
void PaintIcon(TwmWindow *tmp_win)
int GetIconOffset(Icon *icon)
void * LookInList(name_list *list_head, const char *name, XClassHint *class)
void OccupyHandleButtonEvent(XEvent *event)
void RemoveFromWorkSpace(char *wname, TwmWindow *twm_win)
unsigned int GetMaskFromProperty(unsigned char *_prop, unsigned long len)
void PaintOccupyWindow(void)
void AddToWorkSpace(char *wname, TwmWindow *twm_win)
void ChangeOccupation(TwmWindow *tmp_win, int newoccupation)
void OtpUnfocusWindow(TwmWindow *twm_win)
Unfocus a window.
void OtpHandleCirculateNotify(VirtualScreen *vs, TwmWindow *twm_win, WinType wintype, int place)
void OtpLower(TwmWindow *twm_win, WinType wintype)
void OtpFocusWindow(TwmWindow *twm_win)
Focus a window.
void OtpRemove(TwmWindow *twm_win, WinType wintype)
void OtpForcePlacement(TwmWindow *twm_win, int where, TwmWindow *other_win)
bool OtpIsFocusDependent(TwmWindow *twm_win)
void OtpRaise(TwmWindow *twm_win, WinType wintype)
void OtpRaiseLower(TwmWindow *twm_win, WinType wintype)
Info and control for every X Window we take over.
Window w
The actual X Window handle.
struct Icon * icon
The current icon.
struct VirtualScreen * next
struct WorkSpaceWindow * wsw
void SetBorderCursor(TwmWindow *tmp_win, int x, int y)
void PaintTitle(TwmWindow *tmp_win)
void SetFrameShape(TwmWindow *tmp)
void PaintTitleButton(TwmWindow *tmp_win, TBWindow *tbw)
void SetupWindow(TwmWindow *tmp_win, int x, int y, int w, int h, int bw)
void PaintBorders(TwmWindow *tmp_win, bool focus)
void SetupFrame(TwmWindow *tmp_win, int x, int y, int w, int h, int bw, bool sendEvent)
void DeleteHighlightWindows(TwmWindow *tmp_win)
void Iconify(TwmWindow *tmp_win, int def_x, int def_y)
void DeIconify(TwmWindow *tmp_win)
void Squeeze(TwmWindow *tmp_win)
void SetFocusVisualAttributes(TwmWindow *tmp_win, bool focus)
void SetFocus(TwmWindow *tmp_win, Time tim)
void MoveOutline(Window root, int x, int y, int width, int height, int bw, int th)
void AutoSqueeze(TwmWindow *tmp_win)
void RemoveWindowFromRegion(TwmWindow *tmp_win)
void unzoom(TwmWindow *tmp_win)
void DoResize(int x_root, int y_root, TwmWindow *tmp_win)
void UnlinkWindowFromRing(TwmWindow *win)
#define WindowIsOnRing(win)
void apply_window_icon_name(TwmWindow *win)
[Re]set and apply changes to a window's icon name.
void GetWindowSizeHints(TwmWindow *tmp)
void send_clientmessage(Window w, Atom a, Time timestamp)
XWMHints * munge_wmhints(TwmWindow *win, XWMHints *hints)
Perform whatever adaptations of WM_HINTS info we do.
void FreeWMPropertyString(char *prop)
bool GetWMState(Window w, int *statep, Window *iwp)
TwmWindow * GetTwmWindow(Window w)
void ConstrainByBorders(TwmWindow *twmwin, int *left, int width, int *top, int height)
void FetchWmProtocols(TwmWindow *tmp)
void SetMapStateProp(TwmWindow *tmp_win, int state)
void TryToPush(TwmWindow *tmp_win, int x, int y)
void apply_window_name(TwmWindow *win)
[Re]set and apply changes to a window's name.
void TryToGrid(TwmWindow *tmp_win, int *x, int *y)
void TryToPack(TwmWindow *tmp_win, int *x, int *y)
char * GetWMPropertyString(Window w, Atom prop)
void GetGravityOffsets(TwmWindow *tmp, int *xp, int *yp)
void WMapRemoveWindow(TwmWindow *win)
void WMgrHandleKeyPressEvent(VirtualScreen *vs, XEvent *event)
void WMapMapWindow(TwmWindow *win)
void WMapRaise(TwmWindow *win)
void WMgrHandleExposeEvent(VirtualScreen *vs, XEvent *event)
void WMgrHandleKeyReleaseEvent(VirtualScreen *vs, XEvent *event)
void WMgrHandleButtonEvent(VirtualScreen *vs, XEvent *event)
void GotoWorkSpaceByName(VirtualScreen *vs, const char *wname)