261 XRectangle ink_rect, logical_rect;
263 &ink_rect, &logical_rect);
265 y_offset = mi->
item_num *
Scr->EntryHeight +
Scr->MenuShadowDepth;
266 text_y = y_offset + (
Scr->EntryHeight - logical_rect.height) / 2
269 if(mi->
func != F_TITLE) {
275 mr->
width - 2 *
Scr->MenuShadowDepth,
Scr->EntryHeight, 1,
278 XmbDrawImageString(
dpy, mr->
w,
Scr->MenuFont.font_set, gc,
284 XFillRectangle(
dpy, mr->
w, gc,
285 Scr->MenuShadowDepth, y_offset,
286 mr->
width - 2 *
Scr->MenuShadowDepth,
Scr->EntryHeight);
292 XmbDrawImageString(
dpy, mr->
w,
Scr->MenuFont.font_set, gc,
293 mi->
x +
Scr->MenuShadowDepth, text_y,
296 FB(
Scr->MenuC.shadd,
Scr->MenuC.shadc);
297 XDrawLine(
dpy, mr->
w,
Scr->NormalGC,
298 Scr->MenuShadowDepth,
299 y_offset +
Scr->EntryHeight - 2,
301 y_offset +
Scr->EntryHeight - 2);
302 FB(
Scr->MenuC.shadc,
Scr->MenuC.shadd);
303 XDrawLine(
dpy, mr->
w,
Scr->NormalGC,
304 Scr->MenuShadowDepth,
305 y_offset +
Scr->EntryHeight - 1,
307 y_offset +
Scr->EntryHeight - 1);
311 if(mi->
func == F_MENU) {
313 if(
Scr->pullPm == None) {
319 XCopyArea(
dpy,
Scr->pullPm, mr->
w, gc, 0, 0,
Scr->pullW,
Scr->pullH,
x,
y);
324 mr->
width - 2 *
Scr->MenuShadowDepth,
Scr->EntryHeight, 1,
327 XmbDrawImageString(
dpy, mr->
w,
Scr->MenuFont.font_set,
Scr->NormalGC,
444 static char **actions = NULL;
448 if(!
Scr->Workspaces) {
451 AddToMenu(
Scr->Workspaces,
"TWM Workspaces", NULL, NULL, F_TITLE, NULL,
456 for(wlist =
Scr->workSpaceMgr.workSpaceList; wlist != NULL;
457 wlist = wlist->
next) {
461 actions = calloc(count,
sizeof(
char *));
463 for(wlist =
Scr->workSpaceMgr.workSpaceList; wlist != NULL;
464 wlist = wlist->
next) {
465 asprintf(act,
"WGOTO : %s", wlist->
name);
471 for(wlist =
Scr->workSpaceMgr.workSpaceList; wlist != NULL;
472 wlist = wlist->
next) {
476 Scr->Workspaces->pinned =
false;
856 XColor save_fore, save_back;
857 int fred, fgreen, fblue;
858 int bred, bgreen, bblue;
859 int width, borderwidth;
860 unsigned long valuemask;
861 XSetWindowAttributes attributes;
862 Colormap cmap =
Scr->RootColormaps.cwins[0]->colormap->c;
864 XRectangle logical_rect;
866 Scr->EntryHeight =
Scr->MenuFont.height + 4;
870 int max_entry_height = 0;
872 if(mr->
pull ==
true) {
873 mr->
width += 16 + 10;
875 width = mr->
width + 10;
877 XmbTextExtents(
Scr->MenuFont.font_set, cur->item, cur->strlen,
878 &ink_rect, &logical_rect);
879 max_entry_height =
MAX(max_entry_height, logical_rect.height);
881 if(cur->func != F_TITLE) {
885 cur->x = width - logical_rect.width;
892 if(
Scr->use3Dmenus) {
893 mr->
width += 2 *
Scr->MenuShadowDepth;
901 valuemask = (CWBackPixel | CWBorderPixel);
902 attributes.background_pixel =
Scr->MenuShadowColor;
903 attributes.border_pixel =
Scr->MenuShadowColor;
905 valuemask |= CWSaveUnder;
906 attributes.save_under = True;
915 valuemask, &attributes);
918 valuemask = (CWBackPixel | CWBorderPixel | CWEventMask);
919 attributes.background_pixel =
Scr->MenuC.back;
920 attributes.border_pixel =
Scr->MenuC.fore;
922 attributes.event_mask = (ExposureMask | EnterWindowMask
923 | LeaveWindowMask | ButtonPressMask
924 | ButtonReleaseMask | PointerMotionMask
927 attributes.cursor =
Scr->MenuCursor;
928 valuemask |= CWCursor;
931 attributes.event_mask = (ExposureMask | EnterWindowMask);
935 valuemask |= CWSaveUnder;
936 attributes.save_under = True;
938 if(
Scr->BackingStore) {
939 valuemask |= CWBackingStore;
940 attributes.backing_store = Always;
942 borderwidth =
Scr->use3Dmenus ? 0 : 1;
945 CopyFromParent, CopyFromParent,
947 valuemask, &attributes);
956 if(
Scr->use3Dmenus && (
Scr->Monochrome == COLOR)
962 xcol.pixel =
Scr->MenuC.back;
963 XQueryColor(
dpy, cmap, &xcol);
964 sprintf(colname,
"#%04x%04x%04x",
965 5 * ((
int)xcol.red / 6),
966 5 * ((
int)xcol.green / 6),
967 5 * ((
int)xcol.blue / 6));
968 save =
Scr->FirstTime;
969 Scr->FirstTime =
true;
971 Scr->FirstTime = save;
974 if(
Scr->use3Dmenus && (
Scr->Monochrome == COLOR)
980 xcol.pixel =
Scr->MenuC.fore;
981 XQueryColor(
dpy, cmap, &xcol);
982 sprintf(colname,
"#%04x%04x%04x",
983 5 * ((
int)xcol.red / 6),
984 5 * ((
int)xcol.green / 6),
985 5 * ((
int)xcol.blue / 6));
986 save =
Scr->FirstTime;
987 Scr->FirstTime =
true;
989 Scr->FirstTime = save;
991 if(
Scr->use3Dmenus && !
Scr->BeNiceToColormap) {
996 for(tmp = mr->
first; tmp != NULL; tmp = tmp->
next) {
998 if(tmp->
func != F_TITLE) {
1016 if(
Scr->use3Dmenus && !
Scr->BeNiceToColormap) {
1017 if(tmp->
func != F_TITLE) {
1027 if(
Scr->Monochrome == MONOCHROME || !
Scr->InterpolateMenuColors) {
1034 for(; start != NULL; start = start->
next) {
1044 for(end = start->
next; end != NULL; end = end->
next) {
1057 XQueryColor(
dpy, cmap, &f1);
1059 XQueryColor(
dpy, cmap, &f2);
1062 XQueryColor(
dpy, cmap, &b1);
1064 XQueryColor(
dpy, cmap, &b2);
1066 fred = ((int)f2.red - (int)f1.red) / num;
1067 fgreen = ((int)f2.green - (int)f1.green) / num;
1068 fblue = ((int)f2.blue - (int)f1.blue) / num;
1070 bred = ((int)b2.red - (int)b1.red) / num;
1071 bgreen = ((int)b2.green - (int)b1.green) / num;
1072 bblue = ((int)b2.blue - (int)b1.blue) / num;
1075 f3.flags = DoRed | DoGreen | DoBlue;
1078 b3.flags = DoRed | DoGreen | DoBlue;
1088 for(; cur != NULL && i < num ; i++, cur = cur->
next) {
1099 XAllocColor(
dpy, cmap, &f3);
1100 XAllocColor(
dpy, cmap, &b3);
1132 int WindowNameCount;
1143 if((menu ==
Scr->Windows) ||
1144 (menu ==
Scr->Icons) ||
1145 (menu ==
Scr->AllWindows) ||
1147 (menu ==
Scr->AllIcons) ||
1149 (menu ==
Scr->Visible)) {
1152 bool all, icons, visible_, allicons;
1158 all = (menu ==
Scr->AllWindows);
1159 icons = (menu ==
Scr->Icons);
1160 visible_ = (menu ==
Scr->Visible);
1161 allicons = (menu ==
Scr->AllIcons);
1171 if(menu ==
Scr->Windows) {
1172 AddToMenu(menu,
"TWM Windows", NULL, NULL, F_TITLE, NULL, NULL);
1174 else if(menu ==
Scr->Icons) {
1175 AddToMenu(menu,
"TWM Icons", NULL, NULL, F_TITLE, NULL, NULL);
1177 else if(menu ==
Scr->Visible) {
1178 AddToMenu(menu,
"TWM Visible", NULL, NULL, F_TITLE, NULL, NULL);
1180 else if(menu ==
Scr->AllIcons) {
1181 AddToMenu(menu,
"TWM All Icons", NULL, NULL, F_TITLE, NULL, NULL);
1184 AddToMenu(menu,
"TWM All Windows", NULL, NULL, F_TITLE, NULL, NULL);
1189 if(!(all || allicons)
1191 for(ws =
Scr->workSpaceMgr.workSpaceList; ws != NULL; ws = ws->
next) {
1197 if(!
Scr->currentvs) {
1201 ws =
Scr->currentvs->wsw->currentwspc;
1204 for(tmp_win =
Scr->FirstWindow, WindowNameCount = 0;
1206 tmp_win = tmp_win->
next) {
1207 if(tmp_win ==
Scr->workSpaceMgr.occupyWindow->twm_win) {
1214 if(!(all || allicons) && !
OCCUPY(tmp_win, ws)) {
1217 if(allicons && !tmp_win->
isicon) {
1220 if(icons && !tmp_win->
isicon) {
1223 if(visible_ && tmp_win->
isicon) {
1232 if(WindowNameCount == 0) {
1233 WindowNameCount = 1;
1235 WindowNames = calloc(WindowNameCount,
sizeof(
TwmWindow *));
1237 WindowNameCount = 0;
1238 for(tmp_win =
Scr->FirstWindow;
1240 tmp_win = tmp_win->
next) {
1245 if(tmp_win ==
Scr->workSpaceMgr.occupyWindow->twm_win) {
1248 if(
Scr->ShortAllWindowsMenus &&
1249 tmp_win ==
Scr->currentvs->wsw->twm_win) {
1256 if(!(all || allicons) && !
OCCUPY(tmp_win, ws)) {
1259 if(allicons && !tmp_win->
isicon) {
1262 if(icons && !tmp_win->
isicon) {
1265 if(visible_ && tmp_win->
isicon) {
1270 for(i = 0; i < WindowNameCount; i++) {
1272 char *tmpname1, *tmpname2;
1273 tmpname1 = tmp_win2->
name;
1274 tmpname2 = WindowNames[i]->
name;
1275 if(
Scr->CaseSensitive) {
1276 compresult = strcmp(tmpname1, tmpname2);
1279 compresult = strcasecmp(tmpname1, tmpname2);
1281 if(compresult < 0) {
1282 tmp_win3 = tmp_win2;
1283 tmp_win2 = WindowNames[i];
1284 WindowNames[i] = tmp_win3;
1287 WindowNames[WindowNameCount] = tmp_win2;
1292 for(i = 0; i < WindowNameCount; i++) {
1294 tmpname = WindowNames[i]->
name;
1295 AddToMenu(menu, tmpname, (
char *)WindowNames[i],
1296 NULL, func, NULL, NULL);
1306 if(menu ==
Scr->Keys) {
1320 AddToMenu(menu,
"Twm Keys", NULL, NULL, F_TITLE, NULL, NULL);
1322 for(
const FuncKey *tmpKey =
Scr->FuncKeyRoot.next; tmpKey != NULL;
1323 tmpKey = tmpKey->next) {
1326 if(tmpKey->func != F_EXEC) {
1329 if((tmpKey->action == oldact) && (tmpKey->mods == oldmod)) {
1334 if(tmpStr == NULL) {
1335 tmpStr = strdup(
"(error)");
1338 AddToMenu(menu, tmpStr, tmpKey->action, NULL, tmpKey->func, NULL, NULL);
1339 oldact = tmpKey->action;
1340 oldmod = tmpKey->mods;
1345 if(menu->
w == None || menu->
items == 0) {
1368 XRaiseWindow(
dpy, menu->
w);
1372 XGrabPointer(
dpy,
Scr->Root, True,
1373 ButtonPressMask | ButtonReleaseMask | PointerMotionMask |
1374 ButtonMotionMask | PointerMotionHintMask,
1375 GrabModeAsync, GrabModeAsync,
1377 Scr->MenuCursor, CurrentTime);
1379 XGrabKeyboard(
dpy,
Scr->Root, True, GrabModeAsync, GrabModeAsync, CurrentTime);
1387 y -= (
Scr->EntryHeight / 2);
1412 XMoveWindow(
dpy, menu->
w,
x,
y);
1413 XMapRaised(
dpy, menu->
w);
1420 if(!
Scr->NoWarpToMenuTitle && clipped && center) {
1421 const int xl =
x + (menu->
width / 2);
1422 const int yt =
y + (
Scr->EntryHeight / 2);
1540 int XW, YW, newX, newY;
1543 unsigned long event_mask;
1556 ButtonPressMask | ButtonReleaseMask | ButtonMotionMask,
1557 GrabModeAsync, GrabModeAsync,
1558 None,
Scr->MoveCursor, CurrentTime);
1563 event_mask = ButtonPressMask | ButtonMotionMask | ButtonReleaseMask |
1565 XMaskEvent(
dpy, event_mask, &ev);
1567 ev.xbutton.x_root -=
Scr->rootx;
1568 ev.xbutton.y_root -=
Scr->rooty;
1569 switch(ev.xany.type) {
1570 case ButtonRelease :
1575 while(XCheckMaskEvent(
dpy, ButtonMotionMask | ButtonReleaseMask, &ev)) {
1577 if(ev.type == ButtonRelease) {
1581 if(ev.type == ButtonRelease) {
1585 ev.xbutton.x_root -=
Scr->rootx;
1586 ev.xbutton.y_root -=
Scr->rooty;
1589 newX = ev.xbutton.x_root - XW;
1590 newY = ev.xbutton.y_root - YW;
1591 if(
Scr->DontMoveOff) {
1596 XMaskEvent(
dpy, event_mask, &ev);
1607 XMaskEvent(
dpy, event_mask, &ev);
1611 XUngrabPointer(
dpy, CurrentTime);
1612 if(ev.xany.type == ButtonRelease) {
void Draw3DBorder(Window w, int x, int y, int width, int height, int bw, ColorPair cp, ButtonState state, bool fill, bool forcebw)