static Pixmap makePixmap(WMScreen * scr, int width, int height, int side, Pixmap * mask) { Display *dpy = WMScreenDisplay(scr); Pixmap bitmap; Pixmap pixmap; int x, y; WMColor *black = WMBlackColor(scr); bitmap = XCreatePixmap(dpy, scr->rootWin, width + SPACE, height + SPACE, 1); XSetForeground(dpy, scr->monoGC, 0); XFillRectangle(dpy, bitmap, scr->monoGC, 0, 0, width + SPACE, height + SPACE); pixmap = XCreatePixmap(dpy, scr->rootWin, width + SPACE, height + SPACE, scr->depth); XFillRectangle(dpy, pixmap, WMColorGC(black), 0, 0, width + SPACE, height + SPACE); if (side & BOTTOM) { y = 0; } else { y = SPACE; } x = 0; drawBalloon(scr, bitmap, pixmap, x, y, width, height, side); *mask = bitmap; WMReleaseColor(black); return pixmap; }
static void sgrabClicked(WMWidget * w, void *data) { _Panel *panel = (_Panel *) data; Display *dpy = WMScreenDisplay(WMWidgetScreen(panel->parent)); char *shortcut; if (w == panel->sclearB) { WMSetTextFieldText(panel->shortT, ""); updateMenuItem(panel, panel->currentItem, panel->shortT); return; } if (!panel->capturing) { panel->capturing = 1; WMSetButtonText(w, _("Cancel")); XGrabKeyboard(dpy, WMWidgetXID(panel->parent), True, GrabModeAsync, GrabModeAsync, CurrentTime); shortcut = capture_shortcut(dpy, &panel->capturing, 0); if (shortcut) { WMSetTextFieldText(panel->shortT, shortcut); updateMenuItem(panel, panel->currentItem, panel->shortT); wfree(shortcut); } } panel->capturing = 0; WMSetButtonText(w, _("Capture")); XUngrabKeyboard(dpy, CurrentTime); }
void ResetGame(void) { int i, x, y, ox, oy; MoveCount = 0; for (i = 0; i < Size*Size-1; i++) { Map[i] = i; } Map[i] = -1; ox = x = Size-1; oy = y = Size-1; for (i = 0; i < 5; i++) { int ok; ok = 1; switch (rand()%4) { case 0: if (x > 0) x--; else ok = 0; break; case 2: if (x < Size-1) x++; else ok = 0; break; case 1: if (y > 0) y--; else ok = 0; break; case 3: if (y < Size-1) y++; else ok = 0; break; } if (ok) { MoveButton(MAP(x,y), ox, oy); SWAP(MAP(ox, oy), MAP(x, y)); while (XPending(WMScreenDisplay(WMWidgetScreen(win)))) { XEvent ev; WMNextEvent(WMScreenDisplay(WMWidgetScreen(win)), &ev); WMHandleEvent(&ev); } ox = x; oy = y; } } }
static void setMouseAccel(WMScreen * scr, float accel, int threshold) { int n, d; d = 10; n = accel * d; XChangePointerControl(WMScreenDisplay(scr), True, True, n, d, threshold); }
static pid_t downloadFile(WMScreen * scr, _Panel * panel, const char *file) { pid_t pid; pid = fork(); if (pid < 0) { werror("could not fork() process"); WMRunAlertPanel(scr, GetWindow(panel), _("Error"), "Could not start download. fork() failed", _("OK"), NULL, NULL); return -1; } if (pid != 0) { return pid; } close(ConnectionNumber(WMScreenDisplay(scr))); exit(1); }
static void paintItem(WMList *lPtr, int index, Drawable d, char *text, int state, WMRect *rect) { int width, height, x, y; _Panel *panel = (_Panel*)WMGetHangedData(lPtr); WMScreen *scr = WMWidgetScreen(lPtr); Display *dpy = WMScreenDisplay(scr); WMColor *backColor = (state & WLDSSelected) ? panel->white : panel->gray; width = rect->size.width; height = rect->size.height; x = rect->pos.x; y = rect->pos.y; XFillRectangle(dpy, d, WMColorGC(backColor), x, y, width, height); if (state & 1) { WMDrawString(scr, d, panel->red, panel->font, x+4, y, text, strlen(text)); } else { WMDrawString(scr, d, panel->black, panel->font, x+4, y, text, strlen(text)); } }
static void createPanel(_Panel * p) { _Panel *panel = (_Panel *) p; WMScreen *scr = WMWidgetScreen(panel->parent); WMColor *black = WMBlackColor(scr); WMColor *white = WMWhiteColor(scr); WMColor *gray = WMGrayColor(scr); WMFont *bold = WMBoldSystemFontOfSize(scr, 12); WMFont *font = WMSystemFontOfSize(scr, 12); WMLabel *label; int width; menuDelegate.data = panel; panel->boldFont = bold; panel->normalFont = font; panel->black = black; panel->white = white; panel->gray = gray; { Pixmap pix; Display *dpy = WMScreenDisplay(scr); GC gc; WMPixmap *pixm; pixm = WMCreatePixmap(scr, 7, 7, WMScreenDepth(scr), True); pix = WMGetPixmapXID(pixm); XDrawLine(dpy, pix, WMColorGC(black), 0, 3, 6, 3); XDrawLine(dpy, pix, WMColorGC(black), 3, 0, 3, 6); /* XDrawLine(dpy, pix, WMColorGC(black), 1, 0, 3, 3); XDrawLine(dpy, pix, WMColorGC(black), 1, 6, 3, 3); XDrawLine(dpy, pix, WMColorGC(black), 0, 0, 0, 6); */ pix = WMGetPixmapMaskXID(pixm); gc = XCreateGC(dpy, pix, 0, NULL); XSetForeground(dpy, gc, 0); XFillRectangle(dpy, pix, gc, 0, 0, 7, 7); XSetForeground(dpy, gc, 1); XDrawLine(dpy, pix, gc, 0, 3, 6, 3); XDrawLine(dpy, pix, gc, 3, 0, 3, 6); panel->markerPix[ExternalInfo] = pixm; panel->markerPix[PipeInfo] = pixm; panel->markerPix[PLPipeInfo] = pixm; panel->markerPix[DirectoryInfo] = pixm; panel->markerPix[WSMenuInfo] = pixm; panel->markerPix[WWindowListInfo] = pixm; XFreeGC(dpy, gc); } panel->box = WMCreateBox(panel->parent); WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2); panel->typeP = WMCreatePopUpButton(panel->box); WMResizeWidget(panel->typeP, 150, 20); WMMoveWidget(panel->typeP, 10, 10); WMAddPopUpButtonItem(panel->typeP, _("New Items")); WMAddPopUpButtonItem(panel->typeP, _("Sample Commands")); WMAddPopUpButtonItem(panel->typeP, _("Sample Submenus")); WMSetPopUpButtonAction(panel->typeP, changedItemPad, panel); WMSetPopUpButtonSelectedItem(panel->typeP, 0); { WEditMenu *pad; pad = makeFactoryMenu(panel->box, 150); WMMoveWidget(pad, 10, 40); putNewItem(panel, pad, ExecInfo, _("Run Program")); putNewItem(panel, pad, CommandInfo, _("Internal Command")); putNewSubmenu(pad, _("Submenu")); putNewItem(panel, pad, ExternalInfo, _("External Submenu")); putNewItem(panel, pad, PipeInfo, _("Generated Submenu")); putNewItem(panel, pad, PLPipeInfo, _("Generated PL Menu")); putNewItem(panel, pad, DirectoryInfo, _("Directory Contents")); putNewItem(panel, pad, WSMenuInfo, _("Workspace Menu")); putNewItem(panel, pad, WWindowListInfo, _("Window List Menu")); panel->itemPad[0] = pad; } { WEditMenu *pad; ItemData *data; WMScrollView *sview; sview = WMCreateScrollView(panel->box); WMResizeWidget(sview, 150, 180); WMMoveWidget(sview, 10, 40); WMSetScrollViewHasVerticalScroller(sview, True); pad = makeFactoryMenu(panel->box, 130); WMSetScrollViewContentView(sview, WMWidgetView(pad)); data = putNewItem(panel, pad, ExecInfo, _("XTerm")); data->param.exec.command = "xterm -sb -sl 2000 -bg black -fg white"; data = putNewItem(panel, pad, ExecInfo, _("rxvt")); data->param.exec.command = "rxvt"; data = putNewItem(panel, pad, ExecInfo, _("ETerm")); data->param.exec.command = "eterm"; data = putNewItem(panel, pad, ExecInfo, _("Run...")); data->param.exec.command = _("%A(Run,Type command to run)"); data = putNewItem(panel, pad, ExecInfo, _("Firefox")); data->param.exec.command = "firefox"; data = putNewItem(panel, pad, ExecInfo, _("gimp")); data->param.exec.command = "gimp"; data = putNewItem(panel, pad, ExecInfo, _("epic")); data->param.exec.command = "xterm -e epic"; data = putNewItem(panel, pad, ExecInfo, _("ee")); data->param.exec.command = "ee"; data = putNewItem(panel, pad, ExecInfo, _("xv")); data->param.exec.command = "xv"; data = putNewItem(panel, pad, ExecInfo, _("Evince")); data->param.exec.command = "evince"; data = putNewItem(panel, pad, ExecInfo, _("ghostview")); data->param.exec.command = "gv"; data = putNewItem(panel, pad, CommandInfo, _("Exit Window Maker")); data->param.command.command = 3; WMMapWidget(pad); panel->itemPad[1] = sview; } { WEditMenu *pad, *smenu; ItemData *data; WMScrollView *sview; sview = WMCreateScrollView(panel->box); WMResizeWidget(sview, 150, 180); WMMoveWidget(sview, 10, 40); WMSetScrollViewHasVerticalScroller(sview, True); pad = makeFactoryMenu(panel->box, 130); WMSetScrollViewContentView(sview, WMWidgetView(pad)); data = putNewItem(panel, pad, ExternalInfo, _("Debian Menu")); data->param.pipe.command = "/etc/GNUstep/Defaults/menu.hook"; data = putNewItem(panel, pad, PipeInfo, _("RedHat Menu")); data->param.pipe.command = "wmconfig --output wmaker"; data = putNewItem(panel, pad, PipeInfo, _("Menu Conectiva")); data->param.pipe.command = "wmconfig --output wmaker"; data = putNewItem(panel, pad, DirectoryInfo, _("Themes")); data->param.directory.command = "setstyle"; data->param.directory.directory = "/usr/share/WindowMaker/Themes /usr/local/share/WindowMaker/Themes $HOME/GNUstep/Library/WindowMaker/Themes"; data->param.directory.stripExt = 1; data = putNewItem(panel, pad, DirectoryInfo, _("Bg Images (scale)")); data->param.directory.command = "wmsetbg -u -s"; data->param.directory.directory = "/opt/kde2/share/wallpapers /usr/share/WindowMaker/Backgrounds $HOME/GNUstep/Library/WindowMaker/Backgrounds"; data->param.directory.stripExt = 1; data = putNewItem(panel, pad, DirectoryInfo, _("Bg Images (tile)")); data->param.directory.command = "wmsetbg -u -t"; data->param.directory.directory = "/opt/kde2/share/wallpapers /usr/share/WindowMaker/Backgrounds $HOME/GNUstep/Library/WindowMaker/Backgrounds"; data->param.directory.stripExt = 1; smenu = putNewSubmenu(pad, _("Assorted XTerms")); data = putNewItem(panel, smenu, ExecInfo, _("XTerm Yellow on Blue")); data->param.exec.command = "xterm -sb -sl 2000 -bg midnightblue -fg yellow"; data = putNewItem(panel, smenu, ExecInfo, _("XTerm White on Black")); data->param.exec.command = "xterm -sb -sl 2000 -bg black -fg white"; data = putNewItem(panel, smenu, ExecInfo, _("XTerm Black on White")); data->param.exec.command = "xterm -sb -sl 2000 -bg white -fg black"; data = putNewItem(panel, smenu, ExecInfo, _("XTerm Black on Beige")); data->param.exec.command = "xterm -sb -sl 2000 -bg '#bbbb99' -fg black"; data = putNewItem(panel, smenu, ExecInfo, _("XTerm White on Green")); data->param.exec.command = "xterm -sb -sl 2000 -bg '#228822' -fg white"; data = putNewItem(panel, smenu, ExecInfo, _("XTerm White on Olive")); data->param.exec.command = "xterm -sb -sl 2000 -bg '#335533' -fg white"; data = putNewItem(panel, smenu, ExecInfo, _("XTerm Blue on Blue")); data->param.exec.command = "xterm -sb -sl 2000 -bg '#112244' -fg '#88aabb'"; data = putNewItem(panel, smenu, ExecInfo, _("XTerm BIG FONTS")); data->param.exec.command = "xterm -sb -sl 2000 -bg black -fg white -fn 10x20"; WMMapWidget(pad); panel->itemPad[2] = sview; } width = FRAME_WIDTH - 20 - 150 - 10 - 2; panel->optionsF = WMCreateFrame(panel->box); WMResizeWidget(panel->optionsF, width, FRAME_HEIGHT - 15); WMMoveWidget(panel->optionsF, 10 + 150 + 10, 5); width -= 20; /* command */ panel->commandF = WMCreateFrame(panel->optionsF); WMResizeWidget(panel->commandF, width, 50); WMMoveWidget(panel->commandF, 10, 20); WMSetFrameTitle(panel->commandF, _("Program to Run")); WMSetFrameTitlePosition(panel->commandF, WTPAtTop); panel->commandT = WMCreateTextField(panel->commandF); WMResizeWidget(panel->commandT, width - 95, 20); WMMoveWidget(panel->commandT, 10, 20); panel->browseB = WMCreateCommandButton(panel->commandF); WMResizeWidget(panel->browseB, 70, 24); WMMoveWidget(panel->browseB, width - 80, 18); WMSetButtonText(panel->browseB, _("Browse")); WMSetButtonAction(panel->browseB, browseForFile, panel); WMAddNotificationObserver(dataChanged, panel, WMTextDidChangeNotification, panel->commandT); #if 0 panel->xtermC = WMCreateSwitchButton(panel->commandF); WMResizeWidget(panel->xtermC, width - 20, 20); WMMoveWidget(panel->xtermC, 10, 50); WMSetButtonText(panel->xtermC, _("Run the program inside a Xterm")); #endif WMMapSubwidgets(panel->commandF); /* path */ panel->pathF = WMCreateFrame(panel->optionsF); WMResizeWidget(panel->pathF, width, 150); WMMoveWidget(panel->pathF, 10, 40); WMSetFrameTitle(panel->pathF, _("Path for Menu")); panel->pathT = WMCreateTextField(panel->pathF); WMResizeWidget(panel->pathT, width - 20, 20); WMMoveWidget(panel->pathT, 10, 20); WMAddNotificationObserver(dataChanged, panel, WMTextDidChangeNotification, panel->pathT); label = WMCreateLabel(panel->pathF); WMResizeWidget(label, width - 20, 80); WMMoveWidget(label, 10, 50); WMSetLabelText(label, _("Enter the path for a file containing a menu\n" "or a list of directories with the programs you\n" "want to have listed in the menu. Ex:\n" "~/GNUstep/Library/WindowMaker/menu\n" "or\n" "/usr/bin ~/xbin")); WMMapSubwidgets(panel->pathF); /* pipe */ panel->pipeF = WMCreateFrame(panel->optionsF); WMResizeWidget(panel->pipeF, width, 155); WMMoveWidget(panel->pipeF, 10, 30); WMSetFrameTitle(panel->pipeF, _("Command")); panel->pipeT = WMCreateTextField(panel->pipeF); WMResizeWidget(panel->pipeT, width - 20, 20); WMMoveWidget(panel->pipeT, 10, 20); WMAddNotificationObserver(dataChanged, panel, WMTextDidChangeNotification, panel->pipeT); label = WMCreateLabel(panel->pipeF); WMResizeWidget(label, width - 20, 40); WMMoveWidget(label, 10, 50); WMSetLabelText(label, _("Enter a command that outputs a menu\n" "definition to stdout when invoked.")); panel->pipeCacheB = WMCreateSwitchButton(panel->pipeF); WMResizeWidget(panel->pipeCacheB, width - 20, 40); WMMoveWidget(panel->pipeCacheB, 10, 110); WMSetButtonText(panel->pipeCacheB, _("Cache menu contents after opening for\n" "the first time")); WMMapSubwidgets(panel->pipeF); /* proplist pipe */ panel->plpipeF = WMCreateFrame(panel->optionsF); WMResizeWidget(panel->plpipeF, width, 155); WMMoveWidget(panel->plpipeF, 10, 30); WMSetFrameTitle(panel->plpipeF, _("Command")); panel->plpipeT = WMCreateTextField(panel->plpipeF); WMResizeWidget(panel->plpipeT, width - 20, 20); WMMoveWidget(panel->plpipeT, 10, 20); WMAddNotificationObserver(dataChanged, panel, WMTextDidChangeNotification, panel->plpipeT); label = WMCreateLabel(panel->plpipeF); WMResizeWidget(label, width - 20, 40); WMMoveWidget(label, 10, 50); WMSetLabelText(label, _("Enter a command that outputs a proplist menu\n" "definition to stdout when invoked.")); panel->plpipeCacheB = WMCreateSwitchButton(panel->plpipeF); WMResizeWidget(panel->plpipeCacheB, width - 20, 40); WMMoveWidget(panel->plpipeCacheB, 10, 110); WMSetButtonText(panel->plpipeCacheB, _("Cache menu contents after opening for\n" "the first time")); WMMapSubwidgets(panel->plpipeF); /* directory menu */ panel->dcommandF = WMCreateFrame(panel->optionsF); WMResizeWidget(panel->dcommandF, width, 90); WMMoveWidget(panel->dcommandF, 10, 25); WMSetFrameTitle(panel->dcommandF, _("Command to Open Files")); panel->dcommandT = WMCreateTextField(panel->dcommandF); WMResizeWidget(panel->dcommandT, width - 20, 20); WMMoveWidget(panel->dcommandT, 10, 20); WMAddNotificationObserver(dataChanged, panel, WMTextDidChangeNotification, panel->dcommandT); label = WMCreateLabel(panel->dcommandF); WMResizeWidget(label, width - 20, 45); WMMoveWidget(label, 10, 40); WMSetLabelText(label, _("Enter the command you want to use to open the\n" "files in the directories listed below.")); WMMapSubwidgets(panel->dcommandF); panel->dpathF = WMCreateFrame(panel->optionsF); WMResizeWidget(panel->dpathF, width, 80); WMMoveWidget(panel->dpathF, 10, 125); WMSetFrameTitle(panel->dpathF, _("Directories with Files")); panel->dpathT = WMCreateTextField(panel->dpathF); WMResizeWidget(panel->dpathT, width - 20, 20); WMMoveWidget(panel->dpathT, 10, 20); WMAddNotificationObserver(dataChanged, panel, WMTextDidChangeNotification, panel->dpathT); panel->dstripB = WMCreateSwitchButton(panel->dpathF); WMResizeWidget(panel->dstripB, width - 20, 20); WMMoveWidget(panel->dstripB, 10, 50); WMSetButtonText(panel->dstripB, _("Strip extensions from file names")); WMSetButtonAction(panel->dstripB, buttonClicked, panel); WMMapSubwidgets(panel->dpathF); /* shortcut */ panel->shortF = WMCreateFrame(panel->optionsF); WMResizeWidget(panel->shortF, width, 50); WMMoveWidget(panel->shortF, 10, 160); WMSetFrameTitle(panel->shortF, _("Keyboard Shortcut")); panel->shortT = WMCreateTextField(panel->shortF); WMResizeWidget(panel->shortT, width - 20 - 150, 20); WMMoveWidget(panel->shortT, 10, 20); WMAddNotificationObserver(dataChanged, panel, WMTextDidChangeNotification, panel->shortT); panel->sgrabB = WMCreateCommandButton(panel->shortF); WMResizeWidget(panel->sgrabB, 70, 24); WMMoveWidget(panel->sgrabB, width - 80, 18); WMSetButtonText(panel->sgrabB, _("Capture")); WMSetButtonAction(panel->sgrabB, sgrabClicked, panel); panel->sclearB = WMCreateCommandButton(panel->shortF); WMResizeWidget(panel->sclearB, 70, 24); WMMoveWidget(panel->sclearB, width - 155, 18); WMSetButtonText(panel->sclearB, _("Clear")); WMSetButtonAction(panel->sclearB, sgrabClicked, panel); WMMapSubwidgets(panel->shortF); /* internal command */ panel->icommandL = WMCreateList(panel->optionsF); WMResizeWidget(panel->icommandL, width, 80); WMMoveWidget(panel->icommandL, 10, 20); WMSetListAction(panel->icommandL, icommandLClicked, panel); WMAddNotificationObserver(dataChanged, panel, WMListSelectionDidChangeNotification, panel->icommandL); WMInsertListItem(panel->icommandL, 0, _("Arrange Icons")); WMInsertListItem(panel->icommandL, 1, _("Hide All Windows Except For The Focused One")); WMInsertListItem(panel->icommandL, 2, _("Show All Windows")); WMInsertListItem(panel->icommandL, 3, _("Exit Window Maker")); WMInsertListItem(panel->icommandL, 4, _("Exit X Session")); WMInsertListItem(panel->icommandL, 5, _("Restart Window Maker")); WMInsertListItem(panel->icommandL, 6, _("Start Another Window Manager : (")); WMInsertListItem(panel->icommandL, 7, _("Save Current Session")); WMInsertListItem(panel->icommandL, 8, _("Clear Saved Session")); WMInsertListItem(panel->icommandL, 9, _("Refresh Screen")); WMInsertListItem(panel->icommandL, 10, _("Open Info Panel")); WMInsertListItem(panel->icommandL, 11, _("Open Copyright Panel")); panel->paramF = WMCreateFrame(panel->optionsF); WMResizeWidget(panel->paramF, width, 50); WMMoveWidget(panel->paramF, 10, 105); WMSetFrameTitle(panel->paramF, _("Window Manager to Start")); panel->paramT = WMCreateTextField(panel->paramF); WMResizeWidget(panel->paramT, width - 20, 20); WMMoveWidget(panel->paramT, 10, 20); WMAddNotificationObserver(dataChanged, panel, WMTextDidChangeNotification, panel->paramT); WMMapSubwidgets(panel->paramF); panel->quickB = WMCreateSwitchButton(panel->optionsF); WMResizeWidget(panel->quickB, width, 20); WMMoveWidget(panel->quickB, 10, 120); WMSetButtonText(panel->quickB, _("Do not confirm action.")); WMSetButtonAction(panel->quickB, buttonClicked, panel); label = WMCreateLabel(panel->optionsF); WMResizeWidget(label, width + 5, FRAME_HEIGHT - 50); WMMoveWidget(label, 7, 20); WMSetLabelText(label, _("Instructions:\n\n" " - drag items from the left to the menu to add new items\n" " - drag items out of the menu to remove items\n" " - drag items in menu to change their position\n" " - drag items with Control pressed to copy them\n" " - double click in a menu item to change the label\n" " - click on a menu item to change related information")); WMMapWidget(label); WMRealizeWidget(panel->box); WMMapSubwidgets(panel->box); WMMapWidget(panel->box); { int i; for (i = 0; i < wlengthof(panel->itemPad); i++) WMUnmapWidget(panel->itemPad[i]); } changedItemPad(panel->typeP, panel); panel->sections[NoInfo][0] = label; panel->sections[ExecInfo][0] = panel->commandF; panel->sections[ExecInfo][1] = panel->shortF; panel->sections[CommandInfo][0] = panel->icommandL; panel->sections[CommandInfo][1] = panel->shortF; panel->sections[ExternalInfo][0] = panel->pathF; panel->sections[PipeInfo][0] = panel->pipeF; panel->sections[PLPipeInfo][0] = panel->plpipeF; panel->sections[DirectoryInfo][0] = panel->dpathF; panel->sections[DirectoryInfo][1] = panel->dcommandF; panel->currentType = NoInfo; showData(panel); { WMPoint pos; pos = WMGetViewScreenPosition(WMWidgetView(panel->box)); if (pos.x < 200) { pos.x += FRAME_WIDTH + 20; } else { pos.x = 10; } pos.y = WMAX(pos.y - 100, 0); if (panel->menu) WEditMenuShowAt(panel->menu, pos.x, pos.y); } }
static void fillModifierPopUp(WMPopUpButton * pop) { XModifierKeymap *mapping; Display *dpy = WMScreenDisplay(WMWidgetScreen(pop)); int i, j; char *str; char buffer[64]; mapping = XGetModifierMapping(dpy); if (!mapping || mapping->max_keypermod == 0) { WMAddPopUpButtonItem(pop, "Mod1"); WMAddPopUpButtonItem(pop, "Mod2"); WMAddPopUpButtonItem(pop, "Mod3"); WMAddPopUpButtonItem(pop, "Mod4"); WMAddPopUpButtonItem(pop, "Mod5"); wwarning(_("could not retrieve keyboard modifier mapping")); return; } for (j = 0; j < 8; j++) { int idx; char *array[8]; int a; KeySym ksym; int k; char *ptr; char *tmp; a = 0; memset(array, 0, sizeof(char *) * 8); for (i = 0; i < mapping->max_keypermod; i++) { idx = i + j * mapping->max_keypermod; if (mapping->modifiermap[idx] != 0) { int l; for (l = 0; l < 4; l++) { if (xext_xkb_supported) ksym = XkbKeycodeToKeysym(dpy, mapping->modifiermap[idx], 0, l); else ksym = XKeycodeToKeysym(dpy, mapping->modifiermap[idx], 0); if (ksym != NoSymbol) break; } if (ksym != NoSymbol) str = XKeysymToString(ksym); else str = NULL; if (str && !strstr(str, "_Lock") && !strstr(str, "Shift") && !strstr(str, "Control")) { array[a++] = wstrdup(str); } } } for (k = 0; k < a; k++) { if (array[k] == NULL) continue; tmp = wstrdup(array[k]); ptr = strstr(tmp, "_L"); if (ptr) *ptr = 0; ptr = strstr(tmp, "_R"); if (ptr) *ptr = 0; sprintf(buffer, "%s (%s)", modifierNames[j], tmp); /*sprintf(buffer, "%s", tmp); */ WMAddPopUpButtonItem(pop, buffer); for (i = k + 1; i < a; i++) { if (array[i] == NULL) continue; if (strstr(array[i], tmp)) { wfree(array[i]); array[i] = NULL; break; } } wfree(tmp); } while (--a > 0) { if (array[a]) wfree(array[a]); } } if (mapping) XFreeModifiermap(mapping); }
static void showData(_Panel * panel) { char *str; int i; int a = -1, b = -1; float accel; char buffer[32]; Display *dpy = WMScreenDisplay(WMWidgetScreen(panel->parent)); for (i = 0; i < wlengthof(button_list); i++) { int action; str = GetStringForKey(button_list[i].db_key); if (button_list[i].type == T_BUTTON) action = getButtonAction(str); else action = getWheelAction(str); if (action < 0) { if (action == -1) wwarning(_("bad value %s for option %s"), str, button_list[i].db_key); action = button_list[i].default_action; } WMSetPopUpButtonSelectedItem(panel->mouse_action[i].popup, action); } WMSetButtonSelected(panel->disaB, GetBoolForKey("DisableWSMouseActions")); toggle_disabling_of_mouse_actions(panel->disaB, panel); /**/ getMouseParameters(dpy, &accel, &a); panel->maxThreshold = WidthOfScreen(DefaultScreenOfDisplay(dpy)); if (a > panel->maxThreshold) { panel->maxThreshold = a; } sprintf(buffer, "%i", a); WMSetTextFieldText(panel->threT, buffer); WMSetSliderValue(panel->speedS, (accel - 0.25F) / 0.25F); panel->acceleration = accel; sprintf(buffer, "%.2f", (double)accel); WMSetTextFieldText(panel->acceT, buffer); /**/ b = GetIntegerForKey("DoubleClickTime"); /* find best match */ a = -1; for (i = 0; i < wlengthof(panel->ddelaB); i++) { if (DELAY(i) == b) a = i; } if (a >= 0) WMPerformButtonClick(panel->ddelaB[a]); sprintf(buffer, "%i", b); WMSetTextFieldText(panel->ddelaT, buffer); /**/ str = GetStringForKey("ModifierKey"); if (!str) str = "mod1"; a = ModifierFromKey(dpy, str); if (a != -1) { str = modifierNames[a]; a = 0; for (i = 0; i < WMGetPopUpButtonNumberOfItems(panel->grabP); i++) { if (strstr(WMGetPopUpButtonItem(panel->grabP, i), str)) { WMSetPopUpButtonSelectedItem(panel->grabP, i); a = 1; break; } } } if (a < 1) { char *previous; previous = WMGetPopUpButtonItem(panel->grabP, 0); if (previous != NULL) WMSetPopUpButtonSelectedItem(panel->grabP, 0); wwarning(_("modifier key %s for option ModifierKey was not recognized. Using %s as default"), str, previous?previous:"(empty)"); } }
static void showText(Balloon * bPtr, int x, int y, int w, int h, const char *text) { WMScreen *scr = bPtr->view->screen; Display *dpy = WMScreenDisplay(scr); int width; int height; Pixmap pixmap; Pixmap mask; WMFont *font = bPtr->font ? bPtr->font : scr->normalFont; int textHeight; int side = 0; int ty; int bx, by; { int w; const char *ptr, *ptr2; ptr2 = ptr = text; width = 0; while (ptr && ptr2) { ptr2 = strchr(ptr, '\n'); if (ptr2) { w = WMWidthOfString(font, ptr, ptr2 - ptr); } else { w = WMWidthOfString(font, ptr, strlen(ptr)); } if (w > width) width = w; ptr = ptr2 + 1; } } width += 16; textHeight = W_GetTextHeight(font, text, width, False); height = textHeight + 4; if (height < 16) height = 16; if (width < height) width = height; if (x + width > scr->rootView->size.width) { side = RIGHT; bx = x - width + w / 2; if (bx < 0) bx = 0; } else { side = LEFT; bx = x + w / 2; } if (bx + width > scr->rootView->size.width) bx = scr->rootView->size.width - width; if (y - (height + SPACE) < 0) { side |= TOP; by = y + h - 1; ty = SPACE; } else { side |= BOTTOM; by = y - (height + SPACE); ty = 0; } pixmap = makePixmap(scr, width, height, side, &mask); W_PaintText(bPtr->view, pixmap, font, 8, ty + (height - textHeight) / 2, width, bPtr->flags.alignment, bPtr->textColor ? bPtr->textColor : scr->black, False, text, strlen(text)); XSetWindowBackgroundPixmap(dpy, bPtr->view->window, pixmap); W_ResizeView(bPtr->view, width, height + SPACE); XFreePixmap(dpy, pixmap); #ifdef USE_XSHAPE XShapeCombineMask(dpy, bPtr->view->window, ShapeBounding, 0, 0, mask, ShapeSet); #endif XFreePixmap(dpy, mask); W_MoveView(bPtr->view, bx, by); W_MapView(bPtr->view); }