diff --git a/src/appicon.c b/src/appicon.c index 5060238f..f11d3cb2 100644 --- a/src/appicon.c +++ b/src/appicon.c @@ -290,10 +290,6 @@ updateDockNumbers(WScreen *scr) int length; char *ws_numbers; WAppIcon *dicon = scr->dock->icon_array[0]; - WMColor *black, *white; - - black = WMBlackColor(scr->wmscreen); - white = WMWhiteColor(scr->wmscreen); ws_numbers = wmalloc(20); snprintf(ws_numbers, 20, "%i [ %i ]", scr->current_workspace+1, @@ -303,14 +299,12 @@ updateDockNumbers(WScreen *scr) XClearArea(dpy, dicon->icon->core->window, 2, 2, 50, WMFontHeight(scr->icon_title_font)+1, False); - WMDrawString(scr->wmscreen, dicon->icon->core->window, black, + WMDrawString(scr->wmscreen, dicon->icon->core->window, scr->black, scr->icon_title_font, 4, 3, ws_numbers, length); - WMDrawString(scr->wmscreen, dicon->icon->core->window, white, + WMDrawString(scr->wmscreen, dicon->icon->core->window, scr->white, scr->icon_title_font, 3, 2, ws_numbers, length); - WMReleaseColor(black); - WMReleaseColor(white); wfree(ws_numbers); } #endif /* WS_INDICATOR */ diff --git a/src/balloon.c b/src/balloon.c index 176fae2a..6ff4db35 100644 --- a/src/balloon.c +++ b/src/balloon.c @@ -172,7 +172,6 @@ showText(WScreen *scr, int x, int y, int h, int w, char *text) Pixmap pixmap; Pixmap mask; WMFont *font = scr->info_text_font; - WMColor *color; int side = 0; int ty; int bx, by; @@ -212,14 +211,10 @@ showText(WScreen *scr, int x, int y, int h, int w, char *text) } pixmap = makePixmap(scr, width, height, side, &mask); - color = WMBlackColor(scr->wmscreen); - - WMDrawString(scr->wmscreen, pixmap, color, font, 8, + WMDrawString(scr->wmscreen, pixmap, scr->black, font, 8, ty + (height - WMFontHeight(font))/2, text, strlen(text)); - WMReleaseColor(color); - XSetWindowBackgroundPixmap(dpy, scr->balloon->window, pixmap); scr->balloon->contents = pixmap; @@ -241,8 +236,6 @@ showText(WScreen *scr, int x, int y, int h, int w, char *text) int height; Pixmap pixmap; WMFont *font = scr->info_text_font; - WMColor *color; - WMPixel pixel; if (scr->balloon->contents) XFreePixmap(dpy, scr->balloon->contents); @@ -272,13 +265,8 @@ showText(WScreen *scr, int x, int y, int h, int w, char *text) pixmap = XCreatePixmap(dpy, scr->root_win, width, height, scr->w_depth); XFillRectangle(dpy, pixmap, scr->draw_gc, 0, 0, width, height); - /* ugly hack */ - color = WMBlackColor(scr->wmscreen); - pixel = color->color.pixel; - color->color.pixel = scr->window_title_pixel[0]; - WMDrawString(scr->wmscreen, pixmap, color, font, 4, 2, text, strlen(text)); - color->color.pixel = pixel; - WMReleaseColor(color); + WMDrawString(scr->wmscreen, pixmap, scr->window_title_color[0], font, 4, 2, + text, strlen(text)); XResizeWindow(dpy, scr->balloon->window, width, height); XMoveWindow(dpy, scr->balloon->window, x, y); diff --git a/src/defaults.c b/src/defaults.c index a910c2e8..f75e8f08 100644 --- a/src/defaults.c +++ b/src/defaults.c @@ -1,10 +1,10 @@ /* defaults.c - manage configuration through defaults db - * + * * Window Maker window manager - * + * * Copyright (c) 1997-2002 Alfredo K. Kojima * Copyright (c) 1998-2002 Dan Pascu - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ @@ -84,8 +84,8 @@ extern Atom _XA_WINDOWMAKER_ICON_SIZE; extern Atom _XA_WINDOWMAKER_ICON_TILE; /* -extern WMPropList *wDomainName; -extern WMPropList *wAttributeDomainName; + extern WMPropList *wDomainName; + extern WMPropList *wAttributeDomainName; */ extern WPreferences wPreferences; @@ -139,8 +139,8 @@ static int setClearance(); static int setIfDockPresent(); static int setStickyIcons(); /* -static int setPositive(); -*/ + static int setPositive(); + */ static int setWidgetColor(); static int setIconTile(); static int setWinTitleFont(); @@ -330,47 +330,47 @@ static WOptionEnumeration seWorkspaceBorder[] = { * defined, and this value needs to be correct. */ -/* these options will only affect the window manager on startup +/* these options will only affect the window manager on startup * * static defaults can't access the screen data, because it is * created after these defaults are read */ -WDefaultEntry staticOptionList[] = { +WDefaultEntry staticOptionList[] = { {"ColormapSize", "4", NULL, - &wPreferences.cmap_size, getInt, NULL + &wPreferences.cmap_size, getInt, NULL }, {"DisableDithering", "NO", NULL, - &wPreferences.no_dithering, getBool, NULL + &wPreferences.no_dithering, getBool, NULL }, /* static by laziness */ {"IconSize", "64", NULL, - &wPreferences.icon_size, getInt, NULL + &wPreferences.icon_size, getInt, NULL }, {"ModifierKey", "Mod1", NULL, - &wPreferences.modifier_mask, getModMask, NULL + &wPreferences.modifier_mask, getModMask, NULL }, {"DisableWSMouseActions", "NO", NULL, - &wPreferences.disable_root_mouse, getBool, NULL + &wPreferences.disable_root_mouse, getBool, NULL }, {"FocusMode", "manual", seFocusModes, - &wPreferences.focus_mode, getEnum, NULL + &wPreferences.focus_mode, getEnum, NULL }, /* have a problem when switching from manual to sloppy without restart */ {"NewStyle", "NO", NULL, - &wPreferences.new_style, getBool, NULL + &wPreferences.new_style, getBool, NULL }, {"DisableDock", "NO", (void*) WM_DOCK, - NULL, getBool, setIfDockPresent + NULL, getBool, setIfDockPresent }, {"DisableClip", "NO", (void*) WM_CLIP, - NULL, getBool, setIfDockPresent + NULL, getBool, setIfDockPresent }, {"DisableMiniwindows", "NO", NULL, - &wPreferences.disable_miniwindows, getBool, NULL + &wPreferences.disable_miniwindows, getBool, NULL } #if 0 ,{"MultiByteText", "NO", NULL, - &wPreferences.multi_byte_text, getBool, setMultiByte + &wPreferences.multi_byte_text, getBool, setMultiByte } #endif }; @@ -378,481 +378,481 @@ WDefaultEntry staticOptionList[] = { WDefaultEntry optionList[] = { - /* dynamic options */ + /* dynamic options */ {"IconPosition", "blh", seIconPositions, - &wPreferences.icon_yard, getEnum, setIconPosition + &wPreferences.icon_yard, getEnum, setIconPosition }, {"IconificationStyle", "Zoom", seIconificationStyles, - &wPreferences.iconification_style, getEnum, NULL + &wPreferences.iconification_style, getEnum, NULL }, {"MouseLeftButtonAction", "SelectWindows", seMouseButtonActions, - &wPreferences.mouse_button1, getEnum, NULL + &wPreferences.mouse_button1, getEnum, NULL }, {"MouseMiddleButtonAction", "OpenWindowListMenu", seMouseButtonActions, - &wPreferences.mouse_button2, getEnum, NULL + &wPreferences.mouse_button2, getEnum, NULL }, {"MouseRightButtonAction", "OpenApplicationsMenu", seMouseButtonActions, - &wPreferences.mouse_button3, getEnum, NULL + &wPreferences.mouse_button3, getEnum, NULL }, {"MouseWheelAction", "None", seMouseWheelActions, - &wPreferences.mouse_wheel, getEnum, NULL + &wPreferences.mouse_wheel, getEnum, NULL }, {"PixmapPath", DEF_PIXMAP_PATHS, NULL, - &wPreferences.pixmap_path, getPathList, NULL + &wPreferences.pixmap_path, getPathList, NULL }, {"IconPath", DEF_ICON_PATHS, NULL, - &wPreferences.icon_path, getPathList, NULL + &wPreferences.icon_path, getPathList, NULL }, {"ColormapMode", "auto", seColormapModes, - &wPreferences.colormap_mode, getEnum, NULL + &wPreferences.colormap_mode, getEnum, NULL }, {"AutoFocus", "NO", NULL, - &wPreferences.auto_focus, getBool, NULL + &wPreferences.auto_focus, getBool, NULL }, {"RaiseDelay", "0", NULL, - &wPreferences.raise_delay, getInt, NULL + &wPreferences.raise_delay, getInt, NULL }, {"WindozeCycling", "NO", NULL, - &wPreferences.windows_cycling,getBool, NULL + &wPreferences.windows_cycling,getBool, NULL }, {"CirculateRaise", "NO", NULL, - &wPreferences.circ_raise, getBool, NULL + &wPreferences.circ_raise, getBool, NULL }, {"Superfluous", "NO", NULL, - &wPreferences.superfluous, getBool, NULL + &wPreferences.superfluous, getBool, NULL }, {"AdvanceToNewWorkspace", "NO", NULL, - &wPreferences.ws_advance, getBool, NULL + &wPreferences.ws_advance, getBool, NULL }, {"CycleWorkspaces", "NO", NULL, - &wPreferences.ws_cycle, getBool, NULL + &wPreferences.ws_cycle, getBool, NULL }, {"WorkspaceNameDisplayPosition", "center", seDisplayPositions, - &wPreferences.workspace_name_display_position, getEnum, NULL + &wPreferences.workspace_name_display_position, getEnum, NULL }, {"WorkspaceBorder", "None", seWorkspaceBorder, - &wPreferences.workspace_border_position, getEnum, updateUsableArea + &wPreferences.workspace_border_position, getEnum, updateUsableArea }, {"WorkspaceBorderSize", "0", NULL, - &wPreferences.workspace_border_size, getInt, updateUsableArea + &wPreferences.workspace_border_size, getInt, updateUsableArea }, #ifdef VIRTUAL_DESKTOP {"VirtualEdgeThickness", "1", NULL, - &wPreferences.vedge_thickness, getInt, NULL + &wPreferences.vedge_thickness, getInt, NULL }, {"VirtualEdgeExtendSpace", "0", NULL, - &wPreferences.vedge_bordersize, getInt, NULL + &wPreferences.vedge_bordersize, getInt, NULL }, {"VirtualEdgeHorizonScrollSpeed", "1", NULL, - &wPreferences.vedge_hscrollspeed, getInt, NULL + &wPreferences.vedge_hscrollspeed, getInt, NULL }, {"VirtualEdgeVerticalScrollSpeed", "1", NULL, - &wPreferences.vedge_vscrollspeed, getInt, NULL + &wPreferences.vedge_vscrollspeed, getInt, NULL }, {"VirtualEdgeMaximumWidth", "3000", NULL, - &wPreferences.vedge_maxwidth, getInt, NULL + &wPreferences.vedge_maxwidth, getInt, NULL }, {"VirtualEdgeMaximumHeight", "3000", NULL, - &wPreferences.vedge_maxheight, getInt, NULL + &wPreferences.vedge_maxheight, getInt, NULL }, #endif {"StickyIcons", "NO", NULL, - &wPreferences.sticky_icons, getBool, setStickyIcons + &wPreferences.sticky_icons, getBool, setStickyIcons }, {"SaveSessionOnExit", "NO", NULL, - &wPreferences.save_session_on_exit, getBool, NULL + &wPreferences.save_session_on_exit, getBool, NULL }, {"WrapMenus", "NO", NULL, - &wPreferences.wrap_menus, getBool, NULL + &wPreferences.wrap_menus, getBool, NULL }, {"ScrollableMenus", "NO", NULL, - &wPreferences.scrollable_menus, getBool, NULL + &wPreferences.scrollable_menus, getBool, NULL }, {"MenuScrollSpeed", "medium", seSpeeds, - &wPreferences.menu_scroll_speed, getEnum, NULL + &wPreferences.menu_scroll_speed, getEnum, NULL }, {"IconSlideSpeed", "medium", seSpeeds, - &wPreferences.icon_slide_speed, getEnum, NULL + &wPreferences.icon_slide_speed, getEnum, NULL }, {"ShadeSpeed", "medium", seSpeeds, - &wPreferences.shade_speed, getEnum, NULL + &wPreferences.shade_speed, getEnum, NULL }, {"DoubleClickTime", "250", (void*) &wPreferences.dblclick_time, - &wPreferences.dblclick_time, getInt, setDoubleClick, + &wPreferences.dblclick_time, getInt, setDoubleClick, }, {"AlignSubmenus", "NO", NULL, - &wPreferences.align_menus, getBool, NULL + &wPreferences.align_menus, getBool, NULL }, {"OpenTransientOnOwnerWorkspace", "NO", NULL, - &wPreferences.open_transients_with_parent, getBool, NULL + &wPreferences.open_transients_with_parent, getBool, NULL }, {"WindowPlacement", "auto", sePlacements, - &wPreferences.window_placement, getEnum, NULL + &wPreferences.window_placement, getEnum, NULL }, {"IgnoreFocusClick","NO", NULL, - &wPreferences.ignore_focus_click, getBool, NULL + &wPreferences.ignore_focus_click, getBool, NULL }, {"UseSaveUnders", "NO", NULL, - &wPreferences.use_saveunders, getBool, NULL + &wPreferences.use_saveunders, getBool, NULL }, {"OpaqueMove", "NO", NULL, - &wPreferences.opaque_move, getBool, NULL + &wPreferences.opaque_move, getBool, NULL }, {"DisableSound", "NO", NULL, - &wPreferences.no_sound, getBool, NULL + &wPreferences.no_sound, getBool, NULL }, {"DisableAnimations", "NO", NULL, - &wPreferences.no_animations, getBool, NULL + &wPreferences.no_animations, getBool, NULL }, {"DontLinkWorkspaces","NO", NULL, - &wPreferences.no_autowrap, getBool, NULL + &wPreferences.no_autowrap, getBool, NULL }, {"AutoArrangeIcons", "NO", NULL, - &wPreferences.auto_arrange_icons, getBool, NULL + &wPreferences.auto_arrange_icons, getBool, NULL }, {"NoWindowOverDock", "NO", NULL, - &wPreferences.no_window_over_dock, getBool, updateUsableArea + &wPreferences.no_window_over_dock, getBool, updateUsableArea }, {"NoWindowOverIcons", "NO", NULL, - &wPreferences.no_window_over_icons, getBool, updateUsableArea + &wPreferences.no_window_over_icons, getBool, updateUsableArea }, {"WindowPlaceOrigin", "(0, 0)", NULL, - &wPreferences.window_place_origin, getCoord, NULL + &wPreferences.window_place_origin, getCoord, NULL }, {"ResizeDisplay", "corner", seGeomDisplays, - &wPreferences.size_display, getEnum, NULL + &wPreferences.size_display, getEnum, NULL }, {"MoveDisplay", "corner", seGeomDisplays, - &wPreferences.move_display, getEnum, NULL + &wPreferences.move_display, getEnum, NULL }, {"DontConfirmKill", "NO", NULL, - &wPreferences.dont_confirm_kill, getBool,NULL + &wPreferences.dont_confirm_kill, getBool,NULL }, {"WindowTitleBalloons", "NO", NULL, - &wPreferences.window_balloon, getBool, NULL + &wPreferences.window_balloon, getBool, NULL }, {"MiniwindowTitleBalloons", "NO", NULL, - &wPreferences.miniwin_balloon,getBool, NULL + &wPreferences.miniwin_balloon,getBool, NULL }, {"AppIconBalloons", "NO", NULL, - &wPreferences.appicon_balloon,getBool, NULL + &wPreferences.appicon_balloon,getBool, NULL }, {"HelpBalloons", "NO", NULL, - &wPreferences.help_balloon, getBool, NULL + &wPreferences.help_balloon, getBool, NULL }, {"EdgeResistance", "30", NULL, - &wPreferences.edge_resistance,getInt, NULL + &wPreferences.edge_resistance,getInt, NULL }, {"Attraction", "NO", NULL, - &wPreferences.attract, getBool, NULL + &wPreferences.attract, getBool, NULL }, {"DisableBlinking", "NO", NULL, - &wPreferences.dont_blink, getBool, NULL + &wPreferences.dont_blink, getBool, NULL }, - /* style options */ + /* style options */ {"MenuStyle", "normal", seMenuStyles, - &wPreferences.menu_style, getEnum, setMenuStyle + &wPreferences.menu_style, getEnum, setMenuStyle }, {"WidgetColor", "(solid, gray)", NULL, - NULL, getTexture, setWidgetColor, + NULL, getTexture, setWidgetColor, }, {"WorkspaceSpecificBack","()", NULL, - NULL, getWSSpecificBackground, setWorkspaceSpecificBack + NULL, getWSSpecificBackground, setWorkspaceSpecificBack }, - /* WorkspaceBack must come after WorkspaceSpecificBack or - * WorkspaceBack wont know WorkspaceSpecificBack was also - * specified and 2 copies of wmsetbg will be launched */ + /* WorkspaceBack must come after WorkspaceSpecificBack or + * WorkspaceBack wont know WorkspaceSpecificBack was also + * specified and 2 copies of wmsetbg will be launched */ {"WorkspaceBack", "(solid, black)", NULL, - NULL, getWSBackground,setWorkspaceBack + NULL, getWSBackground,setWorkspaceBack }, {"SmoothWorkspaceBack", "NO", NULL, - NULL, getBool, NULL + NULL, getBool, NULL }, {"IconBack", "(solid, gray)", NULL, - NULL, getTexture, setIconTile + NULL, getTexture, setIconTile }, {"TitleJustify", "center", seJustifications, - &wPreferences.title_justification, getEnum, setJustify + &wPreferences.title_justification, getEnum, setJustify }, {"WindowTitleFont", DEF_TITLE_FONT, NULL, - NULL, getFont, setWinTitleFont, + NULL, getFont, setWinTitleFont, }, {"WindowTitleExtendSpace", DEF_WINDOW_TITLE_EXTEND_SPACE, NULL, - &wPreferences.window_title_clearance, getInt, setClearance + &wPreferences.window_title_clearance, getInt, setClearance }, {"MenuTitleExtendSpace", DEF_MENU_TITLE_EXTEND_SPACE, NULL, - &wPreferences.menu_title_clearance, getInt, setClearance + &wPreferences.menu_title_clearance, getInt, setClearance }, {"MenuTextExtendSpace", DEF_MENU_TEXT_EXTEND_SPACE, NULL, - &wPreferences.menu_text_clearance, getInt, setClearance + &wPreferences.menu_text_clearance, getInt, setClearance }, {"MenuTitleFont", DEF_MENU_TITLE_FONT, NULL, - NULL, getFont, setMenuTitleFont + NULL, getFont, setMenuTitleFont }, {"MenuTextFont", DEF_MENU_ENTRY_FONT, NULL, - NULL, getFont, setMenuTextFont + NULL, getFont, setMenuTextFont }, {"IconTitleFont", DEF_ICON_TITLE_FONT, NULL, - NULL, getFont, setIconTitleFont + NULL, getFont, setIconTitleFont }, {"ClipTitleFont", DEF_CLIP_TITLE_FONT, NULL, - NULL, getFont, setClipTitleFont + NULL, getFont, setClipTitleFont }, {"LargeDisplayFont",DEF_WORKSPACE_NAME_FONT, NULL, - NULL, getFont, setLargeDisplayFont + NULL, getFont, setLargeDisplayFont }, {"HighlightColor", "white", NULL, - NULL, getColor, setHightlight + NULL, getColor, setHightlight }, {"HighlightTextColor", "black", NULL, - NULL, getColor, setHightlightText + NULL, getColor, setHightlightText }, {"ClipTitleColor", "black", (void*)CLIP_NORMAL, - NULL, getColor, setClipTitleColor + NULL, getColor, setClipTitleColor }, {"CClipTitleColor", "\"#454045\"", (void*)CLIP_COLLAPSED, - NULL, getColor, setClipTitleColor + NULL, getColor, setClipTitleColor }, {"FTitleColor", "white", (void*)WS_FOCUSED, - NULL, getColor, setWTitleColor + NULL, getColor, setWTitleColor }, {"PTitleColor", "white", (void*)WS_PFOCUSED, - NULL, getColor, setWTitleColor + NULL, getColor, setWTitleColor }, {"UTitleColor", "black", (void*)WS_UNFOCUSED, - NULL, getColor, setWTitleColor + NULL, getColor, setWTitleColor }, {"FTitleBack", "(solid, black)", NULL, - NULL, getTexture, setFTitleBack + NULL, getTexture, setFTitleBack }, {"PTitleBack", "(solid, \"#616161\")", NULL, - NULL, getTexture, setPTitleBack + NULL, getTexture, setPTitleBack }, {"UTitleBack", "(solid, gray)", NULL, - NULL, getTexture, setUTitleBack + NULL, getTexture, setUTitleBack }, {"ResizebarBack", "(solid, gray)", NULL, - NULL, getTexture, setResizebarBack + NULL, getTexture, setResizebarBack }, {"MenuTitleColor", "white", NULL, - NULL, getColor, setMenuTitleColor + NULL, getColor, setMenuTitleColor }, {"MenuTextColor", "black", NULL, - NULL, getColor, setMenuTextColor + NULL, getColor, setMenuTextColor }, {"MenuDisabledColor", "\"#616161\"", NULL, - NULL, getColor, setMenuDisabledColor + NULL, getColor, setMenuDisabledColor }, {"MenuTitleBack", "(solid, black)", NULL, - NULL, getTexture, setMenuTitleBack + NULL, getTexture, setMenuTitleBack }, {"MenuTextBack", "(solid, gray)", NULL, - NULL, getTexture, setMenuTextBack + NULL, getTexture, setMenuTextBack }, {"IconTitleColor", "white", NULL, - NULL, getColor, setIconTitleColor + NULL, getColor, setIconTitleColor }, {"IconTitleBack", "black", NULL, - NULL, getColor, setIconTitleBack + NULL, getColor, setIconTitleBack }, - /* keybindings */ + /* keybindings */ #ifndef LITE {"RootMenuKey", "None", (void*)WKBD_ROOTMENU, - NULL, getKeybind, setKeyGrab + NULL, getKeybind, setKeyGrab }, {"WindowListKey", "None", (void*)WKBD_WINDOWLIST, - NULL, getKeybind, setKeyGrab + NULL, getKeybind, setKeyGrab }, #endif /* LITE */ {"WindowMenuKey", "None", (void*)WKBD_WINDOWMENU, - NULL, getKeybind, setKeyGrab + NULL, getKeybind, setKeyGrab }, {"ClipLowerKey", "None", (void*)WKBD_CLIPLOWER, - NULL, getKeybind, setKeyGrab + NULL, getKeybind, setKeyGrab }, {"ClipRaiseKey", "None", (void*)WKBD_CLIPRAISE, - NULL, getKeybind, setKeyGrab + NULL, getKeybind, setKeyGrab }, {"ClipRaiseLowerKey", "None", (void*)WKBD_CLIPRAISELOWER, - NULL, getKeybind, setKeyGrab + NULL, getKeybind, setKeyGrab }, {"MiniaturizeKey", "None", (void*)WKBD_MINIATURIZE, - NULL, getKeybind, setKeyGrab + NULL, getKeybind, setKeyGrab }, {"HideKey", "None", (void*)WKBD_HIDE, - NULL, getKeybind, setKeyGrab + NULL, getKeybind, setKeyGrab }, {"HideOthersKey", "None", (void*)WKBD_HIDE_OTHERS, - NULL, getKeybind, setKeyGrab + NULL, getKeybind, setKeyGrab }, {"MoveResizeKey", "None", (void*)WKBD_MOVERESIZE, - NULL, getKeybind, setKeyGrab + NULL, getKeybind, setKeyGrab }, {"CloseKey", "None", (void*)WKBD_CLOSE, - NULL, getKeybind, setKeyGrab + NULL, getKeybind, setKeyGrab }, {"MaximizeKey", "None", (void*)WKBD_MAXIMIZE, - NULL, getKeybind, setKeyGrab + NULL, getKeybind, setKeyGrab }, {"VMaximizeKey", "None", (void*)WKBD_VMAXIMIZE, - NULL, getKeybind, setKeyGrab + NULL, getKeybind, setKeyGrab }, {"HMaximizeKey", "None", (void*)WKBD_HMAXIMIZE, - NULL, getKeybind, setKeyGrab + NULL, getKeybind, setKeyGrab }, {"RaiseKey", "\"Meta+Up\"", (void*)WKBD_RAISE, - NULL, getKeybind, setKeyGrab + NULL, getKeybind, setKeyGrab }, {"LowerKey", "\"Meta+Down\"", (void*)WKBD_LOWER, - NULL, getKeybind, setKeyGrab + NULL, getKeybind, setKeyGrab }, {"RaiseLowerKey", "None", (void*)WKBD_RAISELOWER, - NULL, getKeybind, setKeyGrab + NULL, getKeybind, setKeyGrab }, {"ShadeKey", "None", (void*)WKBD_SHADE, - NULL, getKeybind, setKeyGrab + NULL, getKeybind, setKeyGrab }, {"SelectKey", "None", (void*)WKBD_SELECT, - NULL, getKeybind, setKeyGrab + NULL, getKeybind, setKeyGrab }, {"FocusNextKey", "None", (void*)WKBD_FOCUSNEXT, - NULL, getKeybind, setKeyGrab + NULL, getKeybind, setKeyGrab }, {"FocusPrevKey", "None", (void*)WKBD_FOCUSPREV, - NULL, getKeybind, setKeyGrab + NULL, getKeybind, setKeyGrab }, {"NextWorkspaceKey", "None", (void*)WKBD_NEXTWORKSPACE, - NULL, getKeybind, setKeyGrab + NULL, getKeybind, setKeyGrab }, {"PrevWorkspaceKey", "None", (void*)WKBD_PREVWORKSPACE, - NULL, getKeybind, setKeyGrab + NULL, getKeybind, setKeyGrab }, {"NextWorkspaceLayerKey", "None", (void*)WKBD_NEXTWSLAYER, - NULL, getKeybind, setKeyGrab + NULL, getKeybind, setKeyGrab }, {"PrevWorkspaceLayerKey", "None", (void*)WKBD_PREVWSLAYER, - NULL, getKeybind, setKeyGrab + NULL, getKeybind, setKeyGrab }, {"Workspace1Key", "None", (void*)WKBD_WORKSPACE1, - NULL, getKeybind, setKeyGrab + NULL, getKeybind, setKeyGrab }, {"Workspace2Key", "None", (void*)WKBD_WORKSPACE2, - NULL, getKeybind, setKeyGrab + NULL, getKeybind, setKeyGrab }, {"Workspace3Key", "None", (void*)WKBD_WORKSPACE3, - NULL, getKeybind, setKeyGrab + NULL, getKeybind, setKeyGrab }, {"Workspace4Key", "None", (void*)WKBD_WORKSPACE4, - NULL, getKeybind, setKeyGrab + NULL, getKeybind, setKeyGrab }, {"Workspace5Key", "None", (void*)WKBD_WORKSPACE5, - NULL, getKeybind, setKeyGrab + NULL, getKeybind, setKeyGrab }, {"Workspace6Key", "None", (void*)WKBD_WORKSPACE6, - NULL, getKeybind, setKeyGrab + NULL, getKeybind, setKeyGrab }, {"Workspace7Key", "None", (void*)WKBD_WORKSPACE7, - NULL, getKeybind, setKeyGrab + NULL, getKeybind, setKeyGrab }, {"Workspace8Key", "None", (void*)WKBD_WORKSPACE8, - NULL, getKeybind, setKeyGrab + NULL, getKeybind, setKeyGrab }, {"Workspace9Key", "None", (void*)WKBD_WORKSPACE9, - NULL, getKeybind, setKeyGrab + NULL, getKeybind, setKeyGrab }, {"Workspace10Key", "None", (void*)WKBD_WORKSPACE10, - NULL, getKeybind, setKeyGrab + NULL, getKeybind, setKeyGrab }, {"WindowShortcut1Key","None", (void*)WKBD_WINDOW1, - NULL, getKeybind, setKeyGrab + NULL, getKeybind, setKeyGrab }, {"WindowShortcut2Key","None", (void*)WKBD_WINDOW2, - NULL, getKeybind, setKeyGrab + NULL, getKeybind, setKeyGrab }, {"WindowShortcut3Key","None", (void*)WKBD_WINDOW3, - NULL, getKeybind, setKeyGrab + NULL, getKeybind, setKeyGrab }, {"WindowShortcut4Key","None", (void*)WKBD_WINDOW4, - NULL, getKeybind, setKeyGrab + NULL, getKeybind, setKeyGrab } ,{"WindowShortcut5Key","None", (void*)WKBD_WINDOW5, - NULL, getKeybind, setKeyGrab + NULL, getKeybind, setKeyGrab }, {"WindowShortcut6Key","None", (void*)WKBD_WINDOW6, - NULL, getKeybind, setKeyGrab + NULL, getKeybind, setKeyGrab }, {"WindowShortcut7Key","None", (void*)WKBD_WINDOW7, - NULL, getKeybind, setKeyGrab + NULL, getKeybind, setKeyGrab }, {"WindowShortcut8Key","None", (void*)WKBD_WINDOW8, - NULL, getKeybind, setKeyGrab + NULL, getKeybind, setKeyGrab }, {"WindowShortcut9Key","None", (void*)WKBD_WINDOW9, - NULL, getKeybind, setKeyGrab + NULL, getKeybind, setKeyGrab }, {"WindowShortcut10Key","None", (void*)WKBD_WINDOW10, - NULL, getKeybind, setKeyGrab + NULL, getKeybind, setKeyGrab }, {"ScreenSwitchKey", "None", (void*)WKBD_SWITCH_SCREEN, - NULL, getKeybind, setKeyGrab + NULL, getKeybind, setKeyGrab }, #ifdef KEEP_XKB_LOCK_STATUS {"ToggleKbdModeKey", "None", (void*)WKBD_TOGGLE, - NULL, getKeybind, setKeyGrab + NULL, getKeybind, setKeyGrab }, {"KbdModeLock", "NO", NULL, - &wPreferences.modelock, getBool, NULL + &wPreferences.modelock, getBool, NULL }, #endif /* KEEP_XKB_LOCK_STATUS */ {"NormalCursor", "(builtin, left_ptr)", (void*)WCUR_ROOT, - NULL, getCursor, setCursor + NULL, getCursor, setCursor }, {"ArrowCursor", "(builtin, top_left_arrow)", (void*)WCUR_ARROW, - NULL, getCursor, setCursor + NULL, getCursor, setCursor }, {"MoveCursor", "(builtin, fleur)", (void*)WCUR_MOVE, - NULL, getCursor, setCursor + NULL, getCursor, setCursor }, {"ResizeCursor", "(builtin, sizing)", (void*)WCUR_RESIZE, - NULL, getCursor, setCursor + NULL, getCursor, setCursor }, {"TopLeftResizeCursor", "(builtin, top_left_corner)", - (void*)WCUR_TOPLEFTRESIZE, - NULL, getCursor, setCursor + (void*)WCUR_TOPLEFTRESIZE, + NULL, getCursor, setCursor }, {"TopRightResizeCursor", "(builtin, top_right_corner)", - (void*)WCUR_TOPRIGHTRESIZE, - NULL, getCursor, setCursor + (void*)WCUR_TOPRIGHTRESIZE, + NULL, getCursor, setCursor }, {"BottomLeftResizeCursor", "(builtin, bottom_left_corner)", - (void*)WCUR_BOTTOMLEFTRESIZE, - NULL, getCursor, setCursor + (void*)WCUR_BOTTOMLEFTRESIZE, + NULL, getCursor, setCursor }, {"BottomRightResizeCursor", "(builtin, bottom_right_corner)", - (void*)WCUR_BOTTOMRIGHTRESIZE, - NULL, getCursor, setCursor + (void*)WCUR_BOTTOMRIGHTRESIZE, + NULL, getCursor, setCursor }, {"VerticalResizeCursor", "(builtin, sb_v_double_arrow)", - (void*)WCUR_VERTICALRESIZE, - NULL, getCursor, setCursor + (void*)WCUR_VERTICALRESIZE, + NULL, getCursor, setCursor }, {"HorizontalResizeCursor", "(builtin, sb_h_double_arrow)", - (void*)WCUR_HORIZONRESIZE, - NULL, getCursor, setCursor + (void*)WCUR_HORIZONRESIZE, + NULL, getCursor, setCursor }, {"WaitCursor", "(builtin, watch)", (void*)WCUR_WAIT, - NULL, getCursor, setCursor + NULL, getCursor, setCursor }, {"QuestionCursor", "(builtin, question_arrow)", (void*)WCUR_QUESTION, - NULL, getCursor, setCursor + NULL, getCursor, setCursor }, {"TextCursor", "(builtin, xterm)", (void*)WCUR_TEXT, - NULL, getCursor, setCursor + NULL, getCursor, setCursor }, {"SelectCursor", "(builtin, cross)", (void*)WCUR_SELECT, - NULL, getCursor, setCursor + NULL, getCursor, setCursor } }; @@ -863,11 +863,11 @@ static void rereadDefaults(void); #if 0 static void -rereadDefaults(void) + rereadDefaults(void) { /* must defer the update because accessing X data from a * signal handler can mess up Xlib */ - + } #endif @@ -880,32 +880,32 @@ initDefaults() WMPLSetCaseSensitive(False); for (i=0; iplkey = WMCreatePLString(entry->key); - if (entry->default_value) - entry->plvalue = WMCreatePropListFromDescription(entry->default_value); - else - entry->plvalue = NULL; + entry->plkey = WMCreatePLString(entry->key); + if (entry->default_value) + entry->plvalue = WMCreatePropListFromDescription(entry->default_value); + else + entry->plvalue = NULL; } for (i=0; iplkey = WMCreatePLString(entry->key); - if (entry->default_value) - entry->plvalue = WMCreatePropListFromDescription(entry->default_value); - else - entry->plvalue = NULL; - } - -/* - wDomainName = WMCreatePLString(WMDOMAIN_NAME); - wAttributeDomainName = WMCreatePLString(WMATTRIBUTE_DOMAIN_NAME); + entry = &staticOptionList[i]; - PLRegister(wDomainName, rereadDefaults); - PLRegister(wAttributeDomainName, rereadDefaults); - */ + entry->plkey = WMCreatePLString(entry->key); + if (entry->default_value) + entry->plvalue = WMCreatePropListFromDescription(entry->default_value); + else + entry->plvalue = NULL; + } + + /* + wDomainName = WMCreatePLString(WMDOMAIN_NAME); + wAttributeDomainName = WMCreatePLString(WMATTRIBUTE_DOMAIN_NAME); + + PLRegister(wDomainName, rereadDefaults); + PLRegister(wAttributeDomainName, rereadDefaults); + */ } @@ -940,15 +940,15 @@ wDefaultsInit(int screen_number) { static int defaults_inited = 0; WMPropList *dict; - + if (!defaults_inited) { - initDefaults(); + initDefaults(); } - + dict = PLGetDomain(wDomainName); if (!dict) { - wwarning(_("could not read domain \"%s\" from defaults database"), - WMGetFromPLString(wDomainName)); + wwarning(_("could not read domain \"%s\" from defaults database"), + WMGetFromPLString(wDomainName)); } return dict; @@ -960,7 +960,7 @@ void wDefaultsDestroyDomain(WDDomain *domain) { if (domain->dictionary) - WMReleasePropList(domain->dictionary); + WMReleasePropList(domain->dictionary); wfree(domain->path); wfree(domain); } @@ -977,8 +977,8 @@ wDefaultsInitDomain(char *domain, Bool requireDictionary) WMPropList *shared_dict=NULL; if (!inited) { - inited = 1; - initDefaults(); + inited = 1; + initDefaults(); } db = wmalloc(sizeof(WDDomain)); @@ -986,21 +986,21 @@ wDefaultsInitDomain(char *domain, Bool requireDictionary) db->domain_name = domain; db->path = wdefaultspathfordomain(domain); the_path = db->path; - + if (the_path && stat(the_path, &stbuf)>=0) { - db->dictionary = WMReadPropListFromFile(the_path); - if (db->dictionary) { - if (requireDictionary && !WMIsPLDictionary(db->dictionary)) { - WMReleasePropList(db->dictionary); - db->dictionary = NULL; - wwarning(_("Domain %s (%s) of defaults database is corrupted!"), - domain, the_path); - } - db->timestamp = stbuf.st_mtime; - } else { - wwarning(_("could not load domain %s from user defaults database"), - domain); - } + db->dictionary = WMReadPropListFromFile(the_path); + if (db->dictionary) { + if (requireDictionary && !WMIsPLDictionary(db->dictionary)) { + WMReleasePropList(db->dictionary); + db->dictionary = NULL; + wwarning(_("Domain %s (%s) of defaults database is corrupted!"), + domain, the_path); + } + db->timestamp = stbuf.st_mtime; + } else { + wwarning(_("could not load domain %s from user defaults database"), + domain); + } } /* global system dictionary */ @@ -1008,29 +1008,29 @@ wDefaultsInitDomain(char *domain, Bool requireDictionary) if (stat(path, &stbuf)>=0) { shared_dict = WMReadPropListFromFile(path); if (shared_dict) { - if (requireDictionary && !WMIsPLDictionary(shared_dict)) { - wwarning(_("Domain %s (%s) of global defaults database is corrupted!"), - domain, path); - WMReleasePropList(shared_dict); - shared_dict = NULL; - } else { - if (db->dictionary && WMIsPLDictionary(shared_dict) && - WMIsPLDictionary(db->dictionary)) { + if (requireDictionary && !WMIsPLDictionary(shared_dict)) { + wwarning(_("Domain %s (%s) of global defaults database is corrupted!"), + domain, path); + WMReleasePropList(shared_dict); + shared_dict = NULL; + } else { + if (db->dictionary && WMIsPLDictionary(shared_dict) && + WMIsPLDictionary(db->dictionary)) { WMMergePLDictionaries(shared_dict, db->dictionary, True); - WMReleasePropList(db->dictionary); - db->dictionary = shared_dict; - if (stbuf.st_mtime > db->timestamp) - db->timestamp = stbuf.st_mtime; - } else if (!db->dictionary) { - db->dictionary = shared_dict; - if (stbuf.st_mtime > db->timestamp) - db->timestamp = stbuf.st_mtime; - } + WMReleasePropList(db->dictionary); + db->dictionary = shared_dict; + if (stbuf.st_mtime > db->timestamp) + db->timestamp = stbuf.st_mtime; + } else if (!db->dictionary) { + db->dictionary = shared_dict; + if (stbuf.st_mtime > db->timestamp) + db->timestamp = stbuf.st_mtime; + } } } else { - wwarning(_("could not load domain %s from global defaults database (%s)"), - domain, path); - } + wwarning(_("could not load domain %s from global defaults database (%s)"), + domain, path); + } } return db; @@ -1045,27 +1045,27 @@ wReadStaticDefaults(WMPropList *dict) int i; void *tdata; - - for (i=0; iplkey); - else - plvalue = NULL; - - if (!plvalue) { - /* no default in the DB. Use builtin default */ - plvalue = entry->plvalue; - } - - if (plvalue) { - /* convert data */ - (*entry->convert)(NULL, entry, plvalue, entry->addr, &tdata); + for (i=0; iplkey); + else + plvalue = NULL; + + if (!plvalue) { + /* no default in the DB. Use builtin default */ + plvalue = entry->plvalue; + } + + if (plvalue) { + /* convert data */ + (*entry->convert)(NULL, entry, plvalue, entry->addr, &tdata); if (entry->update) { (*entry->update)(NULL, entry, tdata, entry->extra_data); } - } + } } } @@ -1083,76 +1083,76 @@ wDefaultsCheckDomains(void *foo) puts("Checking domains..."); #endif if (stat(WDWindowMaker->path, &stbuf)>=0 - && WDWindowMaker->timestamp < stbuf.st_mtime) { + && WDWindowMaker->timestamp < stbuf.st_mtime) { #ifdef HEARTBEAT - puts("Checking WindowMaker domain"); + puts("Checking WindowMaker domain"); #endif - WDWindowMaker->timestamp = stbuf.st_mtime; + WDWindowMaker->timestamp = stbuf.st_mtime; - /* global dictionary */ + /* global dictionary */ shared_dict = readGlobalDomain("WindowMaker", True); - /* user dictionary */ - dict = WMReadPropListFromFile(WDWindowMaker->path); - if (dict) { - if (!WMIsPLDictionary(dict)) { - WMReleasePropList(dict); - dict = NULL; - wwarning(_("Domain %s (%s) of defaults database is corrupted!"), - "WindowMaker", WDWindowMaker->path); - } else { - if (shared_dict) { + /* user dictionary */ + dict = WMReadPropListFromFile(WDWindowMaker->path); + if (dict) { + if (!WMIsPLDictionary(dict)) { + WMReleasePropList(dict); + dict = NULL; + wwarning(_("Domain %s (%s) of defaults database is corrupted!"), + "WindowMaker", WDWindowMaker->path); + } else { + if (shared_dict) { WMMergePLDictionaries(shared_dict, dict, True); - WMReleasePropList(dict); - dict = shared_dict; - shared_dict = NULL; - } - for (i=0; idictionary) { - WMReleasePropList(WDWindowMaker->dictionary); - } - WDWindowMaker->dictionary = dict; - } - } else { - wwarning(_("could not load domain %s from user defaults database"), - "WindowMaker"); - } - if (shared_dict) { - WMReleasePropList(shared_dict); - } + WMReleasePropList(dict); + dict = shared_dict; + shared_dict = NULL; + } + for (i=0; idictionary) { + WMReleasePropList(WDWindowMaker->dictionary); + } + WDWindowMaker->dictionary = dict; + } + } else { + wwarning(_("could not load domain %s from user defaults database"), + "WindowMaker"); + } + if (shared_dict) { + WMReleasePropList(shared_dict); + } } if (stat(WDWindowAttributes->path, &stbuf)>=0 - && WDWindowAttributes->timestamp < stbuf.st_mtime) { + && WDWindowAttributes->timestamp < stbuf.st_mtime) { #ifdef HEARTBEAT - puts("Checking WMWindowAttributes domain"); + puts("Checking WMWindowAttributes domain"); #endif - /* global dictionary */ + /* global dictionary */ shared_dict = readGlobalDomain("WMWindowAttributes", True); - /* user dictionary */ - dict = WMReadPropListFromFile(WDWindowAttributes->path); - if (dict) { - if (!WMIsPLDictionary(dict)) { - WMReleasePropList(dict); - dict = NULL; - wwarning(_("Domain %s (%s) of defaults database is corrupted!"), - "WMWindowAttributes", WDWindowAttributes->path); - } else { - if (shared_dict) { + /* user dictionary */ + dict = WMReadPropListFromFile(WDWindowAttributes->path); + if (dict) { + if (!WMIsPLDictionary(dict)) { + WMReleasePropList(dict); + dict = NULL; + wwarning(_("Domain %s (%s) of defaults database is corrupted!"), + "WMWindowAttributes", WDWindowAttributes->path); + } else { + if (shared_dict) { WMMergePLDictionaries(shared_dict, dict, True); - WMReleasePropList(dict); - dict = shared_dict; - shared_dict = NULL; - } + WMReleasePropList(dict); + dict = shared_dict; + shared_dict = NULL; + } if (WDWindowAttributes->dictionary) { WMReleasePropList(WDWindowAttributes->dictionary); } - WDWindowAttributes->dictionary = dict; - for (i=0; idictionary = dict; + for (i=0; itimestamp = stbuf.st_mtime; - if (shared_dict) { - WMReleasePropList(shared_dict); - } + } + } + } else { + wwarning(_("could not load domain %s from user defaults database"), + "WMWindowAttributes"); + } + WDWindowAttributes->timestamp = stbuf.st_mtime; + if (shared_dict) { + WMReleasePropList(shared_dict); + } } #ifndef LITE @@ -1211,7 +1211,7 @@ wDefaultsCheckDomains(void *foo) #endif /* !LITE */ if (!foo) - WMAddTimerHandler(DEFAULTS_CHECK_INTERVAL, wDefaultsCheckDomains, foo); + WMAddTimerHandler(DEFAULTS_CHECK_INTERVAL, wDefaultsCheckDomains, foo); } @@ -1224,133 +1224,133 @@ wReadDefaults(WScreen *scr, WMPropList *new_dict) int update_workspace_back = 0; /* kluge :/ */ int needs_refresh; void *tdata; - WMPropList *old_dict = (WDWindowMaker->dictionary!=new_dict - ? WDWindowMaker->dictionary : NULL); - + WMPropList *old_dict = (WDWindowMaker->dictionary!=new_dict + ? WDWindowMaker->dictionary : NULL); + must_update = 0; - + needs_refresh = 0; - + for (i=0; iplkey); - else - plvalue = NULL; + entry = &optionList[i]; - if (!old_dict) - old_value = NULL; - else - old_value = WMGetFromPLDictionary(old_dict, entry->plkey); + if (new_dict) + plvalue = WMGetFromPLDictionary(new_dict, entry->plkey); + else + plvalue = NULL; - - if (!plvalue && !old_value) { - /* no default in the DB. Use builtin default */ - plvalue = entry->plvalue; - if (plvalue && new_dict) { - WMPutInPLDictionary(new_dict, entry->plkey, plvalue); - must_update = 1; - } - } else if (!plvalue) { - /* value was deleted from DB. Keep current value */ - continue; - } else if (!old_value) { - /* set value for the 1st time */ - } else if (!WMIsPropListEqualTo(plvalue, old_value)) { - /* value has changed */ - } else { - - if (strcmp(entry->key, "WorkspaceBack") == 0 - && update_workspace_back - && scr->flags.backimage_helper_launched) { - } else { - /* value was not changed since last time */ - continue; - } - } - - if (plvalue) { + if (!old_dict) + old_value = NULL; + else + old_value = WMGetFromPLDictionary(old_dict, entry->plkey); + + + if (!plvalue && !old_value) { + /* no default in the DB. Use builtin default */ + plvalue = entry->plvalue; + if (plvalue && new_dict) { + WMPutInPLDictionary(new_dict, entry->plkey, plvalue); + must_update = 1; + } + } else if (!plvalue) { + /* value was deleted from DB. Keep current value */ + continue; + } else if (!old_value) { + /* set value for the 1st time */ + } else if (!WMIsPropListEqualTo(plvalue, old_value)) { + /* value has changed */ + } else { + + if (strcmp(entry->key, "WorkspaceBack") == 0 + && update_workspace_back + && scr->flags.backimage_helper_launched) { + } else { + /* value was not changed since last time */ + continue; + } + } + + if (plvalue) { #ifdef DEBUG - printf("Updating %s to %s\n", entry->key, - WMGetPropListDescription(plvalue, False)); + printf("Updating %s to %s\n", entry->key, + WMGetPropListDescription(plvalue, False)); #endif - /* convert data */ - if ((*entry->convert)(scr, entry, plvalue, entry->addr, &tdata)) { - /* - * If the WorkspaceSpecificBack data has been changed - * so that the helper will be launched now, we must be - * sure to send the default background texture config - * to the helper. - */ - if (strcmp(entry->key, "WorkspaceSpecificBack") == 0 - && !scr->flags.backimage_helper_launched) { - update_workspace_back = 1; - } - if (entry->update) { - needs_refresh |= - (*entry->update)(scr, entry, tdata, entry->extra_data); - } - } - } + /* convert data */ + if ((*entry->convert)(scr, entry, plvalue, entry->addr, &tdata)) { + /* + * If the WorkspaceSpecificBack data has been changed + * so that the helper will be launched now, we must be + * sure to send the default background texture config + * to the helper. + */ + if (strcmp(entry->key, "WorkspaceSpecificBack") == 0 + && !scr->flags.backimage_helper_launched) { + update_workspace_back = 1; + } + if (entry->update) { + needs_refresh |= + (*entry->update)(scr, entry, tdata, entry->extra_data); + } + } + } } if (needs_refresh!=0 && !scr->flags.startup) { - int foo; + int foo; - foo = 0; - if (needs_refresh & REFRESH_MENU_TITLE_TEXTURE) - foo |= WTextureSettings; - if (needs_refresh & REFRESH_MENU_TITLE_FONT) - foo |= WFontSettings; - if (needs_refresh & REFRESH_MENU_TITLE_COLOR) - foo |= WColorSettings; + foo = 0; + if (needs_refresh & REFRESH_MENU_TITLE_TEXTURE) + foo |= WTextureSettings; + if (needs_refresh & REFRESH_MENU_TITLE_FONT) + foo |= WFontSettings; + if (needs_refresh & REFRESH_MENU_TITLE_COLOR) + foo |= WColorSettings; if (foo) - WMPostNotificationName(WNMenuTitleAppearanceSettingsChanged, NULL, - (void*)foo); + WMPostNotificationName(WNMenuTitleAppearanceSettingsChanged, NULL, + (void*)foo); - foo = 0; - if (needs_refresh & REFRESH_MENU_TEXTURE) - foo |= WTextureSettings; - if (needs_refresh & REFRESH_MENU_FONT) - foo |= WFontSettings; - if (needs_refresh & REFRESH_MENU_COLOR) - foo |= WColorSettings; + foo = 0; + if (needs_refresh & REFRESH_MENU_TEXTURE) + foo |= WTextureSettings; + if (needs_refresh & REFRESH_MENU_FONT) + foo |= WFontSettings; + if (needs_refresh & REFRESH_MENU_COLOR) + foo |= WColorSettings; if (foo) - WMPostNotificationName(WNMenuAppearanceSettingsChanged, NULL, - (void*)foo); + WMPostNotificationName(WNMenuAppearanceSettingsChanged, NULL, + (void*)foo); - foo = 0; + foo = 0; if (needs_refresh & REFRESH_WINDOW_FONT) { - foo |= WFontSettings; - } - if (needs_refresh & REFRESH_WINDOW_TEXTURES) { - foo |= WTextureSettings; - } - if (needs_refresh & REFRESH_WINDOW_TITLE_COLOR) { - foo |= WColorSettings; - } - if (foo) - WMPostNotificationName(WNWindowAppearanceSettingsChanged, NULL, - (void*)foo); + foo |= WFontSettings; + } + if (needs_refresh & REFRESH_WINDOW_TEXTURES) { + foo |= WTextureSettings; + } + if (needs_refresh & REFRESH_WINDOW_TITLE_COLOR) { + foo |= WColorSettings; + } + if (foo) + WMPostNotificationName(WNWindowAppearanceSettingsChanged, NULL, + (void*)foo); - if (!(needs_refresh & REFRESH_ICON_TILE)) { - foo = 0; - if (needs_refresh & REFRESH_ICON_FONT) { - foo |= WFontSettings; - } - if (needs_refresh & REFRESH_ICON_TITLE_COLOR) { - foo |= WTextureSettings; - } - if (needs_refresh & REFRESH_ICON_TITLE_BACK) { - foo |= WTextureSettings; - } - if (foo) - WMPostNotificationName(WNIconAppearanceSettingsChanged, NULL, - (void*)foo); - } + if (!(needs_refresh & REFRESH_ICON_TILE)) { + foo = 0; + if (needs_refresh & REFRESH_ICON_FONT) { + foo |= WFontSettings; + } + if (needs_refresh & REFRESH_ICON_TITLE_COLOR) { + foo |= WTextureSettings; + } + if (needs_refresh & REFRESH_ICON_TITLE_BACK) { + foo |= WTextureSettings; + } + if (foo) + WMPostNotificationName(WNIconAppearanceSettingsChanged, NULL, + (void*)foo); + } if (needs_refresh & REFRESH_ICON_TILE) - WMPostNotificationName(WNIconTileSettingsChanged, NULL, NULL); + WMPostNotificationName(WNIconTileSettingsChanged, NULL, NULL); } } @@ -1364,7 +1364,7 @@ wDefaultUpdateIcons(WScreen *scr) while(aicon) { file = wDefaultGetIconFile(scr, aicon->wm_instance, aicon->wm_class, - False); + False); if ((file && aicon->icon->file && strcmp(file, aicon->icon->file)!=0) || (file && !aicon->icon->file)) { RImage *new_image; @@ -1374,7 +1374,7 @@ wDefaultUpdateIcons(WScreen *scr) aicon->icon->file = wstrdup(file); new_image = wDefaultGetImage(scr, aicon->wm_instance, - aicon->wm_class); + aicon->wm_class); if (new_image) { wIconChangeImage(aicon->icon, new_image); wAppIconPaint(aicon); @@ -1389,7 +1389,7 @@ wDefaultUpdateIcons(WScreen *scr) while (wwin) { if (wwin->icon && wwin->flags.miniaturized) { file = wDefaultGetIconFile(scr, wwin->wm_instance, wwin->wm_class, - False); + False); if ((file && wwin->icon->file && strcmp(file, wwin->icon->file)!=0) || (file && !wwin->icon->file)) { RImage *new_image; @@ -1399,7 +1399,7 @@ wDefaultUpdateIcons(WScreen *scr) wwin->icon->file = wstrdup(file); new_image = wDefaultGetImage(scr, wwin->wm_instance, - wwin->wm_class); + wwin->wm_class); if (new_image) wIconChangeImage(wwin->icon, new_image); } @@ -1412,44 +1412,44 @@ wDefaultUpdateIcons(WScreen *scr) /* --------------------------- Local ----------------------- */ #define GET_STRING_OR_DEFAULT(x, var) if (!WMIsPLString(value)) { \ - wwarning(_("Wrong option format for key \"%s\". Should be %s."), \ - entry->key, x); \ - wwarning(_("using default \"%s\" instead"), entry->default_value); \ - var = entry->default_value;\ - } else var = WMGetFromPLString(value)\ + wwarning(_("Wrong option format for key \"%s\". Should be %s."), \ + entry->key, x); \ + wwarning(_("using default \"%s\" instead"), entry->default_value); \ + var = entry->default_value;\ + } else var = WMGetFromPLString(value)\ + - static int string2index(WMPropList *key, WMPropList *val, char *def, - WOptionEnumeration *values) + WOptionEnumeration *values) { char *str; WOptionEnumeration *v; char buffer[TOTAL_VALUES_LENGTH]; if (WMIsPLString(val) && (str = WMGetFromPLString(val))) { - for (v=values; v->string!=NULL; v++) { - if (strcasecmp(v->string, str)==0) - return v->value; - } + for (v=values; v->string!=NULL; v++) { + if (strcasecmp(v->string, str)==0) + return v->value; + } } buffer[0] = 0; for (v=values; v->string!=NULL; v++) { - if (!v->is_alias) { - if (buffer[0]!=0) - strcat(buffer, ", "); - strcat(buffer, v->string); - } + if (!v->is_alias) { + if (buffer[0]!=0) + strcat(buffer, ", "); + strcat(buffer, v->string); + } } wwarning(_("wrong option value for key \"%s\". Should be one of %s"), - WMGetFromPLString(key), buffer); + WMGetFromPLString(key), buffer); if (def) { - return string2index(key, val, NULL, values); + return string2index(key, val, NULL, values); } return -1; @@ -1464,9 +1464,9 @@ string2index(WMPropList *key, WMPropList *val, char *def, * ret - is the address to store a pointer to a temporary buffer. ret * must not be freed and is used by the set functions */ -static int +static int getBool(WScreen *scr, WDefaultEntry *entry, WMPropList *value, void *addr, - void **ret) + void **ret) { static char data; char *val; @@ -1476,53 +1476,53 @@ getBool(WScreen *scr, WDefaultEntry *entry, WMPropList *value, void *addr, again: if ((val[1]=='\0' && (val[0]=='y' || val[0]=='Y')) - || strcasecmp(val, "YES")==0) { + || strcasecmp(val, "YES")==0) { - data = 1; + data = 1; } else if ((val[1]=='\0' && (val[0]=='n' || val[0]=='N')) - || strcasecmp(val, "NO")==0) { - data = 0; + || strcasecmp(val, "NO")==0) { + data = 0; } else { - int i; - if (sscanf(val, "%i", &i)==1) { - if (i!=0) - data = 1; - else - data = 0; - } else { - wwarning(_("can't convert \"%s\" to boolean for key \"%s\""), - val, entry->key); - if (second_pass==0) { - val = WMGetFromPLString(entry->plvalue); - second_pass = 1; - wwarning(_("using default \"%s\" instead"), val); - goto again; - } - return False; - } + int i; + if (sscanf(val, "%i", &i)==1) { + if (i!=0) + data = 1; + else + data = 0; + } else { + wwarning(_("can't convert \"%s\" to boolean for key \"%s\""), + val, entry->key); + if (second_pass==0) { + val = WMGetFromPLString(entry->plvalue); + second_pass = 1; + wwarning(_("using default \"%s\" instead"), val); + goto again; + } + return False; + } } - + if (ret) - *ret = &data; - + *ret = &data; + if (addr) { - *(char*)addr = data; + *(char*)addr = data; } - + return True; } -static int +static int getInt(WScreen *scr, WDefaultEntry *entry, WMPropList *value, void *addr, void **ret) { static int data; char *val; - - + + GET_STRING_OR_DEFAULT("Integer", val); - + if (sscanf(val, "%i", &data)!=1) { wwarning(_("can't convert \"%s\" to integer for key \"%s\""), val, entry->key); @@ -1532,18 +1532,18 @@ getInt(WScreen *scr, WDefaultEntry *entry, WMPropList *value, void *addr, return False; } } - + if (ret) - *ret = &data; - + *ret = &data; + if (addr) { - *(int*)addr = data; + *(int*)addr = data; } return True; } -static int +static int getCoord(WScreen *scr, WDefaultEntry *entry, WMPropList *value, void *addr, void **ret) { @@ -1580,7 +1580,7 @@ again: elem_x = WMGetFromPLArray(value, 0); elem_y = WMGetFromPLArray(value, 1); - + if (!elem_x || !elem_y || !WMIsPLString(elem_x) || !WMIsPLString(elem_y)) { wwarning(_("Wrong value for key \"%s\". Should be Coordinate."), entry->key); @@ -1629,34 +1629,34 @@ again: #if 0 /* This function is not used at the moment. */ -static int -getString(WScreen *scr, WDefaultEntry *entry, WMPropList *value, void *addr, - void **ret) +static int +getString(WScreen *scr, WDefaultEntry *entry, WMPropList *value, void *addr, + void **ret) { static char *data; - + GET_STRING_OR_DEFAULT("String", data); - + if (!data) { data = WMGetFromPLString(entry->plvalue); if (!data) return False; } - + if (ret) - *ret = &data; - + *ret = &data; + if (addr) - *(char**)addr = wstrdup(data); - + *(char**)addr = wstrdup(data); + return True; } #endif -static int +static int getPathList(WScreen *scr, WDefaultEntry *entry, WMPropList *value, void *addr, - void **ret) + void **ret) { static char *data; int i, count, len; @@ -1666,7 +1666,7 @@ getPathList(WScreen *scr, WDefaultEntry *entry, WMPropList *value, void *addr, again: if (!WMIsPLArray(value)) { - wwarning(_("Wrong option format for key \"%s\". Should be %s."), + wwarning(_("Wrong option format for key \"%s\". Should be %s."), entry->key, "an array of paths"); if (changed==0) { value = entry->plvalue; @@ -1674,7 +1674,7 @@ again: wwarning(_("using default \"%s\" instead"), entry->default_value); goto again; } - return False; + return False; } i = 0; @@ -1691,30 +1691,30 @@ again: len = 0; for (i=0; iplkey, value, entry->default_value, - (WOptionEnumeration*)entry->extra_data); + (WOptionEnumeration*)entry->extra_data); if (data < 0) - return False; + return False; if (ret) - *ret = &data; + *ret = &data; if (addr) - *(signed char*)addr = data; - - return True; + *(signed char*)addr = data; + + return True; } @@ -1769,384 +1769,384 @@ parse_texture(WScreen *scr, WMPropList *pl) char *val; int nelem; WTexture *texture=NULL; - + nelem = WMGetPropListItemCount(pl); if (nelem < 1) - return NULL; - - + return NULL; + + elem = WMGetFromPLArray(pl, 0); if (!elem || !WMIsPLString(elem)) - return NULL; + return NULL; val = WMGetFromPLString(elem); - + if (strcasecmp(val, "solid")==0) { - XColor color; + XColor color; - if (nelem != 2) - return NULL; + if (nelem != 2) + return NULL; - /* get color */ - - elem = WMGetFromPLArray(pl, 1); - if (!elem || !WMIsPLString(elem)) - return NULL; - val = WMGetFromPLString(elem); + /* get color */ - if (!XParseColor(dpy, scr->w_colormap, val, &color)) { - wwarning(_("\"%s\" is not a valid color name"), val); - return NULL; - } - - texture = (WTexture*)wTextureMakeSolid(scr, &color); + elem = WMGetFromPLArray(pl, 1); + if (!elem || !WMIsPLString(elem)) + return NULL; + val = WMGetFromPLString(elem); + + if (!XParseColor(dpy, scr->w_colormap, val, &color)) { + wwarning(_("\"%s\" is not a valid color name"), val); + return NULL; + } + + texture = (WTexture*)wTextureMakeSolid(scr, &color); } else if (strcasecmp(val, "dgradient")==0 - || strcasecmp(val, "vgradient")==0 - || strcasecmp(val, "hgradient")==0) { - RColor color1, color2; - XColor xcolor; - int type; - - if (nelem != 3) { - wwarning(_("bad number of arguments in gradient specification")); - return NULL; - } - - if (val[0]=='d' || val[0]=='D') - type = WTEX_DGRADIENT; - else if (val[0]=='h' || val[0]=='H') - type = WTEX_HGRADIENT; - else - type = WTEX_VGRADIENT; - - - /* get from color */ - elem = WMGetFromPLArray(pl, 1); - if (!elem || !WMIsPLString(elem)) - return NULL; - val = WMGetFromPLString(elem); - - if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) { - wwarning(_("\"%s\" is not a valid color name"), val); - return NULL; - } - color1.alpha = 255; - color1.red = xcolor.red >> 8; - color1.green = xcolor.green >> 8; - color1.blue = xcolor.blue >> 8; - - /* get to color */ - elem = WMGetFromPLArray(pl, 2); - if (!elem || !WMIsPLString(elem)) { - return NULL; - } - val = WMGetFromPLString(elem); - - if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) { - wwarning(_("\"%s\" is not a valid color name"), val); - return NULL; - } - color2.alpha = 255; - color2.red = xcolor.red >> 8; - color2.green = xcolor.green >> 8; - color2.blue = xcolor.blue >> 8; - - texture = (WTexture*)wTextureMakeGradient(scr, type, &color1, &color2); - - } else if (strcasecmp(val, "igradient")==0) { - RColor colors1[2], colors2[2]; - int th1, th2; - XColor xcolor; - int i; - - if (nelem != 7) { - wwarning(_("bad number of arguments in gradient specification")); - return NULL; - } - - /* get from color */ - for (i = 0; i < 2; i++) { - elem = WMGetFromPLArray(pl, 1+i); - if (!elem || !WMIsPLString(elem)) - return NULL; - val = WMGetFromPLString(elem); - - if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) { - wwarning(_("\"%s\" is not a valid color name"), val); - return NULL; - } - colors1[i].alpha = 255; - colors1[i].red = xcolor.red >> 8; - colors1[i].green = xcolor.green >> 8; - colors1[i].blue = xcolor.blue >> 8; - } - elem = WMGetFromPLArray(pl, 3); - if (!elem || !WMIsPLString(elem)) - return NULL; - val = WMGetFromPLString(elem); - th1 = atoi(val); - - - /* get from color */ - for (i = 0; i < 2; i++) { - elem = WMGetFromPLArray(pl, 4+i); - if (!elem || !WMIsPLString(elem)) - return NULL; - val = WMGetFromPLString(elem); - - if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) { - wwarning(_("\"%s\" is not a valid color name"), val); - return NULL; - } - colors2[i].alpha = 255; - colors2[i].red = xcolor.red >> 8; - colors2[i].green = xcolor.green >> 8; - colors2[i].blue = xcolor.blue >> 8; - } - elem = WMGetFromPLArray(pl, 6); - if (!elem || !WMIsPLString(elem)) - return NULL; - val = WMGetFromPLString(elem); - th2 = atoi(val); - - texture = (WTexture*)wTextureMakeIGradient(scr, th1, colors1, - th2, colors2); - - } else if (strcasecmp(val, "mhgradient")==0 - || strcasecmp(val, "mvgradient")==0 - || strcasecmp(val, "mdgradient")==0) { - XColor color; - RColor **colors; - int i, count; - int type; - - if (nelem < 3) { - wwarning(_("too few arguments in multicolor gradient specification")); - return NULL; - } - - if (val[1]=='h' || val[1]=='H') - type = WTEX_MHGRADIENT; - else if (val[1]=='v' || val[1]=='V') - type = WTEX_MVGRADIENT; - else - type = WTEX_MDGRADIENT; - - count = nelem-1; - - colors = wmalloc(sizeof(RColor*)*(count+1)); - - for (i=0; i=0; --i) { - wfree(colors[i]); - } - wfree(colors); - return NULL; - } - val = WMGetFromPLString(elem); - - if (!XParseColor(dpy, scr->w_colormap, val, &color)) { - wwarning(_("\"%s\" is not a valid color name"), val); - for (--i; i>=0; --i) { - wfree(colors[i]); - } - wfree(colors); - return NULL; - } else { - colors[i] = wmalloc(sizeof(RColor)); - colors[i]->red = color.red >> 8; - colors[i]->green = color.green >> 8; - colors[i]->blue = color.blue >> 8; - } - } - colors[i] = NULL; - - texture = (WTexture*)wTextureMakeMGradient(scr, type, colors); - } else if (strcasecmp(val, "spixmap")==0 || - strcasecmp(val, "cpixmap")==0 || - strcasecmp(val, "tpixmap")==0) { - XColor color; + || strcasecmp(val, "vgradient")==0 + || strcasecmp(val, "hgradient")==0) { + RColor color1, color2; + XColor xcolor; int type; - if (nelem != 3) - return NULL; + if (nelem != 3) { + wwarning(_("bad number of arguments in gradient specification")); + return NULL; + } + + if (val[0]=='d' || val[0]=='D') + type = WTEX_DGRADIENT; + else if (val[0]=='h' || val[0]=='H') + type = WTEX_HGRADIENT; + else + type = WTEX_VGRADIENT; + + + /* get from color */ + elem = WMGetFromPLArray(pl, 1); + if (!elem || !WMIsPLString(elem)) + return NULL; + val = WMGetFromPLString(elem); + + if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) { + wwarning(_("\"%s\" is not a valid color name"), val); + return NULL; + } + color1.alpha = 255; + color1.red = xcolor.red >> 8; + color1.green = xcolor.green >> 8; + color1.blue = xcolor.blue >> 8; + + /* get to color */ + elem = WMGetFromPLArray(pl, 2); + if (!elem || !WMIsPLString(elem)) { + return NULL; + } + val = WMGetFromPLString(elem); + + if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) { + wwarning(_("\"%s\" is not a valid color name"), val); + return NULL; + } + color2.alpha = 255; + color2.red = xcolor.red >> 8; + color2.green = xcolor.green >> 8; + color2.blue = xcolor.blue >> 8; + + texture = (WTexture*)wTextureMakeGradient(scr, type, &color1, &color2); + + } else if (strcasecmp(val, "igradient")==0) { + RColor colors1[2], colors2[2]; + int th1, th2; + XColor xcolor; + int i; + + if (nelem != 7) { + wwarning(_("bad number of arguments in gradient specification")); + return NULL; + } + + /* get from color */ + for (i = 0; i < 2; i++) { + elem = WMGetFromPLArray(pl, 1+i); + if (!elem || !WMIsPLString(elem)) + return NULL; + val = WMGetFromPLString(elem); + + if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) { + wwarning(_("\"%s\" is not a valid color name"), val); + return NULL; + } + colors1[i].alpha = 255; + colors1[i].red = xcolor.red >> 8; + colors1[i].green = xcolor.green >> 8; + colors1[i].blue = xcolor.blue >> 8; + } + elem = WMGetFromPLArray(pl, 3); + if (!elem || !WMIsPLString(elem)) + return NULL; + val = WMGetFromPLString(elem); + th1 = atoi(val); + + + /* get from color */ + for (i = 0; i < 2; i++) { + elem = WMGetFromPLArray(pl, 4+i); + if (!elem || !WMIsPLString(elem)) + return NULL; + val = WMGetFromPLString(elem); + + if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) { + wwarning(_("\"%s\" is not a valid color name"), val); + return NULL; + } + colors2[i].alpha = 255; + colors2[i].red = xcolor.red >> 8; + colors2[i].green = xcolor.green >> 8; + colors2[i].blue = xcolor.blue >> 8; + } + elem = WMGetFromPLArray(pl, 6); + if (!elem || !WMIsPLString(elem)) + return NULL; + val = WMGetFromPLString(elem); + th2 = atoi(val); + + texture = (WTexture*)wTextureMakeIGradient(scr, th1, colors1, + th2, colors2); + + } else if (strcasecmp(val, "mhgradient")==0 + || strcasecmp(val, "mvgradient")==0 + || strcasecmp(val, "mdgradient")==0) { + XColor color; + RColor **colors; + int i, count; + int type; + + if (nelem < 3) { + wwarning(_("too few arguments in multicolor gradient specification")); + return NULL; + } + + if (val[1]=='h' || val[1]=='H') + type = WTEX_MHGRADIENT; + else if (val[1]=='v' || val[1]=='V') + type = WTEX_MVGRADIENT; + else + type = WTEX_MDGRADIENT; + + count = nelem-1; + + colors = wmalloc(sizeof(RColor*)*(count+1)); + + for (i=0; i=0; --i) { + wfree(colors[i]); + } + wfree(colors); + return NULL; + } + val = WMGetFromPLString(elem); + + if (!XParseColor(dpy, scr->w_colormap, val, &color)) { + wwarning(_("\"%s\" is not a valid color name"), val); + for (--i; i>=0; --i) { + wfree(colors[i]); + } + wfree(colors); + return NULL; + } else { + colors[i] = wmalloc(sizeof(RColor)); + colors[i]->red = color.red >> 8; + colors[i]->green = color.green >> 8; + colors[i]->blue = color.blue >> 8; + } + } + colors[i] = NULL; + + texture = (WTexture*)wTextureMakeMGradient(scr, type, colors); + } else if (strcasecmp(val, "spixmap")==0 || + strcasecmp(val, "cpixmap")==0 || + strcasecmp(val, "tpixmap")==0) { + XColor color; + int type; + + if (nelem != 3) + return NULL; if (val[0] == 's' || val[0] == 'S') type = WTP_SCALE; else if (val[0] == 'c' || val[0] == 'C') - type = WTP_CENTER; - else + type = WTP_CENTER; + else type = WTP_TILE; - /* get color */ - elem = WMGetFromPLArray(pl, 2); - if (!elem || !WMIsPLString(elem)) { - return NULL; - } - val = WMGetFromPLString(elem); + /* get color */ + elem = WMGetFromPLArray(pl, 2); + if (!elem || !WMIsPLString(elem)) { + return NULL; + } + val = WMGetFromPLString(elem); - if (!XParseColor(dpy, scr->w_colormap, val, &color)) { - wwarning(_("\"%s\" is not a valid color name"), val); - return NULL; - } - - /* file name */ - elem = WMGetFromPLArray(pl, 1); - if (!elem || !WMIsPLString(elem)) - return NULL; - val = WMGetFromPLString(elem); + if (!XParseColor(dpy, scr->w_colormap, val, &color)) { + wwarning(_("\"%s\" is not a valid color name"), val); + return NULL; + } - texture = (WTexture*)wTextureMakePixmap(scr, type, val, &color); + /* file name */ + elem = WMGetFromPLArray(pl, 1); + if (!elem || !WMIsPLString(elem)) + return NULL; + val = WMGetFromPLString(elem); + + texture = (WTexture*)wTextureMakePixmap(scr, type, val, &color); } else if (strcasecmp(val, "thgradient")==0 - || strcasecmp(val, "tvgradient")==0 - || strcasecmp(val, "tdgradient")==0) { - RColor color1, color2; - XColor xcolor; - int opacity; - int style; + || strcasecmp(val, "tvgradient")==0 + || strcasecmp(val, "tdgradient")==0) { + RColor color1, color2; + XColor xcolor; + int opacity; + int style; - if (val[1]=='h' || val[1]=='H') - style = WTEX_THGRADIENT; - else if (val[1]=='v' || val[1]=='V') - style = WTEX_TVGRADIENT; - else - style = WTEX_TDGRADIENT; + if (val[1]=='h' || val[1]=='H') + style = WTEX_THGRADIENT; + else if (val[1]=='v' || val[1]=='V') + style = WTEX_TVGRADIENT; + else + style = WTEX_TDGRADIENT; - if (nelem != 5) { - wwarning(_("bad number of arguments in textured gradient specification")); - return NULL; - } - - /* get from color */ - elem = WMGetFromPLArray(pl, 3); - if (!elem || !WMIsPLString(elem)) - return NULL; - val = WMGetFromPLString(elem); + if (nelem != 5) { + wwarning(_("bad number of arguments in textured gradient specification")); + return NULL; + } - if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) { - wwarning(_("\"%s\" is not a valid color name"), val); - return NULL; - } - color1.alpha = 255; - color1.red = xcolor.red >> 8; - color1.green = xcolor.green >> 8; - color1.blue = xcolor.blue >> 8; + /* get from color */ + elem = WMGetFromPLArray(pl, 3); + if (!elem || !WMIsPLString(elem)) + return NULL; + val = WMGetFromPLString(elem); - /* get to color */ - elem = WMGetFromPLArray(pl, 4); - if (!elem || !WMIsPLString(elem)) { - return NULL; - } - val = WMGetFromPLString(elem); + if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) { + wwarning(_("\"%s\" is not a valid color name"), val); + return NULL; + } + color1.alpha = 255; + color1.red = xcolor.red >> 8; + color1.green = xcolor.green >> 8; + color1.blue = xcolor.blue >> 8; - if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) { - wwarning(_("\"%s\" is not a valid color name"), val); - return NULL; - } - color2.alpha = 255; - color2.red = xcolor.red >> 8; - color2.green = xcolor.green >> 8; - color2.blue = xcolor.blue >> 8; + /* get to color */ + elem = WMGetFromPLArray(pl, 4); + if (!elem || !WMIsPLString(elem)) { + return NULL; + } + val = WMGetFromPLString(elem); - /* get opacity */ - elem = WMGetFromPLArray(pl, 2); - if (!elem || !WMIsPLString(elem)) - opacity = 128; - else - val = WMGetFromPLString(elem); - - if (!val || (opacity = atoi(val)) < 0 || opacity > 255) { - wwarning(_("bad opacity value for tgradient texture \"%s\". Should be [0..255]"), val); - opacity = 128; - } + if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) { + wwarning(_("\"%s\" is not a valid color name"), val); + return NULL; + } + color2.alpha = 255; + color2.red = xcolor.red >> 8; + color2.green = xcolor.green >> 8; + color2.blue = xcolor.blue >> 8; - /* get file name */ - elem = WMGetFromPLArray(pl, 1); - if (!elem || !WMIsPLString(elem)) - return NULL; - val = WMGetFromPLString(elem); + /* get opacity */ + elem = WMGetFromPLArray(pl, 2); + if (!elem || !WMIsPLString(elem)) + opacity = 128; + else + val = WMGetFromPLString(elem); - texture = (WTexture*)wTextureMakeTGradient(scr, style, &color1, &color2, - val, opacity); + if (!val || (opacity = atoi(val)) < 0 || opacity > 255) { + wwarning(_("bad opacity value for tgradient texture \"%s\". Should be [0..255]"), val); + opacity = 128; + } + + /* get file name */ + elem = WMGetFromPLArray(pl, 1); + if (!elem || !WMIsPLString(elem)) + return NULL; + val = WMGetFromPLString(elem); + + texture = (WTexture*)wTextureMakeTGradient(scr, style, &color1, &color2, + val, opacity); } #ifdef TEXTURE_PLUGIN else if (strcasecmp(val, "function")==0) { - WTexFunction *function; - void (*initFunc) (Display *, Colormap); - char *lib, *func, **argv; - int i, argc; + WTexFunction *function; + void (*initFunc) (Display *, Colormap); + char *lib, *func, **argv; + int i, argc; if (nelem < 3) - return NULL; + return NULL; - /* get the library name */ - elem = WMGetFromPLArray(pl, 1); - if (!elem || !WMIsPLString(elem)) { - return NULL; - } - lib = WMGetFromPLString(elem); + /* get the library name */ + elem = WMGetFromPLArray(pl, 1); + if (!elem || !WMIsPLString(elem)) { + return NULL; + } + lib = WMGetFromPLString(elem); - /* get the function name */ - elem = WMGetFromPLArray(pl, 2); - if (!elem || !WMIsPLString(elem)) { - return NULL; - } - func = WMGetFromPLString(elem); + /* get the function name */ + elem = WMGetFromPLArray(pl, 2); + if (!elem || !WMIsPLString(elem)) { + return NULL; + } + func = WMGetFromPLString(elem); - argc = nelem - 2; - argv = (char **)wmalloc(argc * sizeof(char *)); + argc = nelem - 2; + argv = (char **)wmalloc(argc * sizeof(char *)); - /* get the parameters */ - argv[0] = wstrdup(func); - for (i = 0; i < argc - 1; i++) { - elem = WMGetFromPLArray(pl, 3 + i); - if (!elem || !WMIsPLString(elem)) { - wfree(argv); + /* get the parameters */ + argv[0] = wstrdup(func); + for (i = 0; i < argc - 1; i++) { + elem = WMGetFromPLArray(pl, 3 + i); + if (!elem || !WMIsPLString(elem)) { + wfree(argv); - return NULL; - } - argv[i+1] = wstrdup(WMGetFromPLString(elem)); - } + return NULL; + } + argv[i+1] = wstrdup(WMGetFromPLString(elem)); + } - function = wTextureMakeFunction(scr, lib, func, argc, argv); + function = wTextureMakeFunction(scr, lib, func, argc, argv); #ifdef HAVE_DLFCN_H - if (function) { - initFunc = dlsym(function->handle, "initWindowMaker"); - if (initFunc) { - initFunc(dpy, scr->w_colormap); - } else { - wwarning(_("could not initialize library %s"), lib); - } - } else { - wwarning(_("could not find function %s::%s"), lib, func); - } + if (function) { + initFunc = dlsym(function->handle, "initWindowMaker"); + if (initFunc) { + initFunc(dpy, scr->w_colormap); + } else { + wwarning(_("could not initialize library %s"), lib); + } + } else { + wwarning(_("could not find function %s::%s"), lib, func); + } #endif /* HAVE_DLFCN_H */ - texture = (WTexture*)function; + texture = (WTexture*)function; } #endif /* TEXTURE_PLUGIN */ else { - wwarning(_("invalid texture type %s"), val); - return NULL; + wwarning(_("invalid texture type %s"), val); + return NULL; } return texture; } -static int +static int getTexture(WScreen *scr, WDefaultEntry *entry, WMPropList *value, void *addr, - void **ret) + void **ret) { static WTexture *texture; int changed=0; again: - if (!WMIsPLArray(value)) { - wwarning(_("Wrong option format for key \"%s\". Should be %s."), - entry->key, "Texture"); + if (!WMIsPLArray(value)) { + wwarning(_("Wrong option format for key \"%s\". Should be %s."), + entry->key, "Texture"); if (changed==0) { value = entry->plvalue; changed = 1; @@ -2155,28 +2155,28 @@ again: } return False; } - - if (strcmp(entry->key, "WidgetColor")==0 && !changed) { - WMPropList *pl; - - pl = WMGetFromPLArray(value, 0); - if (!pl || !WMIsPLString(pl) || !WMGetFromPLString(pl) - || strcasecmp(WMGetFromPLString(pl), "solid")!=0) { - wwarning(_("Wrong option format for key \"%s\". Should be %s."), - entry->key, "Solid Texture"); - value = entry->plvalue; - changed = 1; - wwarning(_("using default \"%s\" instead"), entry->default_value); - goto again; - } + if (strcmp(entry->key, "WidgetColor")==0 && !changed) { + WMPropList *pl; + + pl = WMGetFromPLArray(value, 0); + if (!pl || !WMIsPLString(pl) || !WMGetFromPLString(pl) + || strcasecmp(WMGetFromPLString(pl), "solid")!=0) { + wwarning(_("Wrong option format for key \"%s\". Should be %s."), + entry->key, "Solid Texture"); + + value = entry->plvalue; + changed = 1; + wwarning(_("using default \"%s\" instead"), entry->default_value); + goto again; + } } texture = parse_texture(scr, value); if (!texture) { - wwarning(_("Error in texture specification for key \"%s\""), - entry->key); + wwarning(_("Error in texture specification for key \"%s\""), + entry->key); if (changed==0) { value = entry->plvalue; changed = 1; @@ -2185,20 +2185,20 @@ again: } return False; } - - if (ret) - *ret = &texture; + + if (ret) + *ret = &texture; if (addr) - *(WTexture**)addr = texture; - + *(WTexture**)addr = texture; + return True; } static int getWSBackground(WScreen *scr, WDefaultEntry *entry, WMPropList *value, - void *addr, void **ret) + void *addr, void **ret) { WMPropList *elem; int changed = 0; @@ -2207,7 +2207,7 @@ getWSBackground(WScreen *scr, WDefaultEntry *entry, WMPropList *value, again: if (!WMIsPLArray(value)) { - wwarning(_("Wrong option format for key \"%s\". Should be %s."), + wwarning(_("Wrong option format for key \"%s\". Should be %s."), "WorkspaceBack", "Texture or None"); if (changed==0) { value = entry->plvalue; @@ -2222,21 +2222,21 @@ again: nelem = WMGetPropListItemCount(value); if (nelem > 0) { - elem = WMGetFromPLArray(value, 0); - if (!elem || !WMIsPLString(elem)) { - wwarning(_("Wrong type for workspace background. Should be a texture type.")); - if (changed==0) { - value = entry->plvalue; - changed = 1; - wwarning(_("using default \"%s\" instead"), entry->default_value); - goto again; - } - return False; - } - val = WMGetFromPLString(elem); + elem = WMGetFromPLArray(value, 0); + if (!elem || !WMIsPLString(elem)) { + wwarning(_("Wrong type for workspace background. Should be a texture type.")); + if (changed==0) { + value = entry->plvalue; + changed = 1; + wwarning(_("using default \"%s\" instead"), entry->default_value); + goto again; + } + return False; + } + val = WMGetFromPLString(elem); - if (strcasecmp(val, "None")==0) - return True; + if (strcasecmp(val, "None")==0) + return True; } *ret = WMRetainPropList(value); @@ -2246,7 +2246,7 @@ again: static int getWSSpecificBackground(WScreen *scr, WDefaultEntry *entry, WMPropList *value, - void *addr, void **ret) + void *addr, void **ret) { WMPropList *elem; int nelem; @@ -2254,7 +2254,7 @@ getWSSpecificBackground(WScreen *scr, WDefaultEntry *entry, WMPropList *value, again: if (!WMIsPLArray(value)) { - wwarning(_("Wrong option format for key \"%s\". Should be %s."), + wwarning(_("Wrong option format for key \"%s\". Should be %s."), "WorkspaceSpecificBack", "an array of textures"); if (changed==0) { value = entry->plvalue; @@ -2269,19 +2269,19 @@ again: nelem = WMGetPropListItemCount(value); if (nelem > 0) { - while (nelem--) { - elem = WMGetFromPLArray(value, nelem); - if (!elem || !WMIsPLArray(elem)) { - wwarning(_("Wrong type for background of workspace %i. Should be a texture."), - nelem); - } - } + while (nelem--) { + elem = WMGetFromPLArray(value, nelem); + if (!elem || !WMIsPLArray(elem)) { + wwarning(_("Wrong type for background of workspace %i. Should be a texture."), + nelem); + } + } } *ret = WMRetainPropList(value); #ifdef notworking - /* + /* * Kluge to force wmsetbg helper to set the default background. * If the WorkspaceSpecificBack is changed once wmaker has started, * the WorkspaceBack won't be sent to the helper, unless the user @@ -2289,20 +2289,20 @@ again: * value from the defaults DB. */ if (!scr->flags.backimage_helper_launched && !scr->flags.startup) { - WMPropList *key = WMCreatePLString("WorkspaceBack"); + WMPropList *key = WMCreatePLString("WorkspaceBack"); - WMRemoveFromPLDictionary(WDWindowMaker->dictionary, key); + WMRemoveFromPLDictionary(WDWindowMaker->dictionary, key); - WMReleasePropList(key); + WMReleasePropList(key); } #endif return True; } -static int -getFont(WScreen *scr, WDefaultEntry *entry, WMPropList *value, void *addr, - void **ret) +static int +getFont(WScreen *scr, WDefaultEntry *entry, WMPropList *value, void *addr, + void **ret) { static WMFont *font; char *val; @@ -2311,33 +2311,33 @@ getFont(WScreen *scr, WDefaultEntry *entry, WMPropList *value, void *addr, font = WMCreateFont(scr->wmscreen, val); if (!font) - font = WMCreateFont(scr->wmscreen, "fixed"); + font = WMCreateFont(scr->wmscreen, "fixed"); if (!font) { - wfatal(_("could not load any usable font!!!")); - exit(1); + wfatal(_("could not load any usable font!!!")); + exit(1); } if (ret) - *ret = font; + *ret = font; /* can't assign font value outside update function */ wassertrv(addr == NULL, True); - + return True; } -static int -getColor(WScreen *scr, WDefaultEntry *entry, WMPropList *value, void *addr, - void **ret) +static int +getColor(WScreen *scr, WDefaultEntry *entry, WMPropList *value, void *addr, + void **ret) { static XColor color; char *val; int second_pass=0; GET_STRING_OR_DEFAULT("Color", val); - + again: if (!wGetColor(scr, val, &color)) { @@ -2353,22 +2353,22 @@ again: } if (ret) - *ret = &color; - + *ret = &color; + assert(addr==NULL); /* - if (addr) - *(unsigned long*)addr = pixel; + if (addr) + *(unsigned long*)addr = pixel; */ - + return True; } static int -getKeybind(WScreen *scr, WDefaultEntry *entry, WMPropList *value, void *addr, - void **ret) +getKeybind(WScreen *scr, WDefaultEntry *entry, WMPropList *value, void *addr, + void **ret) { static WShortKey shortcut; KeySym ksym; @@ -2380,58 +2380,58 @@ getKeybind(WScreen *scr, WDefaultEntry *entry, WMPropList *value, void *addr, GET_STRING_OR_DEFAULT("Key spec", val); if (!val || strcasecmp(val, "NONE")==0) { - shortcut.keycode = 0; - shortcut.modifier = 0; - if (ret) - *ret = &shortcut; - return True; + shortcut.keycode = 0; + shortcut.modifier = 0; + if (ret) + *ret = &shortcut; + return True; } strcpy(buf, val); - + b = (char*)buf; /* get modifiers */ shortcut.modifier = 0; while ((k = strchr(b, '+'))!=NULL) { - int mod; - - *k = 0; - mod = wXModifierFromKey(b); - if (mod<0) { - wwarning(_("%s:invalid key modifier \"%s\""), entry->key, b); - return False; - } - shortcut.modifier |= mod; - - b = k+1; + int mod; + + *k = 0; + mod = wXModifierFromKey(b); + if (mod<0) { + wwarning(_("%s:invalid key modifier \"%s\""), entry->key, b); + return False; + } + shortcut.modifier |= mod; + + b = k+1; } - + /* get key */ ksym = XStringToKeysym(b); - + if (ksym==NoSymbol) { - wwarning(_("%s:invalid kbd shortcut specification \"%s\""), entry->key, - val); - return False; + wwarning(_("%s:invalid kbd shortcut specification \"%s\""), entry->key, + val); + return False; } - + shortcut.keycode = XKeysymToKeycode(dpy, ksym); if (shortcut.keycode==0) { - wwarning(_("%s:invalid key in shortcut \"%s\""), entry->key, val); - return False; + wwarning(_("%s:invalid key in shortcut \"%s\""), entry->key, val); + return False; } if (ret) - *ret = &shortcut; + *ret = &shortcut; return True; } static int -getModMask(WScreen *scr, WDefaultEntry *entry, WMPropList *value, void *addr, - void **ret) +getModMask(WScreen *scr, WDefaultEntry *entry, WMPropList *value, void *addr, + void **ret) { static unsigned int mask; char *str; @@ -2439,20 +2439,20 @@ getModMask(WScreen *scr, WDefaultEntry *entry, WMPropList *value, void *addr, GET_STRING_OR_DEFAULT("Modifier Key", str); if (!str) - return False; + return False; mask = wXModifierFromKey(str); if (mask < 0) { - wwarning(_("%s: modifier key %s is not valid"), entry->key, str); - mask = 0; - return False; + wwarning(_("%s: modifier key %s is not valid"), entry->key, str); + mask = 0; + return False; } if (addr) - *(unsigned int*)addr = mask; + *(unsigned int*)addr = mask; if (ret) - *ret = &mask; + *ret = &mask; return True; } @@ -2461,7 +2461,7 @@ getModMask(WScreen *scr, WDefaultEntry *entry, WMPropList *value, void *addr, #ifdef NEWSTUFF static int getRImages(WScreen *scr, WDefaultEntry *entry, WMPropList *value, - void *addr, void **ret) + void *addr, void **ret) { unsigned int mask; char *str; @@ -2471,25 +2471,25 @@ getRImages(WScreen *scr, WDefaultEntry *entry, WMPropList *value, GET_STRING_OR_DEFAULT("Image File Path", str); if (!str) - return False; + return False; image = RLoadImage(scr->rcontext, str, 0); if (!image) { - wwarning(_("could not load image in option %s: %s"), entry->key, - RMessageForError(RErrorCode)); - return False; + wwarning(_("could not load image in option %s: %s"), entry->key, + RMessageForError(RErrorCode)); + return False; } if (*(RImage**)addr) { - RReleaseImage(*(RImage**)addr); + RReleaseImage(*(RImage**)addr); } if (addr) - *(RImage**)addr = image; + *(RImage**)addr = image; assert(ret == NULL); /* - if (ret) - *(RImage**)ret = image; + if (ret) + *(RImage**)ret = image; */ return True; @@ -2497,10 +2497,10 @@ getRImages(WScreen *scr, WDefaultEntry *entry, WMPropList *value, #endif # include -typedef struct +typedef struct { - char *name; - int id; + char *name; + int id; } WCursorLookup; #define CURSOR_ID_NONE (XC_num_glyphs) @@ -2591,18 +2591,18 @@ static void check_bitmap_status(int status, char *filename, Pixmap bitmap) { switch(status) { - case BitmapOpenFailed: - wwarning(_("failed to open bitmap file \"%s\""), filename); - break; - case BitmapFileInvalid: - wwarning(_("\"%s\" is not a valid bitmap file"), filename); - break; - case BitmapNoMemory: - wwarning(_("out of memory reading bitmap file \"%s\""), filename); - break; - case BitmapSuccess: - XFreePixmap(dpy, bitmap); - break; + case BitmapOpenFailed: + wwarning(_("failed to open bitmap file \"%s\""), filename); + break; + case BitmapFileInvalid: + wwarning(_("\"%s\" is not a valid bitmap file"), filename); + break; + case BitmapNoMemory: + wwarning(_("out of memory reading bitmap file \"%s\""), filename); + break; + case BitmapSuccess: + XFreePixmap(dpy, bitmap); + break; } } @@ -2618,100 +2618,100 @@ parse_cursor(WScreen *scr, WMPropList *pl, Cursor *cursor) char *val; int nelem; int status = 0; - + nelem = WMGetPropListItemCount(pl); if (nelem < 1) { - return(status); + return(status); } elem = WMGetFromPLArray(pl, 0); if (!elem || !WMIsPLString(elem)) { - return(status); + return(status); } val = WMGetFromPLString(elem); - - if (0 == strcasecmp(val, "none")) { - status = 1; - *cursor = None; - } else if (0 == strcasecmp(val, "builtin")) { - int i; - int cursor_id = CURSOR_ID_NONE; - - if (2 != nelem) { - wwarning(_("bad number of arguments in cursor specification")); - return(status); - } - elem = WMGetFromPLArray(pl, 1); - if (!elem || !WMIsPLString(elem)) { - return(status); - } - val = WMGetFromPLString(elem); - for (i = 0; NULL != cursor_table[i].name; i++) { - if (0 == strcasecmp(val, cursor_table[i].name)) { - cursor_id = cursor_table[i].id; - break; - } - } - if (CURSOR_ID_NONE == cursor_id) { - wwarning(_("unknown builtin cursor name \"%s\""), val); - } else { - *cursor = XCreateFontCursor(dpy, cursor_id); - status = 1; - } + if (0 == strcasecmp(val, "none")) { + status = 1; + *cursor = None; + } else if (0 == strcasecmp(val, "builtin")) { + int i; + int cursor_id = CURSOR_ID_NONE; + + if (2 != nelem) { + wwarning(_("bad number of arguments in cursor specification")); + return(status); + } + elem = WMGetFromPLArray(pl, 1); + if (!elem || !WMIsPLString(elem)) { + return(status); + } + val = WMGetFromPLString(elem); + + for (i = 0; NULL != cursor_table[i].name; i++) { + if (0 == strcasecmp(val, cursor_table[i].name)) { + cursor_id = cursor_table[i].id; + break; + } + } + if (CURSOR_ID_NONE == cursor_id) { + wwarning(_("unknown builtin cursor name \"%s\""), val); + } else { + *cursor = XCreateFontCursor(dpy, cursor_id); + status = 1; + } } else if (0 == strcasecmp(val, "bitmap")) { - char *bitmap_name; - char *mask_name; - int bitmap_status; - int mask_status; - Pixmap bitmap; - Pixmap mask; - unsigned int w, h; - int x, y; - XColor fg, bg; - - if (3 != nelem) { - wwarning(_("bad number of arguments in cursor specification")); - return(status); - } - elem = WMGetFromPLArray(pl, 1); - if (!elem || !WMIsPLString(elem)) { - return(status); - } - val = WMGetFromPLString(elem); - bitmap_name = FindImage(wPreferences.pixmap_path, val); - if (!bitmap_name) { - wwarning(_("could not find cursor bitmap file \"%s\""), val); - return(status); - } - elem = WMGetFromPLArray(pl, 2); - if (!elem || !WMIsPLString(elem)) { - wfree(bitmap_name); - return(status); - } - val = WMGetFromPLString(elem); - mask_name = FindImage(wPreferences.pixmap_path, val); - if (!mask_name) { - wfree(bitmap_name); - wwarning(_("could not find cursor bitmap file \"%s\""), val); - return(status); - } - mask_status = XReadBitmapFile(dpy, scr->w_win, mask_name, &w, &h, - &mask, &x, &y); - bitmap_status = XReadBitmapFile(dpy, scr->w_win, bitmap_name, &w, &h, - &bitmap, &x, &y); - if ((BitmapSuccess == bitmap_status) && - (BitmapSuccess == mask_status)) { - fg.pixel = scr->black_pixel; - bg.pixel = scr->white_pixel; - XQueryColor(dpy, scr->w_colormap, &fg); - XQueryColor(dpy, scr->w_colormap, &bg); - *cursor = XCreatePixmapCursor(dpy, bitmap, mask, &fg, &bg, x, y); - status = 1; - } - check_bitmap_status(bitmap_status, bitmap_name, bitmap); - check_bitmap_status(mask_status, mask_name, mask); - wfree(bitmap_name); - wfree(mask_name); + char *bitmap_name; + char *mask_name; + int bitmap_status; + int mask_status; + Pixmap bitmap; + Pixmap mask; + unsigned int w, h; + int x, y; + XColor fg, bg; + + if (3 != nelem) { + wwarning(_("bad number of arguments in cursor specification")); + return(status); + } + elem = WMGetFromPLArray(pl, 1); + if (!elem || !WMIsPLString(elem)) { + return(status); + } + val = WMGetFromPLString(elem); + bitmap_name = FindImage(wPreferences.pixmap_path, val); + if (!bitmap_name) { + wwarning(_("could not find cursor bitmap file \"%s\""), val); + return(status); + } + elem = WMGetFromPLArray(pl, 2); + if (!elem || !WMIsPLString(elem)) { + wfree(bitmap_name); + return(status); + } + val = WMGetFromPLString(elem); + mask_name = FindImage(wPreferences.pixmap_path, val); + if (!mask_name) { + wfree(bitmap_name); + wwarning(_("could not find cursor bitmap file \"%s\""), val); + return(status); + } + mask_status = XReadBitmapFile(dpy, scr->w_win, mask_name, &w, &h, + &mask, &x, &y); + bitmap_status = XReadBitmapFile(dpy, scr->w_win, bitmap_name, &w, &h, + &bitmap, &x, &y); + if ((BitmapSuccess == bitmap_status) && + (BitmapSuccess == mask_status)) { + fg.pixel = scr->black_pixel; + bg.pixel = scr->white_pixel; + XQueryColor(dpy, scr->w_colormap, &fg); + XQueryColor(dpy, scr->w_colormap, &bg); + *cursor = XCreatePixmapCursor(dpy, bitmap, mask, &fg, &bg, x, y); + status = 1; + } + check_bitmap_status(bitmap_status, bitmap_name, bitmap); + check_bitmap_status(mask_status, mask_name, mask); + wfree(bitmap_name); + wfree(mask_name); } return(status); } @@ -2719,40 +2719,40 @@ parse_cursor(WScreen *scr, WMPropList *pl, Cursor *cursor) static int getCursor(WScreen *scr, WDefaultEntry *entry, WMPropList *value, void *addr, - void **ret) + void **ret) { static Cursor cursor; int status; int changed = 0; - + again: if (!WMIsPLArray(value)) { - wwarning(_("Wrong option format for key \"%s\". Should be %s."), - entry->key, "cursor specification"); - if (!changed) { - value = entry->plvalue; - changed = 1; - wwarning(_("using default \"%s\" instead"), entry->default_value); - goto again; - } - return(False); + wwarning(_("Wrong option format for key \"%s\". Should be %s."), + entry->key, "cursor specification"); + if (!changed) { + value = entry->plvalue; + changed = 1; + wwarning(_("using default \"%s\" instead"), entry->default_value); + goto again; + } + return(False); } status = parse_cursor(scr, value, &cursor); if (!status) { - wwarning(_("Error in cursor specification for key \"%s\""), entry->key); - if (!changed) { - value = entry->plvalue; - changed = 1; - wwarning(_("using default \"%s\" instead"), entry->default_value); - goto again; - } - return(False); + wwarning(_("Error in cursor specification for key \"%s\""), entry->key); + if (!changed) { + value = entry->plvalue; + changed = 1; + wwarning(_("using default \"%s\" instead"), entry->default_value); + goto again; + } + return(False); } if (ret) { - *ret = &cursor; + *ret = &cursor; } if (addr) { - *(Cursor *)addr = cursor; + *(Cursor *)addr = cursor; } return(True); } @@ -2761,7 +2761,7 @@ again: /* ---------------- value setting functions --------------- */ static int - setJustify(WScreen *scr, WDefaultEntry *entry, WTexture **texture, void *foo) +setJustify(WScreen *scr, WDefaultEntry *entry, WTexture **texture, void *foo) { return REFRESH_WINDOW_TITLE_COLOR; } @@ -2818,37 +2818,37 @@ setIconTile(WScreen *scr, WDefaultEntry *entry, WTexture **texture, void *foo) Pixmap pixmap; RImage *img; int reset = 0; - + img = wTextureRenderImage(*texture, wPreferences.icon_size, - wPreferences.icon_size, - ((*texture)->any.type & WREL_BORDER_MASK) - ? WREL_ICON : WREL_FLAT); + wPreferences.icon_size, + ((*texture)->any.type & WREL_BORDER_MASK) + ? WREL_ICON : WREL_FLAT); if (!img) { - wwarning(_("could not render texture for icon background")); - if (!entry->addr) - wTextureDestroy(scr, *texture); - return 0; + wwarning(_("could not render texture for icon background")); + if (!entry->addr) + wTextureDestroy(scr, *texture); + return 0; } RConvertImage(scr->rcontext, img, &pixmap); - + if (scr->icon_tile) { - reset = 1; - RReleaseImage(scr->icon_tile); - XFreePixmap(dpy, scr->icon_tile_pixmap); + reset = 1; + RReleaseImage(scr->icon_tile); + XFreePixmap(dpy, scr->icon_tile_pixmap); } scr->icon_tile = img; - - + + /* put the icon in the noticeboard hint */ PropSetIconTileHint(scr, img); - + if (!wPreferences.flags.noclip) { - if (scr->clip_tile) { - RReleaseImage(scr->clip_tile); - } - scr->clip_tile = wClipMakeTile(scr, img); + if (scr->clip_tile) { + RReleaseImage(scr->clip_tile); + } + scr->clip_tile = wClipMakeTile(scr, img); } scr->icon_tile_pixmap = pixmap; @@ -2863,56 +2863,56 @@ setIconTile(WScreen *scr, WDefaultEntry *entry, WTexture **texture, void *foo) } if (scr->icon_back_texture) { - wTextureDestroy(scr, (WTexture*)scr->icon_back_texture); + wTextureDestroy(scr, (WTexture*)scr->icon_back_texture); } scr->icon_back_texture = wTextureMakeSolid(scr, &((*texture)->any.color)); if (scr->clip_balloon) - XSetWindowBackground(dpy, scr->clip_balloon, - (*texture)->any.color.pixel); - + XSetWindowBackground(dpy, scr->clip_balloon, + (*texture)->any.color.pixel); + /* * Free the texture as nobody else will use it, nor refer to it. */ if (!entry->addr) - wTextureDestroy(scr, *texture); + wTextureDestroy(scr, *texture); return (reset ? REFRESH_ICON_TILE : 0); } -static int +static int setWinTitleFont(WScreen *scr, WDefaultEntry *entry, WMFont *font, void *foo) { if (scr->title_font) { - WMReleaseFont(scr->title_font); + WMReleaseFont(scr->title_font); } scr->title_font = font; - + return REFRESH_WINDOW_FONT|REFRESH_BUTTON_IMAGES; } -static int +static int setMenuTitleFont(WScreen *scr, WDefaultEntry *entry, WMFont *font, void *foo) { if (scr->menu_title_font) { - WMReleaseFont(scr->menu_title_font); + WMReleaseFont(scr->menu_title_font); } - + scr->menu_title_font = font; return REFRESH_MENU_TITLE_FONT; } -static int +static int setMenuTextFont(WScreen *scr, WDefaultEntry *entry, WMFont *font, void *foo) { if (scr->menu_entry_font) { - WMReleaseFont(scr->menu_entry_font); - } + WMReleaseFont(scr->menu_entry_font); + } scr->menu_entry_font = font; return REFRESH_MENU_FONT; @@ -2920,26 +2920,26 @@ setMenuTextFont(WScreen *scr, WDefaultEntry *entry, WMFont *font, void *foo) -static int +static int setIconTitleFont(WScreen *scr, WDefaultEntry *entry, WMFont *font, void *foo) { if (scr->icon_title_font) { - WMReleaseFont(scr->icon_title_font); + WMReleaseFont(scr->icon_title_font); } - + scr->icon_title_font = font; - + return REFRESH_ICON_FONT; } -static int +static int setClipTitleFont(WScreen *scr, WDefaultEntry *entry, WMFont *font, void *foo) { if (scr->clip_title_font) { - WMReleaseFont(scr->clip_title_font); + WMReleaseFont(scr->clip_title_font); } - + scr->clip_title_font = font; return REFRESH_ICON_FONT; @@ -2950,9 +2950,9 @@ static int setLargeDisplayFont(WScreen *scr, WDefaultEntry *entry, WMFont *font, void *foo) { if (scr->workspace_name_font) { - WMReleaseFont(scr->workspace_name_font); + WMReleaseFont(scr->workspace_name_font); } - + scr->workspace_name_font = font; return 0; @@ -2962,12 +2962,14 @@ setLargeDisplayFont(WScreen *scr, WDefaultEntry *entry, WMFont *font, void *foo) static int setHightlight(WScreen *scr, WDefaultEntry *entry, XColor *color, void *foo) { - if (scr->select_pixel!=scr->white_pixel && - scr->select_pixel!=scr->black_pixel) { - wFreeColor(scr, scr->select_pixel); - } - - scr->select_pixel = color->pixel; + if (scr->select_color) + WMReleaseColor(scr->select_color); + + scr->select_color = + WMCreateRGBColor(scr->wmscreen, color->red, color->green, + color->blue, True); + + wFreeColor(scr, color->pixel); return REFRESH_MENU_COLOR; } @@ -2976,12 +2978,14 @@ setHightlight(WScreen *scr, WDefaultEntry *entry, XColor *color, void *foo) static int setHightlightText(WScreen *scr, WDefaultEntry *entry, XColor *color, void *foo) { - if (scr->select_text_pixel!=scr->white_pixel && - scr->select_text_pixel!=scr->black_pixel) { - wFreeColor(scr, scr->select_text_pixel); - } - - scr->select_text_pixel = color->pixel; + if (scr->select_text_color) + WMReleaseColor(scr->select_text_color); + + scr->select_text_color = + WMCreateRGBColor(scr->wmscreen, color->red, color->green, + color->blue, True); + + wFreeColor(scr, color->pixel); return REFRESH_MENU_COLOR; } @@ -2995,27 +2999,28 @@ setClipTitleColor(WScreen *scr, WDefaultEntry *entry, XColor *color, long index) scr->clip_title_color[index] = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True); + wFreeColor(scr, color->pixel); #ifdef GRADIENT_CLIP_ARROW if (index == CLIP_NORMAL) { - RImage *image; - RColor color1, color2; - int pt = CLIP_BUTTON_SIZE*wPreferences.icon_size/64; - int as = pt - 15; /* 15 = 5+5+5 */ - - FREE_PIXMAP(scr->clip_arrow_gradient); + RImage *image; + RColor color1, color2; + int pt = CLIP_BUTTON_SIZE*wPreferences.icon_size/64; + int as = pt - 15; /* 15 = 5+5+5 */ - color1.red = (color->red >> 8)*6/10; - color1.green = (color->green >> 8)*6/10; - color1.blue = (color->blue >> 8)*6/10; + FREE_PIXMAP(scr->clip_arrow_gradient); - color2.red = WMIN((color->red >> 8)*20/10, 255); - color2.green = WMIN((color->green >> 8)*20/10, 255); - color2.blue = WMIN((color->blue >> 8)*20/10, 255); + color1.red = (color->red >> 8)*6/10; + color1.green = (color->green >> 8)*6/10; + color1.blue = (color->blue >> 8)*6/10; - image = RRenderGradient(as+1, as+1, &color1, &color2, RDiagonalGradient); - RConvertImage(scr->rcontext, image, &scr->clip_arrow_gradient); - RReleaseImage(image); + color2.red = WMIN((color->red >> 8)*20/10, 255); + color2.green = WMIN((color->green >> 8)*20/10, 255); + color2.blue = WMIN((color->blue >> 8)*20/10, 255); + + image = RRenderGradient(as+1, as+1, &color1, &color2, RDiagonalGradient); + RConvertImage(scr->rcontext, image, &scr->clip_arrow_gradient); + RReleaseImage(image); } #endif /* GRADIENT_CLIP_ARROW */ @@ -3026,94 +3031,81 @@ setClipTitleColor(WScreen *scr, WDefaultEntry *entry, XColor *color, long index) static int setWTitleColor(WScreen *scr, WDefaultEntry *entry, XColor *color, long index) { - if (scr->window_title_pixel[index]!=scr->white_pixel && - scr->window_title_pixel[index]!=scr->black_pixel) { - wFreeColor(scr, scr->window_title_pixel[index]); - } - - scr->window_title_pixel[index] = color->pixel; + if (scr->window_title_color[index]) + WMReleaseColor(scr->window_title_color[index]); + + scr->window_title_color[index] = + WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, + True); if (index == WS_UNFOCUSED) - XSetForeground(dpy, scr->info_text_gc, color->pixel); - + XSetForeground(dpy, scr->info_text_gc, color->pixel); + + wFreeColor(scr, color->pixel); + return REFRESH_WINDOW_TITLE_COLOR; } -static int +static int setMenuTitleColor(WScreen *scr, WDefaultEntry *entry, XColor *color, long index) { - if (scr->menu_title_pixel[0]!=scr->white_pixel && - scr->menu_title_pixel[0]!=scr->black_pixel) { - wFreeColor(scr, scr->menu_title_pixel[0]); - } - - scr->menu_title_pixel[0] = color->pixel; - XSetForeground(dpy, scr->menu_title_gc, color->pixel); - + if (scr->menu_title_color[0]) + WMReleaseColor(scr->menu_title_color[0]); + + scr->menu_title_color[0] = + WMCreateRGBColor(scr->wmscreen, color->red, color->green, + color->blue, True); + + wFreeColor(scr, color->pixel); + return REFRESH_MENU_TITLE_COLOR; } -static int +static int setMenuTextColor(WScreen *scr, WDefaultEntry *entry, XColor *color, void *foo) { - XGCValues gcv; -#define gcm (GCForeground|GCBackground|GCFillStyle) + if (scr->mtext_color) + WMReleaseColor(scr->mtext_color); - if (scr->mtext_pixel!=scr->white_pixel && - scr->mtext_pixel!=scr->black_pixel) { - wFreeColor(scr, scr->mtext_pixel); - } - - scr->mtext_pixel = color->pixel; - - XSetForeground(dpy, scr->menu_entry_gc, color->pixel); + scr->mtext_color = WMCreateRGBColor(scr->wmscreen, color->red, + color->green, color->blue, True); - - if (scr->dtext_pixel == scr->mtext_pixel) { - gcv.foreground = scr->white_pixel; - gcv.background = scr->black_pixel; - gcv.fill_style = FillStippled; + if (WMColorPixel(scr->dtext_color) == WMColorPixel(scr->mtext_color)) { + WMSetColorAlpha(scr->dtext_color, 0x7fff); } else { - gcv.foreground = scr->dtext_pixel; - gcv.fill_style = FillSolid; + WMSetColorAlpha(scr->dtext_color, 0xffff); } - XChangeGC(dpy, scr->disabled_menu_entry_gc, gcm, &gcv); - + + wFreeColor(scr, color->pixel); + return REFRESH_MENU_COLOR; -#undef gcm } -static int +static int setMenuDisabledColor(WScreen *scr, WDefaultEntry *entry, XColor *color, void *foo) { - XGCValues gcv; -#define gcm (GCForeground|GCBackground|GCFillStyle) + if (scr->dtext_color) + WMReleaseColor(scr->dtext_color); - if (scr->dtext_pixel!=scr->white_pixel && - scr->dtext_pixel!=scr->black_pixel) { - wFreeColor(scr, scr->dtext_pixel); - } - - scr->dtext_pixel = color->pixel; + scr->dtext_color = WMCreateRGBColor(scr->wmscreen, color->red, + color->green, color->blue, True); - if (scr->dtext_pixel == scr->mtext_pixel) { - gcv.foreground = scr->white_pixel; - gcv.background = scr->black_pixel; - gcv.fill_style = FillStippled; + if (WMColorPixel(scr->dtext_color) == WMColorPixel(scr->mtext_color)) { + WMSetColorAlpha(scr->dtext_color, 0x7fff); } else { - gcv.foreground = scr->dtext_pixel; - gcv.fill_style = FillSolid; + WMSetColorAlpha(scr->dtext_color, 0xffff); } - XChangeGC(dpy, scr->disabled_menu_entry_gc, gcm, &gcv); + + wFreeColor(scr, color->pixel); return REFRESH_MENU_COLOR; -#undef gcm } -static int + +static int setIconTitleColor(WScreen *scr, WDefaultEntry *entry, XColor *color, void *foo) { if (scr->icon_title_color) @@ -3121,20 +3113,23 @@ setIconTitleColor(WScreen *scr, WDefaultEntry *entry, XColor *color, void *foo) scr->icon_title_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True); - + + wFreeColor(scr, color->pixel); + return REFRESH_ICON_TITLE_COLOR; } -static int +static int setIconTitleBack(WScreen *scr, WDefaultEntry *entry, XColor *color, void *foo) { if (scr->icon_title_texture) { - wTextureDestroy(scr, (WTexture*)scr->icon_title_texture); + wTextureDestroy(scr, (WTexture*)scr->icon_title_texture); } + // ?? why is this necessary? color was already parsed and alloced XQueryColor (dpy, scr->w_colormap, color); scr->icon_title_texture = wTextureMakeSolid(scr, color); - + return REFRESH_ICON_TITLE_BACK; } @@ -3146,95 +3141,95 @@ trackDeadProcess(pid_t pid, unsigned char status, WScreen *scr) scr->helper_fd = 0; scr->helper_pid = 0; scr->flags.backimage_helper_launched = 0; -} +} static int -setWorkspaceSpecificBack(WScreen *scr, WDefaultEntry *entry, WMPropList *value, - void *bar) +setWorkspaceSpecificBack(WScreen *scr, WDefaultEntry *entry, WMPropList *value, + void *bar) { WMPropList *val; char *str; int i; if (scr->flags.backimage_helper_launched) { - if (WMGetPropListItemCount(value)==0) { - SendHelperMessage(scr, 'C', 0, NULL); - SendHelperMessage(scr, 'K', 0, NULL); + if (WMGetPropListItemCount(value)==0) { + SendHelperMessage(scr, 'C', 0, NULL); + SendHelperMessage(scr, 'K', 0, NULL); - WMReleasePropList(value); - return 0; - } + WMReleasePropList(value); + return 0; + } } else { - pid_t pid; - int filedes[2]; + pid_t pid; + int filedes[2]; - if (WMGetPropListItemCount(value) == 0) - return 0; - - if (pipe(filedes) < 0) { - wsyserror("pipe() failed:can't set workspace specific background image"); - - WMReleasePropList(value); - return 0; - } + if (WMGetPropListItemCount(value) == 0) + return 0; - pid = fork(); - if (pid < 0) { - wsyserror("fork() failed:can't set workspace specific background image"); - if (close(filedes[0]) < 0) - wsyserror("could not close pipe"); - if (close(filedes[1]) < 0) - wsyserror("could not close pipe"); + if (pipe(filedes) < 0) { + wsyserror("pipe() failed:can't set workspace specific background image"); + + WMReleasePropList(value); + return 0; + } + + pid = fork(); + if (pid < 0) { + wsyserror("fork() failed:can't set workspace specific background image"); + if (close(filedes[0]) < 0) + wsyserror("could not close pipe"); + if (close(filedes[1]) < 0) + wsyserror("could not close pipe"); } else if (pid == 0) { char *dither; - SetupEnvironment(scr); + SetupEnvironment(scr); - if (close(0) < 0) - wsyserror("could not close pipe"); - if (dup(filedes[0]) < 0) { - wsyserror("dup() failed:can't set workspace specific background image"); + if (close(0) < 0) + wsyserror("could not close pipe"); + if (dup(filedes[0]) < 0) { + wsyserror("dup() failed:can't set workspace specific background image"); } dither = wPreferences.no_dithering ? "-m" : "-d"; - if (wPreferences.smooth_workspace_back) - execlp("wmsetbg", "wmsetbg", "-helper", "-S", dither, NULL); - else - execlp("wmsetbg", "wmsetbg", "-helper", dither, NULL); - wsyserror("could not execute wmsetbg"); - exit(1); - } else { + if (wPreferences.smooth_workspace_back) + execlp("wmsetbg", "wmsetbg", "-helper", "-S", dither, NULL); + else + execlp("wmsetbg", "wmsetbg", "-helper", dither, NULL); + wsyserror("could not execute wmsetbg"); + exit(1); + } else { - if (fcntl(filedes[0], F_SETFD, FD_CLOEXEC) < 0) { - wsyserror("error setting close-on-exec flag"); - } - if (fcntl(filedes[1], F_SETFD, FD_CLOEXEC) < 0) { - wsyserror("error setting close-on-exec flag"); - } + if (fcntl(filedes[0], F_SETFD, FD_CLOEXEC) < 0) { + wsyserror("error setting close-on-exec flag"); + } + if (fcntl(filedes[1], F_SETFD, FD_CLOEXEC) < 0) { + wsyserror("error setting close-on-exec flag"); + } - scr->helper_fd = filedes[1]; - scr->helper_pid = pid; - scr->flags.backimage_helper_launched = 1; + scr->helper_fd = filedes[1]; + scr->helper_pid = pid; + scr->flags.backimage_helper_launched = 1; - wAddDeathHandler(pid, (WDeathHandler*)trackDeadProcess, scr); + wAddDeathHandler(pid, (WDeathHandler*)trackDeadProcess, scr); + + SendHelperMessage(scr, 'P', -1, wPreferences.pixmap_path); + } - SendHelperMessage(scr, 'P', -1, wPreferences.pixmap_path); - } - } for (i = 0; i < WMGetPropListItemCount(value); i++) { - val = WMGetFromPLArray(value, i); - if (val && WMIsPLArray(val) && WMGetPropListItemCount(val)>0) { - str = WMGetPropListDescription(val, False); + val = WMGetFromPLArray(value, i); + if (val && WMIsPLArray(val) && WMGetPropListItemCount(val)>0) { + str = WMGetPropListDescription(val, False); - SendHelperMessage(scr, 'S', i+1, str); + SendHelperMessage(scr, 'S', i+1, str); - wfree(str); - } else { - SendHelperMessage(scr, 'U', i+1, NULL); - } + wfree(str); + } else { + SendHelperMessage(scr, 'U', i+1, NULL); + } } sleep(1); @@ -3244,43 +3239,43 @@ setWorkspaceSpecificBack(WScreen *scr, WDefaultEntry *entry, WMPropList *value, static int -setWorkspaceBack(WScreen *scr, WDefaultEntry *entry, WMPropList *value, - void *bar) +setWorkspaceBack(WScreen *scr, WDefaultEntry *entry, WMPropList *value, + void *bar) { if (scr->flags.backimage_helper_launched) { - char *str; + char *str; - if (WMGetPropListItemCount(value)==0) { - SendHelperMessage(scr, 'U', 0, NULL); - } else { - /* set the default workspace background to this one */ - str = WMGetPropListDescription(value, False); - if (str) { - SendHelperMessage(scr, 'S', 0, str); - wfree(str); - SendHelperMessage(scr, 'C', scr->current_workspace+1, NULL); - } else { - SendHelperMessage(scr, 'U', 0, NULL); - } - } + if (WMGetPropListItemCount(value)==0) { + SendHelperMessage(scr, 'U', 0, NULL); + } else { + /* set the default workspace background to this one */ + str = WMGetPropListDescription(value, False); + if (str) { + SendHelperMessage(scr, 'S', 0, str); + wfree(str); + SendHelperMessage(scr, 'C', scr->current_workspace+1, NULL); + } else { + SendHelperMessage(scr, 'U', 0, NULL); + } + } } else if (WMGetPropListItemCount(value) > 0) { - char *command; + char *command; char *text; char *dither; - int len; + int len; - SetupEnvironment(scr); - text = WMGetPropListDescription(value, False); - len = strlen(text)+40; + SetupEnvironment(scr); + text = WMGetPropListDescription(value, False); + len = strlen(text)+40; command = wmalloc(len); dither = wPreferences.no_dithering ? "-m" : "-d"; - if (wPreferences.smooth_workspace_back) - snprintf(command, len, "wmsetbg %s -S -p '%s' &", dither, text); - else - snprintf(command, len, "wmsetbg %s -p '%s' &", dither, text); - wfree(text); - system(command); - wfree(command); + if (wPreferences.smooth_workspace_back) + snprintf(command, len, "wmsetbg %s -S -p '%s' &", dither, text); + else + snprintf(command, len, "wmsetbg %s -p '%s' &", dither, text); + wfree(text); + system(command); + wfree(command); } WMReleasePropList(value); @@ -3288,11 +3283,11 @@ setWorkspaceBack(WScreen *scr, WDefaultEntry *entry, WMPropList *value, } -static int +static int setWidgetColor(WScreen *scr, WDefaultEntry *entry, WTexture **texture, void *foo) { if (scr->widget_texture) { - wTextureDestroy(scr, (WTexture*)scr->widget_texture); + wTextureDestroy(scr, (WTexture*)scr->widget_texture); } scr->widget_texture = *(WTexSolid**)texture; @@ -3300,11 +3295,11 @@ setWidgetColor(WScreen *scr, WDefaultEntry *entry, WTexture **texture, void *foo } -static int +static int setFTitleBack(WScreen *scr, WDefaultEntry *entry, WTexture **texture, void *foo) -{ +{ if (scr->window_title_texture[WS_FOCUSED]) { - wTextureDestroy(scr, scr->window_title_texture[WS_FOCUSED]); + wTextureDestroy(scr, scr->window_title_texture[WS_FOCUSED]); } scr->window_title_texture[WS_FOCUSED] = *texture; @@ -3312,23 +3307,23 @@ setFTitleBack(WScreen *scr, WDefaultEntry *entry, WTexture **texture, void *foo) } -static int +static int setPTitleBack(WScreen *scr, WDefaultEntry *entry, WTexture **texture, void *foo) { if (scr->window_title_texture[WS_PFOCUSED]) { - wTextureDestroy(scr, scr->window_title_texture[WS_PFOCUSED]); + wTextureDestroy(scr, scr->window_title_texture[WS_PFOCUSED]); } scr->window_title_texture[WS_PFOCUSED] = *texture; - + return REFRESH_WINDOW_TEXTURES; } -static int +static int setUTitleBack(WScreen *scr, WDefaultEntry *entry, WTexture **texture, void *foo) { if (scr->window_title_texture[WS_UNFOCUSED]) { - wTextureDestroy(scr, scr->window_title_texture[WS_UNFOCUSED]); + wTextureDestroy(scr, scr->window_title_texture[WS_UNFOCUSED]); } scr->window_title_texture[WS_UNFOCUSED] = *texture; @@ -3336,11 +3331,11 @@ setUTitleBack(WScreen *scr, WDefaultEntry *entry, WTexture **texture, void *foo) } -static int +static int setResizebarBack(WScreen *scr, WDefaultEntry *entry, WTexture **texture, void *foo) { if (scr->resizebar_texture[0]) { - wTextureDestroy(scr, scr->resizebar_texture[0]); + wTextureDestroy(scr, scr->resizebar_texture[0]); } scr->resizebar_texture[0] = *texture; @@ -3348,11 +3343,11 @@ setResizebarBack(WScreen *scr, WDefaultEntry *entry, WTexture **texture, void *f } -static int +static int setMenuTitleBack(WScreen *scr, WDefaultEntry *entry, WTexture **texture, void *foo) { if (scr->menu_title_texture[0]) { - wTextureDestroy(scr, scr->menu_title_texture[0]); + wTextureDestroy(scr, scr->menu_title_texture[0]); } scr->menu_title_texture[0] = *texture; @@ -3360,18 +3355,18 @@ setMenuTitleBack(WScreen *scr, WDefaultEntry *entry, WTexture **texture, void *f } -static int +static int setMenuTextBack(WScreen *scr, WDefaultEntry *entry, WTexture **texture, void *foo) { if (scr->menu_item_texture) { - wTextureDestroy(scr, scr->menu_item_texture); - wTextureDestroy(scr, (WTexture*)scr->menu_item_auxtexture); + wTextureDestroy(scr, scr->menu_item_texture); + wTextureDestroy(scr, (WTexture*)scr->menu_item_auxtexture); } scr->menu_item_texture = *texture; - scr->menu_item_auxtexture - = wTextureMakeSolid(scr, &scr->menu_item_texture->any.color); - + scr->menu_item_auxtexture + = wTextureMakeSolid(scr, &scr->menu_item_texture->any.color); + return REFRESH_MENU_TEXTURE; } @@ -3381,18 +3376,18 @@ setKeyGrab(WScreen *scr, WDefaultEntry *entry, WShortKey *shortcut, long index) { WWindow *wwin; wKeyBindings[index] = *shortcut; - - wwin = scr->focused_window; - - while (wwin!=NULL) { - XUngrabKey(dpy, AnyKey, AnyModifier, wwin->frame->core->window); - if (!WFLAGP(wwin, no_bind_keys)) { - wWindowSetKeyGrabs(wwin); - } - wwin = wwin->prev; + wwin = scr->focused_window; + + while (wwin!=NULL) { + XUngrabKey(dpy, AnyKey, AnyModifier, wwin->frame->core->window); + + if (!WFLAGP(wwin, no_bind_keys)) { + wWindowSetKeyGrabs(wwin); + } + wwin = wwin->prev; } - + return 0; } @@ -3423,17 +3418,17 @@ setMenuStyle(WScreen *scr, WDefaultEntry *entry, int *value, void *foo) /* -static int -setButtonImages(WScreen *scr, WDefaultEntry *entry, int *value, void *foo) -{ - return REFRESH_BUTTON_IMAGES; -} -*/ + static int + setButtonImages(WScreen *scr, WDefaultEntry *entry, int *value, void *foo) + { + return REFRESH_BUTTON_IMAGES; + } + */ /* * Very ugly kluge. * Need access to the double click variables, so that all widgets in - * wmaker panels will have the same dbl-click values. + * wmaker panels will have the same dbl-click values. * TODO: figure a better way of dealing with it. */ #include @@ -3447,7 +3442,7 @@ setDoubleClick(WScreen *scr, WDefaultEntry *entry, int *value, void *foo) *(int*)foo = 1; WINGsConfiguration.doubleClickDelay = *value; - + return 0; } @@ -3468,17 +3463,17 @@ setMultiByte(WScreen *scr, WDefaultEntry *entry, char *value, void *foo) static int setCursor(WScreen *scr, WDefaultEntry *entry, Cursor *cursor, long index) { - if (wCursor[index] != None) { - XFreeCursor(dpy, wCursor[index]); - } + if (wCursor[index] != None) { + XFreeCursor(dpy, wCursor[index]); + } - wCursor[index] = *cursor; + wCursor[index] = *cursor; - if (index==WCUR_ROOT && *cursor!=None) { - XDefineCursor(dpy, scr->root_win, *cursor); - } + if (index==WCUR_ROOT && *cursor!=None) { + XDefineCursor(dpy, scr->root_win, *cursor); + } - return 0; + return 0; } diff --git a/src/dialog.c b/src/dialog.c index ad4fc4ec..4e7d9f60 100644 --- a/src/dialog.c +++ b/src/dialog.c @@ -442,11 +442,12 @@ drawIconProc(WMList *lPtr, int index, Drawable d, char *text, int state, WMRect *rect) { IconPanel *panel = WMGetHangedData(lPtr); - GC gc = panel->scr->draw_gc; - GC copygc = panel->scr->copy_gc; + WScreen *scr = panel->scr; + GC gc = scr->draw_gc; + GC copygc = scr->copy_gc; char *file, *dirfile; WMPixmap *pixmap; - WMColor *black, *white, *gray, *back; + WMColor *back; WMSize size; WMScreen *wmscr = WMWidgetScreen(panel->win); RColor color; @@ -459,10 +460,7 @@ drawIconProc(WMList *lPtr, int index, Drawable d, char *text, int state, width = rect->size.width; height = rect->size.height; - black = WMBlackColor(wmscr); - white = WMWhiteColor(wmscr); - gray = WMGrayColor(wmscr); - back = (state & WLDSSelected) ? white : gray; + back = (state & WLDSSelected) ? scr->white : scr->gray; dirfile = wexpandpath(WMGetListSelectedItem(panel->dirList)->text); len = strlen(dirfile)+strlen(text)+4; @@ -480,9 +478,6 @@ drawIconProc(WMList *lPtr, int index, Drawable d, char *text, int state, if (!pixmap) { /*WMRemoveListItem(lPtr, index);*/ - WMReleaseColor(black); - WMReleaseColor(white); - WMReleaseColor(gray); return; } @@ -490,7 +485,7 @@ drawIconProc(WMList *lPtr, int index, Drawable d, char *text, int state, XSetClipMask(dpy, gc, None); /*XDrawRectangle(dpy, d, WMColorGC(white), x+5, y+5, width-10, 54);*/ - XDrawLine(dpy, d, WMColorGC(white), x, y+height-1, x+width, y+height-1); + XDrawLine(dpy, d, WMColorGC(scr->white), x, y+height-1, x+width, y+height-1); size = WMGetPixmapSize(pixmap); @@ -512,20 +507,16 @@ drawIconProc(WMList *lPtr, int index, Drawable d, char *text, int state, for(i=-1;i<2;i++) for(j=-1;j<2;j++) - WMDrawString(wmscr, d, white, panel->normalfont, + WMDrawString(wmscr, d, scr->white, panel->normalfont, ofx+i, ofy+j, text, tlen); - WMDrawString(wmscr, d, black, panel->normalfont, ofx, ofy, + WMDrawString(wmscr, d, scr->black, panel->normalfont, ofx, ofy, text, tlen); } WMReleasePixmap(pixmap); /* I hope it is better to do not use cache / on my box it is fast nuff */ XFlush(dpy); - - WMReleaseColor(black); - WMReleaseColor(white); - WMReleaseColor(gray); } diff --git a/src/dock.c b/src/dock.c index 37015bac..67e5fffd 100644 --- a/src/dock.c +++ b/src/dock.c @@ -4221,7 +4221,8 @@ showClipBalloon(WDock *dock, int workspace) XMoveWindow(dpy, scr->clip_balloon, x, y); XClearWindow(dpy, scr->clip_balloon); WMDrawString(scr->wmscreen, scr->clip_balloon, - scr->clip_title_color[CLIP_NORMAL], scr->clip_title_font, + scr->clip_title_color[CLIP_NORMAL], + scr->clip_title_font, 0, 0, text, strlen(text)); } diff --git a/src/framewin.c b/src/framewin.c index c271e662..be1a3b18 100644 --- a/src/framewin.c +++ b/src/framewin.c @@ -67,7 +67,7 @@ WFrameWindow* wFrameWindowCreate(WScreen *scr, int wlevel, int x, int y, int width, int height, int *clearance, int flags, WTexture **title_texture, WTexture **resize_texture, - unsigned long *color, WMFont **font) + WMColor **color, WMFont **font) { WFrameWindow *fwin; @@ -80,7 +80,7 @@ wFrameWindowCreate(WScreen *scr, int wlevel, int x, int y, fwin->title_texture = title_texture; fwin->resizebar_texture = resize_texture; - fwin->title_pixel = color; + fwin->title_color = color; fwin->title_clearance = clearance; fwin->font = font; #ifdef KEEP_XKB_LOCK_STATUS @@ -1050,14 +1050,12 @@ wFrameWindowPaint(WFrameWindow *fwin) if (fwin->title) { char *title; - WMColor *color; - WMPixel pixel; - + title = ShrinkString(*fwin->font, fwin->title, fwin->titlebar->width - lofs - rofs); titlelen = strlen(title); w = WMWidthOfString(*fwin->font, title, titlelen); - + switch (fwin->flags.justification) { case WTJ_LEFT: x = lofs; @@ -1074,20 +1072,16 @@ wFrameWindowPaint(WFrameWindow *fwin) x = (fwin->titlebar->width - w) / 2; break; } - - color = WMBlackColor(scr->wmscreen); - /* ugly hack */ - pixel = color->color.pixel; - color->color.pixel = fwin->title_pixel[fwin->flags.state]; - WMDrawString(scr->wmscreen, fwin->titlebar->window, color, - *fwin->font, x, *fwin->title_clearance + TITLEBAR_EXTEND_SPACE, + + WMDrawString(scr->wmscreen, fwin->titlebar->window, + fwin->title_color[fwin->flags.state], + *fwin->font, x, + *fwin->title_clearance + TITLEBAR_EXTEND_SPACE, title, titlelen); - color->color.pixel = pixel; - WMReleaseColor(color); - + wfree(title); } - + if (fwin->left_button) handleButtonExpose(&fwin->left_button->descriptor, NULL); if (fwin->right_button) @@ -1095,7 +1089,7 @@ wFrameWindowPaint(WFrameWindow *fwin) #ifdef XKB_BUTTON_HINT if (fwin->language_button) handleButtonExpose(&fwin->language_button->descriptor, NULL); -#endif +#endif } } @@ -1255,7 +1249,7 @@ wFrameWindowUpdatePushButton(WFrameWindow *fwin, Bool pushed) fwin->flags.right_button_pushed_in = pushed; paintButton(fwin->right_button, fwin->title_texture[fwin->flags.state], - fwin->title_pixel[fwin->flags.state], + WMColorPixel(fwin->title_color[fwin->flags.state]), fwin->rbutton_image, pushed); } #endif /* OLWM_HINTS */ @@ -1266,7 +1260,7 @@ void wFrameWindowUpdateLanguageButton(WFrameWindow *fwin) { paintButton(fwin->language_button, fwin->title_texture[fwin->flags.state], - fwin->title_pixel[fwin->flags.state], + WMColorPixel(fwin->title_color[fwin->flags.state]), fwin->languagebutton_image, True); } #endif /* XKB_BUTTON_HINT */ @@ -1433,14 +1427,14 @@ handleButtonExpose(WObjDescriptor *desc, XEvent *event) if (button == fwin->language_button) { if (wPreferences.modelock){ paintButton(button, fwin->title_texture[fwin->flags.state], - fwin->title_pixel[fwin->flags.state], + WMColorPixel(fwin->title_color[fwin->flags.state]), fwin->languagebutton_image, False); } } else #endif if (button == fwin->left_button) { paintButton(button, fwin->title_texture[fwin->flags.state], - fwin->title_pixel[fwin->flags.state], + WMColorPixel(fwin->title_color[fwin->flags.state]), fwin->lbutton_image, False); } else { Bool pushed = False; @@ -1451,7 +1445,7 @@ handleButtonExpose(WObjDescriptor *desc, XEvent *event) #endif /* emulate the olwm pushpin in the "out" state */ paintButton(button, fwin->title_texture[fwin->flags.state], - fwin->title_pixel[fwin->flags.state], + WMColorPixel(fwin->title_color[fwin->flags.state]), fwin->rbutton_image, pushed); } } @@ -1515,7 +1509,7 @@ buttonMouseDown(WObjDescriptor *desc, XEvent *event) } #endif - pixel = fwin->title_pixel[fwin->flags.state]; + pixel = WMColorPixel(fwin->title_color[fwin->flags.state]); texture = fwin->title_texture[fwin->flags.state]; paintButton(button, texture, pixel, image, True); diff --git a/src/framewin.h b/src/framewin.h index e6f0e39f..c3b0703b 100644 --- a/src/framewin.h +++ b/src/framewin.h @@ -81,7 +81,7 @@ typedef struct WFrameWindow { union WTexture **title_texture; union WTexture **resizebar_texture; - unsigned long *title_pixel; + WMColor **title_color; WMFont **font; char *title; /* window name (title) */ @@ -156,7 +156,7 @@ wFrameWindowCreate(WScreen *scr, int wlevel, int x, int y, int width, int height, int *clearance, int flags, union WTexture **title_texture, union WTexture **resize_texture, - unsigned long *color, WMFont **font); + WMColor **color, WMFont **font); void wFrameWindowUpdateBorders(WFrameWindow *fwin, int flags); diff --git a/src/menu.c b/src/menu.c index 49b001f7..54d679ba 100644 --- a/src/menu.c +++ b/src/menu.c @@ -1,10 +1,10 @@ /* menu.c- generic menu, used for root menu, application menus etc. * * Window Maker window manager - * + * * Copyright (c) 1997-2002 Alfredo K. Kojima * Copyright (c) 1998-2002 Dan Pascu - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ @@ -106,32 +106,32 @@ appearanceObserver(void *self, WMNotification *notif) int flags = (int)WMGetNotificationClientData(notif); if (!menu->flags.realized) - return; - + return; + if (WMGetNotificationName(notif) == WNMenuAppearanceSettingsChanged) { - if (flags & WFontSettings) { - menu->flags.realized = 0; - wMenuRealize(menu); - } - if (flags & WTextureSettings) { - if (!menu->flags.brother) - updateTexture(menu); - } - if (flags & (WTextureSettings|WColorSettings)) { - wMenuPaint(menu); - } + if (flags & WFontSettings) { + menu->flags.realized = 0; + wMenuRealize(menu); + } + if (flags & WTextureSettings) { + if (!menu->flags.brother) + updateTexture(menu); + } + if (flags & (WTextureSettings|WColorSettings)) { + wMenuPaint(menu); + } } else if (menu->flags.titled) { - if (flags & WFontSettings) { - menu->flags.realized = 0; - wMenuRealize(menu); - } - if (flags & WTextureSettings) { - menu->frame->flags.need_texture_remake = 1; - } - if (flags & (WColorSettings|WTextureSettings)) { - wFrameWindowPaint(menu->frame); - } + if (flags & WFontSettings) { + menu->flags.realized = 0; + wMenuRealize(menu); + } + if (flags & WTextureSettings) { + menu->frame->flags.need_texture_remake = 1; + } + if (flags & (WColorSettings|WTextureSettings)) { + wFrameWindowPaint(menu->frame); + } } } @@ -145,10 +145,10 @@ appearanceObserver(void *self, WMNotification *notif) * is True, the created menu will be a main menu, which has some special * properties such as being placed over other normal menus. * If title is NULL, the menu will have no titlebar. - * + * * Returns: * The created menu. - *---------------------------------------------------------------------- + *---------------------------------------------------------------------- */ WMenu* wMenuCreate(WScreen *screen, char *title, int main_menu) @@ -156,7 +156,7 @@ wMenuCreate(WScreen *screen, char *title, int main_menu) WMenu *menu; static int brother=0; int tmp, flags; - + menu = wmalloc(sizeof(WMenu)); memset(menu, 0, sizeof(WMenu)); @@ -169,23 +169,23 @@ wMenuCreate(WScreen *screen, char *title, int main_menu) flags = WFF_SINGLE_STATE|WFF_BORDER; if (title) { - flags |= WFF_TITLEBAR|WFF_RIGHT_BUTTON; - menu->flags.titled = 1; + flags |= WFF_TITLEBAR|WFF_RIGHT_BUTTON; + menu->flags.titled = 1; } menu->frame = - wFrameWindowCreate(screen, tmp, 8, 2, 1, 1, &wPreferences.menu_title_clearance, flags, - screen->menu_title_texture, NULL, - screen->menu_title_pixel, + wFrameWindowCreate(screen, tmp, 8, 2, 1, 1, &wPreferences.menu_title_clearance, flags, + screen->menu_title_texture, NULL, + screen->menu_title_color, &screen->menu_title_font); - + menu->frame->core->descriptor.parent = menu; menu->frame->core->descriptor.parent_type = WCLASS_MENU; menu->frame->core->descriptor.handle_mousedown = menuMouseDown; - + wFrameWindowHideButton(menu->frame, WFF_RIGHT_BUTTON); if (title) { - menu->frame->title = wstrdup(title); + menu->frame->title = wstrdup(title); } menu->frame->flags.justification = WTJ_LEFT; @@ -196,50 +196,50 @@ wMenuCreate(WScreen *screen, char *title, int main_menu) menu->alloced_entries = 0; menu->selected_entry = -1; menu->entries = NULL; - + menu->frame_x = screen->app_menu_x; menu->frame_y = screen->app_menu_y; - + menu->frame->child = menu; menu->flags.lowered = 0; /* create borders */ if (title) { - /* setup object descriptors */ - menu->frame->on_mousedown_titlebar = menuTitleMouseDown; - menu->frame->on_dblclick_titlebar = menuTitleDoubleClick; + /* setup object descriptors */ + menu->frame->on_mousedown_titlebar = menuTitleMouseDown; + menu->frame->on_dblclick_titlebar = menuTitleDoubleClick; } - + menu->frame->on_click_right = menuCloseClick; - - + + menu->menu = wCoreCreate(menu->frame->core, 0, menu->frame->top_width, - menu->frame->core->width, 10); + menu->frame->core->width, 10); menu->menu->descriptor.parent = menu; menu->menu->descriptor.parent_type = WCLASS_MENU; menu->menu->descriptor.handle_expose = menuExpose; menu->menu->descriptor.handle_mousedown = menuMouseDown; - + menu->menu_texture_data = None; XMapWindow(dpy, menu->menu->window); XFlush(dpy); - + if (!brother) { - brother = 1; - menu->brother = wMenuCreate(screen, title, main_menu); - brother = 0; - menu->brother->flags.brother = 1; - menu->brother->brother = menu; + brother = 1; + menu->brother = wMenuCreate(screen, title, main_menu); + brother = 0; + menu->brother->flags.brother = 1; + menu->brother->brother = menu; } WMAddNotificationObserver(appearanceObserver, menu, - WNMenuAppearanceSettingsChanged, menu); + WNMenuAppearanceSettingsChanged, menu); WMAddNotificationObserver(appearanceObserver, menu, - WNMenuTitleAppearanceSettingsChanged, menu); + WNMenuTitleAppearanceSettingsChanged, menu); return menu; @@ -252,10 +252,10 @@ WMenu* wMenuCreateForApp(WScreen *screen, char *title, int main_menu) { WMenu *menu; - + menu = wMenuCreate(screen, title, main_menu); if (!menu) - return NULL; + return NULL; menu->flags.app_menu = 1; menu->brother->flags.app_menu = 1; @@ -268,10 +268,10 @@ static void insertEntry(WMenu *menu, WMenuEntry *entry, int index) { int i; - + for (i = menu->entry_no-1; i >= index; i--) { - menu->entries[i]->order++; - menu->entries[i+1] = menu->entries[i]; + menu->entries[i]->order++; + menu->entries[i+1] = menu->entries[i]; } menu->entries[index] = entry; } @@ -279,26 +279,26 @@ insertEntry(WMenu *menu, WMenuEntry *entry, int index) WMenuEntry* wMenuInsertCallback(WMenu *menu, int index, char *text, - void (*callback)(WMenu *menu, WMenuEntry *entry), - void *clientdata) + void (*callback)(WMenu *menu, WMenuEntry *entry), + void *clientdata) { WMenuEntry *entry; menu->flags.realized = 0; menu->brother->flags.realized = 0; - + /* reallocate array if it's too small */ if (menu->entry_no >= menu->alloced_entries) { - void *tmp; + void *tmp; - tmp = wrealloc(menu->entries, - sizeof(WMenuEntry)*(menu->alloced_entries+5)); + tmp = wrealloc(menu->entries, + sizeof(WMenuEntry)*(menu->alloced_entries+5)); - menu->entries = tmp; - menu->alloced_entries += 5; - - menu->brother->entries = tmp; - menu->brother->alloced_entries = menu->alloced_entries; + menu->entries = tmp; + menu->alloced_entries += 5; + + menu->brother->entries = tmp; + menu->brother->alloced_entries = menu->alloced_entries; } entry = wmalloc(sizeof(WMenuEntry)); memset(entry, 0, sizeof(WMenuEntry)); @@ -308,16 +308,16 @@ wMenuInsertCallback(WMenu *menu, int index, char *text, entry->clientdata = clientdata; entry->callback = callback; if (index<0 || index>=menu->entry_no) { - entry->order = menu->entry_no; - menu->entries[menu->entry_no] = entry; + entry->order = menu->entry_no; + menu->entries[menu->entry_no] = entry; } else { - entry->order = index; - insertEntry(menu, entry, index); + entry->order = index; + insertEntry(menu, entry, index); } - + menu->entry_no++; menu->brother->entry_no = menu->entry_no; - + return entry; } @@ -330,69 +330,69 @@ wMenuEntrySetCascade(WMenu *menu, WMenuEntry *entry, WMenu *cascade) int i, done; assert(menu->flags.brother==0); - + if (entry->cascade>=0) { - menu->flags.realized = 0; - brother->flags.realized = 0; + menu->flags.realized = 0; + brother->flags.realized = 0; } - + cascade->parent = menu; cascade->brother->parent = brother; done = 0; for (i=0; icascade_no; i++) { - if (menu->cascades[i]==NULL) { - menu->cascades[i] = cascade; - brother->cascades[i] = cascade->brother; - done = 1; - entry->cascade = i; - break; - } + if (menu->cascades[i]==NULL) { + menu->cascades[i] = cascade; + brother->cascades[i] = cascade->brother; + done = 1; + entry->cascade = i; + break; + } } if (!done) { - entry->cascade = menu->cascade_no; + entry->cascade = menu->cascade_no; - menu->cascades = wrealloc(menu->cascades, - sizeof(WMenu)*(menu->cascade_no+1)); - menu->cascades[menu->cascade_no++] = cascade; - + menu->cascades = wrealloc(menu->cascades, + sizeof(WMenu)*(menu->cascade_no+1)); + menu->cascades[menu->cascade_no++] = cascade; - brother->cascades = wrealloc(brother->cascades, - sizeof(WMenu)*(brother->cascade_no+1)); - brother->cascades[brother->cascade_no++] = cascade->brother; + + brother->cascades = wrealloc(brother->cascades, + sizeof(WMenu)*(brother->cascade_no+1)); + brother->cascades[brother->cascade_no++] = cascade->brother; } if (menu->flags.lowered) { - - cascade->flags.lowered = 1; - ChangeStackingLevel(cascade->frame->core, WMNormalLevel); - - cascade->brother->flags.lowered = 1; - ChangeStackingLevel(cascade->brother->frame->core, WMNormalLevel); + + cascade->flags.lowered = 1; + ChangeStackingLevel(cascade->frame->core, WMNormalLevel); + + cascade->brother->flags.lowered = 1; + ChangeStackingLevel(cascade->brother->frame->core, WMNormalLevel); } - + if (!menu->flags.realized) - wMenuRealize(menu); + wMenuRealize(menu); } void wMenuEntryRemoveCascade(WMenu *menu, WMenuEntry *entry) -{ +{ assert(menu->flags.brother==0); - + /* destroy cascade menu */ if (entry->cascade>=0 && menu->cascades - && menu->cascades[entry->cascade]!=NULL) { + && menu->cascades[entry->cascade]!=NULL) { - wMenuDestroy(menu->cascades[entry->cascade], True); + wMenuDestroy(menu->cascades[entry->cascade], True); - menu->cascades[entry->cascade] = NULL; - menu->brother->cascades[entry->cascade] = NULL; + menu->cascades[entry->cascade] = NULL; + menu->brother->cascades[entry->cascade] = NULL; - entry->cascade = -1; + entry->cascade = -1; } } @@ -401,33 +401,33 @@ void wMenuRemoveItem(WMenu *menu, int index) { int i; - + if (menu->flags.brother) { - wMenuRemoveItem(menu->brother, index); - return; + wMenuRemoveItem(menu->brother, index); + return; } - + if (index>=menu->entry_no) return; /* destroy cascade menu */ wMenuEntryRemoveCascade(menu, menu->entries[index]); - + /* destroy unshared data */ if (menu->entries[index]->text) - wfree(menu->entries[index]->text); - + wfree(menu->entries[index]->text); + if (menu->entries[index]->rtext) - wfree(menu->entries[index]->rtext); - + wfree(menu->entries[index]->rtext); + if (menu->entries[index]->free_cdata && menu->entries[index]->clientdata) - (*menu->entries[index]->free_cdata)(menu->entries[index]->clientdata); + (*menu->entries[index]->free_cdata)(menu->entries[index]->clientdata); wfree(menu->entries[index]); - + for (i=index; ientry_no-1; i++) { - menu->entries[i+1]->order--; - menu->entries[i]=menu->entries[i+1]; + menu->entries[i+1]->order--; + menu->entries[i]=menu->entries[i+1]; } menu->entry_no--; menu->brother->entry_no--; @@ -447,43 +447,43 @@ renderTexture(WMenu *menu) WTexture *texture = scr->menu_item_texture; if (wPreferences.menu_style == MS_NORMAL) { - img = wTextureRenderImage(texture, menu->menu->width, - menu->entry_height, WREL_MENUENTRY); + img = wTextureRenderImage(texture, menu->menu->width, + menu->entry_height, WREL_MENUENTRY); } else { - img = wTextureRenderImage(texture, menu->menu->width, - menu->menu->height+1, WREL_MENUENTRY); + img = wTextureRenderImage(texture, menu->menu->width, + menu->menu->height+1, WREL_MENUENTRY); } if (!img) { - wwarning(_("could not render texture: %s"), - RMessageForError(RErrorCode)); + wwarning(_("could not render texture: %s"), + RMessageForError(RErrorCode)); - return None; + return None; } if (wPreferences.menu_style == MS_SINGLE_TEXTURE) { - light.alpha = 0; - light.red = light.green = light.blue = 80; - - dark.alpha = 255; - dark.red = dark.green = dark.blue = 0; - - mid.alpha = 0; - mid.red = mid.green = mid.blue = 40; - - for (i = 1; i < menu->entry_no; i++) { - ROperateLine(img, RSubtractOperation, 0, i*menu->entry_height-2, - menu->menu->width-1, i*menu->entry_height-2, &mid); - - RDrawLine(img, 0, i*menu->entry_height-1, - menu->menu->width-1, i*menu->entry_height-1, &dark); + light.alpha = 0; + light.red = light.green = light.blue = 80; - ROperateLine(img, RAddOperation, 0, i*menu->entry_height, - menu->menu->width-1, i*menu->entry_height, - &light); - } + dark.alpha = 255; + dark.red = dark.green = dark.blue = 0; + + mid.alpha = 0; + mid.red = mid.green = mid.blue = 40; + + for (i = 1; i < menu->entry_no; i++) { + ROperateLine(img, RSubtractOperation, 0, i*menu->entry_height-2, + menu->menu->width-1, i*menu->entry_height-2, &mid); + + RDrawLine(img, 0, i*menu->entry_height-1, + menu->menu->width-1, i*menu->entry_height-1, &dark); + + ROperateLine(img, RAddOperation, 0, i*menu->entry_height, + menu->menu->width-1, i*menu->entry_height, + &light); + } } if (!RConvertImage(scr->rcontext, img, &pix)) { - wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode)); + wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode)); } RReleaseImage(img); @@ -498,28 +498,28 @@ updateTexture(WMenu *menu) /* setup background texture */ if (scr->menu_item_texture->any.type != WTEX_SOLID) { - if (!menu->flags.brother) { - FREE_PIXMAP(menu->menu_texture_data); + if (!menu->flags.brother) { + FREE_PIXMAP(menu->menu_texture_data); - menu->menu_texture_data = renderTexture(menu); + menu->menu_texture_data = renderTexture(menu); - XSetWindowBackgroundPixmap(dpy, menu->menu->window, - menu->menu_texture_data); - XClearWindow(dpy, menu->menu->window); + XSetWindowBackgroundPixmap(dpy, menu->menu->window, + menu->menu_texture_data); + XClearWindow(dpy, menu->menu->window); - XSetWindowBackgroundPixmap(dpy, menu->brother->menu->window, - menu->menu_texture_data); - XClearWindow(dpy, menu->brother->menu->window); - } + XSetWindowBackgroundPixmap(dpy, menu->brother->menu->window, + menu->menu_texture_data); + XClearWindow(dpy, menu->brother->menu->window); + } } else { - XSetWindowBackground(dpy, menu->menu->window, - scr->menu_item_texture->any.color.pixel); - XClearWindow(dpy, menu->menu->window); + XSetWindowBackground(dpy, menu->menu->window, + scr->menu_item_texture->any.color.pixel); + XClearWindow(dpy, menu->menu->window); } } -void +void wMenuRealize(WMenu *menu) { int i; @@ -530,67 +530,67 @@ wMenuRealize(WMenu *menu) int flags; if (!brother_done) { - brother_done = 1; - wMenuRealize(menu->brother); - brother_done = 0; + brother_done = 1; + wMenuRealize(menu->brother); + brother_done = 0; } flags = WFF_SINGLE_STATE|WFF_BORDER; if (menu->flags.titled) - flags |= WFF_TITLEBAR|WFF_RIGHT_BUTTON; + flags |= WFF_TITLEBAR|WFF_RIGHT_BUTTON; wFrameWindowUpdateBorders(menu->frame, flags); if (menu->flags.titled) { - twidth = WMWidthOfString(scr->menu_title_font, menu->frame->title, - strlen(menu->frame->title)); + twidth = WMWidthOfString(scr->menu_title_font, menu->frame->title, + strlen(menu->frame->title)); theight = menu->frame->top_width; twidth += theight + (wPreferences.new_style ? 16 : 8); } else { - twidth = 0; - theight = 0; + twidth = 0; + theight = 0; } eheight = WMFontHeight(scr->menu_entry_font) + 6 + wPreferences.menu_text_clearance * 2; menu->entry_height = eheight; mrwidth = 0; mwidth = 0; for (i=0; ientry_no; i++) { - char *text; + char *text; - /* search widest text */ - text = menu->entries[i]->text; - width = WMWidthOfString(scr->menu_entry_font, text, strlen(text))+10; + /* search widest text */ + text = menu->entries[i]->text; + width = WMWidthOfString(scr->menu_entry_font, text, strlen(text))+10; - if (menu->entries[i]->flags.indicator) { - width += MENU_INDICATOR_SPACE; - } + if (menu->entries[i]->flags.indicator) { + width += MENU_INDICATOR_SPACE; + } - if (width > mwidth) - mwidth = width; - - /* search widest text on right */ - text = menu->entries[i]->rtext; - if (text) - rwidth = WMWidthOfString(scr->menu_entry_font, text, strlen(text)) - + 5; - else if (menu->entries[i]->cascade>=0) - rwidth = 16; - else - rwidth = 4; + if (width > mwidth) + mwidth = width; - if (rwidth > mrwidth) - mrwidth = rwidth; + /* search widest text on right */ + text = menu->entries[i]->rtext; + if (text) + rwidth = WMWidthOfString(scr->menu_entry_font, text, strlen(text)) + + 5; + else if (menu->entries[i]->cascade>=0) + rwidth = 16; + else + rwidth = 4; + + if (rwidth > mrwidth) + mrwidth = rwidth; } mwidth += mrwidth; - - if (mwidth < twidth) - mwidth = twidth; - + if (mwidth < twidth) + mwidth = twidth; + + wCoreConfigure(menu->menu, 0, theight, mwidth, menu->entry_no*eheight -1); wFrameWindowResize(menu->frame, mwidth, menu->entry_no*eheight-1 - + menu->frame->top_width + menu->frame->bottom_width); + + menu->frame->top_width + menu->frame->bottom_width); updateTexture(menu); @@ -598,9 +598,9 @@ wMenuRealize(WMenu *menu) menu->flags.realized = 1; if (menu->flags.mapped) - wMenuPaint(menu); + wMenuPaint(menu); if (menu->brother->flags.mapped) - wMenuPaint(menu->brother); + wMenuPaint(menu->brother); } @@ -610,67 +610,67 @@ wMenuDestroy(WMenu *menu, int recurse) int i; WMRemoveNotificationObserver(menu); - + /* remove any pending timers */ if (menu->timer) - WMDeleteTimerHandler(menu->timer); + WMDeleteTimerHandler(menu->timer); menu->timer = NULL; - + /* call destroy handler */ if (menu->on_destroy) - (*menu->on_destroy)(menu); - + (*menu->on_destroy)(menu); + /* Destroy items if this menu own them. If this is the "brother" menu, * leave them alone as it is shared by them. */ if (!menu->flags.brother) { - for (i=0; ientry_no; i++) { + for (i=0; ientry_no; i++) { - wfree(menu->entries[i]->text); + wfree(menu->entries[i]->text); - if (menu->entries[i]->rtext) - wfree(menu->entries[i]->rtext); + if (menu->entries[i]->rtext) + wfree(menu->entries[i]->rtext); #ifdef USER_MENU - if (menu->entries[i]->instances){ - WMReleasePropList(menu->entries[i]->instances); - } + if (menu->entries[i]->instances){ + WMReleasePropList(menu->entries[i]->instances); + } #endif /* USER_MENU */ - if (menu->entries[i]->free_cdata && menu->entries[i]->clientdata) { - (*menu->entries[i]->free_cdata)(menu->entries[i]->clientdata); - } - wfree(menu->entries[i]); - } + if (menu->entries[i]->free_cdata && menu->entries[i]->clientdata) { + (*menu->entries[i]->free_cdata)(menu->entries[i]->clientdata); + } + wfree(menu->entries[i]); + } + + if (recurse) { + for (i=0; icascade_no; i++) { + if (menu->cascades[i]) { + if (menu->cascades[i]->flags.brother) + wMenuDestroy(menu->cascades[i]->brother, recurse); + else + wMenuDestroy(menu->cascades[i], recurse); + } + } + } + + if (menu->entries) + wfree(menu->entries); - if (recurse) { - for (i=0; icascade_no; i++) { - if (menu->cascades[i]) { - if (menu->cascades[i]->flags.brother) - wMenuDestroy(menu->cascades[i]->brother, recurse); - else - wMenuDestroy(menu->cascades[i], recurse); - } - } - } - - if (menu->entries) - wfree(menu->entries); - } FREE_PIXMAP(menu->menu_texture_data); - + if (menu->cascades) wfree(menu->cascades); wCoreDestroy(menu->menu); wFrameWindowDestroy(menu->frame); - + /* destroy copy of this menu */ if (!menu->flags.brother && menu->brother) - wMenuDestroy(menu->brother, False); - + wMenuDestroy(menu->brother, False); + wfree(menu); } @@ -692,10 +692,10 @@ drawFrame(WScreen *scr, Drawable win, int y, int w, int h, int type) segs[i].y2 = y + h - 1; i++; if (type != F_TOP && type != F_NONE) { - segs[i].x1 = 1; - segs[i].y1 = segs[i].y2 = y + h-2; - segs[i].x2 = w-1; - i++; + segs[i].x1 = 1; + segs[i].y1 = segs[i].y2 = y + h-2; + segs[i].x2 = w-1; + i++; } XDrawSegments(dpy, win, scr->menu_item_auxtexture->dim_gc, segs, i); @@ -706,31 +706,30 @@ drawFrame(WScreen *scr, Drawable win, int y, int w, int h, int type) segs[i].y2 = y + h - 1; i++; if (type != F_BOTTOM && type != F_NONE) { - segs[i].x1 = 0; - segs[i].y1 = y; - segs[i].x2 = w-1; - segs[i].y2 = y; - i++; + segs[i].x1 = 0; + segs[i].y1 = y; + segs[i].x2 = w-1; + segs[i].y2 = y; + i++; } XDrawSegments(dpy, win, scr->menu_item_auxtexture->light_gc, segs, i); if (type != F_TOP && type != F_NONE) - XDrawLine(dpy, win, scr->menu_item_auxtexture->dark_gc, 0, y+h-1, - w-1, y+h-1); + XDrawLine(dpy, win, scr->menu_item_auxtexture->dark_gc, 0, y+h-1, + w-1, y+h-1); } static void paintEntry(WMenu *menu, int index, int selected) { - int x, y, w, h, tw; - int type; - GC light, dim, dark, textGC, saveGC; - WMColor *color; - WMPixel pixel, savePixel; WScreen *scr=menu->frame->screen_ptr; Window win = menu->menu->window; WMenuEntry *entry=menu->entries[index]; + GC light, dim, dark; + WMColor *color; + int x, y, w, h, tw; + int type; if (!menu->flags.realized) return; h = menu->entry_height; @@ -742,135 +741,115 @@ paintEntry(WMenu *menu, int index, int selected) dark = scr->menu_item_auxtexture->dark_gc; if (wPreferences.menu_style == MS_FLAT && menu->entry_no > 1) { - if (index == 0) - type = F_TOP; - else if (index == menu->entry_no - 1) - type = F_BOTTOM; - else - type = F_NONE; + if (index == 0) + type = F_TOP; + else if (index == menu->entry_no - 1) + type = F_BOTTOM; + else + type = F_NONE; } else { - type = F_NORMAL; + type = F_NORMAL; } - + /* paint background */ if (selected) { - XSetForeground(dpy, scr->select_menu_gc, scr->select_pixel); - XFillRectangle(dpy, win, scr->select_menu_gc, 1, y+1, w-2, h-3); - if (scr->menu_item_texture->any.type == WTEX_SOLID) - drawFrame(scr, win, y, w, h, type); - } else { - if (scr->menu_item_texture->any.type == WTEX_SOLID) { - XClearArea(dpy, win, 0, y + 1, w - 1, h - 3, False); - /* draw the frame */ - drawFrame(scr, win, y, w, h, type); - } else { - XClearArea(dpy, win, 0, y, w, h, False); - } + XFillRectangle(dpy, win, WMColorGC(scr->white), 1, y+1, w-2, h-3); + if (scr->menu_item_texture->any.type == WTEX_SOLID) + drawFrame(scr, win, y, w, h, type); + } else { + if (scr->menu_item_texture->any.type == WTEX_SOLID) { + XClearArea(dpy, win, 0, y + 1, w - 1, h - 3, False); + /* draw the frame */ + drawFrame(scr, win, y, w, h, type); + } else { + XClearArea(dpy, win, 0, y, w, h, False); + } } - /* very ugly hack */ - saveGC = scr->wmscreen->drawStringGC; - color = WMBlackColor(scr->wmscreen); - savePixel = color->color.pixel; - if (selected) { - textGC = scr->select_menu_gc; - if (entry->flags.enabled) - pixel = scr->select_text_pixel; - else - pixel = scr->dtext_pixel; + if (entry->flags.enabled) + color = scr->select_text_color; + else + color = scr->dtext_color; } else if (!entry->flags.enabled) { - textGC = scr->disabled_menu_entry_gc; - pixel = scr->dtext_pixel; + color = scr->dtext_color; } else { - textGC = scr->menu_entry_gc; - pixel = scr->mtext_pixel; + color = scr->mtext_color; } - /* draw text */ + /* draw text */ x = 5; if (entry->flags.indicator) - x += MENU_INDICATOR_SPACE + 2; + x += MENU_INDICATOR_SPACE + 2; - /* this is nasty */ - scr->wmscreen->drawStringGC = textGC; - color->color.pixel = pixel; WMDrawString(scr->wmscreen, win, color, scr->menu_entry_font, - x, 3 + y + wPreferences.menu_text_clearance, entry->text, strlen(entry->text)); - color->color.pixel = savePixel; - scr->wmscreen->drawStringGC = saveGC; + x, 3 + y + wPreferences.menu_text_clearance, entry->text, strlen(entry->text)); if (entry->cascade>=0) { - /* draw the cascade indicator */ - XDrawLine(dpy,win,dim, w-11, y+6, w-6, y+h/2-1); - XDrawLine(dpy,win,light, w-11, y+h-8, w-6, y+h/2-1); - XDrawLine(dpy,win,dark, w-12, y+6, w-12, y+h-8); + /* draw the cascade indicator */ + XDrawLine(dpy,win,dim, w-11, y+6, w-6, y+h/2-1); + XDrawLine(dpy,win,light, w-11, y+h-8, w-6, y+h/2-1); + XDrawLine(dpy,win,dark, w-12, y+6, w-12, y+h-8); } /* draw indicator */ if (entry->flags.indicator && entry->flags.indicator_on) { - int iw, ih; - WPixmap *indicator; + int iw, ih; + WPixmap *indicator; - - switch (entry->flags.indicator_type) { - case MI_CHECK: - indicator = scr->menu_check_indicator; - break; - case MI_MINIWINDOW: - indicator = scr->menu_mini_indicator; - break; - case MI_HIDDEN: - indicator = scr->menu_hide_indicator; - break; - case MI_SHADED: - indicator = scr->menu_shade_indicator; - break; - case MI_DIAMOND: - default: - indicator = scr->menu_radio_indicator; - break; - } - - iw = indicator->width; - ih = indicator->height; - XSetClipMask(dpy, scr->copy_gc, indicator->mask); - XSetClipOrigin(dpy, scr->copy_gc, 5, y+(h-ih)/2); + + switch (entry->flags.indicator_type) { + case MI_CHECK: + indicator = scr->menu_check_indicator; + break; + case MI_MINIWINDOW: + indicator = scr->menu_mini_indicator; + break; + case MI_HIDDEN: + indicator = scr->menu_hide_indicator; + break; + case MI_SHADED: + indicator = scr->menu_shade_indicator; + break; + case MI_DIAMOND: + default: + indicator = scr->menu_radio_indicator; + break; + } + + iw = indicator->width; + ih = indicator->height; + XSetClipMask(dpy, scr->copy_gc, indicator->mask); + XSetClipOrigin(dpy, scr->copy_gc, 5, y+(h-ih)/2); if (selected) { if (entry->flags.enabled) { XSetForeground(dpy, scr->copy_gc, scr->black_pixel); } else { - XSetForeground(dpy, scr->copy_gc, scr->dtext_pixel); + XSetForeground(dpy, scr->copy_gc, WMColorPixel(scr->dtext_color)); } } else { if (entry->flags.enabled) { - XSetForeground(dpy, scr->copy_gc, scr->mtext_pixel); + XSetForeground(dpy, scr->copy_gc, WMColorPixel(scr->mtext_color)); } else { - XSetForeground(dpy, scr->copy_gc, scr->dtext_pixel); + XSetForeground(dpy, scr->copy_gc, WMColorPixel(scr->dtext_color)); } } - XFillRectangle(dpy, win, scr->copy_gc, 5, y+(h-ih)/2, iw, ih); - /* - XCopyArea(dpy, indicator->image, win, scr->copy_gc, 0, 0, - iw, ih, 5, y+(h-ih)/2); - */ - XSetClipOrigin(dpy, scr->copy_gc, 0, 0); + XFillRectangle(dpy, win, scr->copy_gc, 5, y+(h-ih)/2, iw, ih); + /* + XCopyArea(dpy, indicator->image, win, scr->copy_gc, 0, 0, + iw, ih, 5, y+(h-ih)/2); + */ + XSetClipOrigin(dpy, scr->copy_gc, 0, 0); } /* draw right text */ - + if (entry->rtext && entry->cascade<0) { tw = WMWidthOfString(scr->menu_entry_font, entry->rtext, strlen(entry->rtext)); - /* this is nasty */ - scr->wmscreen->drawStringGC = textGC; - color->color.pixel = pixel; WMDrawString(scr->wmscreen, win, color, scr->menu_entry_font, w-6-tw, y + 3 + wPreferences.menu_text_clearance, entry->rtext, strlen(entry->rtext)); - color->color.pixel = savePixel; - scr->wmscreen->drawStringGC = saveGC; } - WMReleaseColor(color); } @@ -878,11 +857,11 @@ static void move_menus(WMenu *menu, int x, int y) { while (menu->parent) { - menu = menu->parent; - x -= MENUW(menu); - if (!wPreferences.align_menus && menu->selected_entry>=0) { - y -= menu->selected_entry*menu->entry_height; - } + menu = menu->parent; + x -= MENUW(menu); + if (!wPreferences.align_menus && menu->selected_entry>=0) { + y -= menu->selected_entry*menu->entry_height; + } } wMenuMove(menu, x, y, True); } @@ -892,37 +871,37 @@ makeVisible(WMenu *menu) { WScreen *scr = menu->frame->screen_ptr; int x1, y1, x2, y2, new_x, new_y, move; - + if (menu->entry_no<0) return; - + x1 = menu->frame_x; y1 = menu->frame_y+menu->frame->top_width - + menu->selected_entry*menu->entry_height; + + menu->selected_entry*menu->entry_height; x2 = x1 + MENUW(menu); y2 = y1 + menu->entry_height; - + new_x = x1; new_y = y1; move = 0; if (x1 < 0) { - new_x = 0; - move = 1; + new_x = 0; + move = 1; } else if (x2 >= scr->scr_width) { - new_x = scr->scr_width - MENUW(menu) - 1; - move = 1; + new_x = scr->scr_width - MENUW(menu) - 1; + move = 1; } if (y1 < 0) { - new_y = 0; - move = 1; + new_y = 0; + move = 1; } else if (y2 >= scr->scr_height) { - new_y = scr->scr_height - menu->entry_height - 1; - move = 1; + new_y = scr->scr_height - menu->entry_height - 1; + move = 1; } new_y = new_y - menu->frame->top_width - - menu->selected_entry*menu->entry_height; + - menu->selected_entry*menu->entry_height; move_menus(menu, new_x, new_y); } @@ -932,25 +911,25 @@ check_key(WMenu *menu, XKeyEvent *event) { int i, ch, s; char buffer[32]; - + if (XLookupString(event, buffer, 32, NULL, NULL)<1) - return -1; - + return -1; + ch = toupper(buffer[0]); - + s = (menu->selected_entry>=0 ? menu->selected_entry+1 : 0); - + again: for (i=s; ientry_no; i++) { - if (ch==toupper(menu->entries[i]->text[0])) { - return i; - } + if (ch==toupper(menu->entries[i]->text[0])) { + return i; + } } /* no match. Retry from start, if previous started from a selected entry */ if (s!=0) { - s = 0; - goto again; - } + s = 0; + goto again; + } return -1; } @@ -970,182 +949,182 @@ keyboardMenu(WMenu *menu) int scr_height = menu->frame->screen_ptr->scr_height; if (menu->flags.editing) - return False; + return False; XGrabKeyboard(dpy, menu->frame->core->window, True, GrabModeAsync, - GrabModeAsync, CurrentTime); + GrabModeAsync, CurrentTime); if (menu->frame_y+menu->frame->top_width >= scr_height) - new_y = scr_height - menu->frame->top_width; - + new_y = scr_height - menu->frame->top_width; + if (menu->frame_x+MENUW(menu) >= scr_width) - new_x = scr_width-MENUW(menu)-1; - + new_x = scr_width-MENUW(menu)-1; + move_menus(menu, new_x, new_y); while (!done && menu->flags.mapped) { - XAllowEvents(dpy, AsyncKeyboard, CurrentTime); - WMMaskEvent(dpy, ExposureMask|ButtonMotionMask|ButtonPressMask - |ButtonReleaseMask|KeyPressMask|KeyReleaseMask - |SubstructureNotifyMask, &event); + XAllowEvents(dpy, AsyncKeyboard, CurrentTime); + WMMaskEvent(dpy, ExposureMask|ButtonMotionMask|ButtonPressMask + |ButtonReleaseMask|KeyPressMask|KeyReleaseMask + |SubstructureNotifyMask, &event); - switch (event.type) { - case KeyPress: - ksym = XLookupKeysym(&event.xkey, 0); - switch (ksym) { - case XK_Escape: - done = 1; - break; + switch (event.type) { + case KeyPress: + ksym = XLookupKeysym(&event.xkey, 0); + switch (ksym) { + case XK_Escape: + done = 1; + break; - case XK_Home: + case XK_Home: #ifdef XK_KP_Home - case XK_KP_Home: + case XK_KP_Home: #endif - selectEntry(menu, 0); - makeVisible(menu); - break; - - case XK_End: + selectEntry(menu, 0); + makeVisible(menu); + break; + + case XK_End: #ifdef XK_KP_End - case XK_KP_End: + case XK_KP_End: #endif - selectEntry(menu, menu->entry_no-1); - makeVisible(menu); - break; - - case XK_Up: + selectEntry(menu, menu->entry_no-1); + makeVisible(menu); + break; + + case XK_Up: #ifdef ARROWLESS_KBD - case XK_k: + case XK_k: #endif #ifdef XK_KP_Up - case XK_KP_Up: + case XK_KP_Up: #endif - if (menu->selected_entry <= 0) + if (menu->selected_entry <= 0) selectEntry(menu, menu->entry_no-1); - else - selectEntry(menu, menu->selected_entry-1); - makeVisible(menu); - break; - - case XK_Down: + else + selectEntry(menu, menu->selected_entry-1); + makeVisible(menu); + break; + + case XK_Down: #ifdef ARROWLESS_KBD - case XK_j: + case XK_j: #endif #ifdef XK_KP_Down - case XK_KP_Down: + case XK_KP_Down: #endif - if (menu->selected_entry<0) + if (menu->selected_entry<0) selectEntry(menu, 0); else if (menu->selected_entry == menu->entry_no-1) selectEntry(menu, 0); - else if (menu->selected_entry < menu->entry_no-1) - selectEntry(menu, menu->selected_entry+1); - makeVisible(menu); - break; - - case XK_Right: + else if (menu->selected_entry < menu->entry_no-1) + selectEntry(menu, menu->selected_entry+1); + makeVisible(menu); + break; + + case XK_Right: #ifdef ARROWLESS_KBD - case XK_l: + case XK_l: #endif #ifdef XK_KP_Right - case XK_KP_Right: + case XK_KP_Right: #endif - if (menu->selected_entry>=0) { - WMenuEntry *entry; - entry = menu->entries[menu->selected_entry]; + if (menu->selected_entry>=0) { + WMenuEntry *entry; + entry = menu->entries[menu->selected_entry]; - if (entry->cascade >= 0 && menu->cascades - && menu->cascades[entry->cascade]->entry_no > 0) { + if (entry->cascade >= 0 && menu->cascades + && menu->cascades[entry->cascade]->entry_no > 0) { - XUngrabKeyboard(dpy, CurrentTime); + XUngrabKeyboard(dpy, CurrentTime); - selectEntry(menu->cascades[entry->cascade], 0); - if (!keyboardMenu(menu->cascades[entry->cascade])) - done = 1; + selectEntry(menu->cascades[entry->cascade], 0); + if (!keyboardMenu(menu->cascades[entry->cascade])) + done = 1; - XGrabKeyboard(dpy, menu->frame->core->window, True, - GrabModeAsync, GrabModeAsync, - CurrentTime); - } - } - break; + XGrabKeyboard(dpy, menu->frame->core->window, True, + GrabModeAsync, GrabModeAsync, + CurrentTime); + } + } + break; - case XK_Left: + case XK_Left: #ifdef ARROWLESS_KBD - case XK_h: + case XK_h: #endif #ifdef XK_KP_Left - case XK_KP_Left: + case XK_KP_Left: #endif - if (menu->parent!=NULL && menu->parent->selected_entry>=0) { - selectEntry(menu, -1); - move_menus(menu, old_pos_x, old_pos_y); - return True; - } - break; - - case XK_Return: - done = 2; - break; - - default: - index = check_key(menu, &event.xkey); - if (index>=0) { - selectEntry(menu, index); - } - } - break; - - default: - if (event.type==ButtonPress) - done = 1; - - WMHandleEvent(&event); - } + if (menu->parent!=NULL && menu->parent->selected_entry>=0) { + selectEntry(menu, -1); + move_menus(menu, old_pos_x, old_pos_y); + return True; + } + break; + + case XK_Return: + done = 2; + break; + + default: + index = check_key(menu, &event.xkey); + if (index>=0) { + selectEntry(menu, index); + } + } + break; + + default: + if (event.type==ButtonPress) + done = 1; + + WMHandleEvent(&event); + } } XUngrabKeyboard(dpy, CurrentTime); if (done==2 && menu->selected_entry>=0) { - entry = menu->entries[menu->selected_entry]; + entry = menu->entries[menu->selected_entry]; } else { - entry = NULL; + entry = NULL; } if (entry && entry->callback!=NULL && entry->flags.enabled - && entry->cascade < 0) { + && entry->cascade < 0) { #if (MENU_BLINK_COUNT > 0) - int sel = menu->selected_entry; - int i; - - for (i=0; iselected_entry; + int i; - if (!menu->flags.buttoned) { - wMenuUnmap(menu); - move_menus(menu, old_pos_x, old_pos_y); - } - closeCascade(menu); - - (*entry->callback)(menu, entry); + for (i=0; iflags.buttoned) { + wMenuUnmap(menu); + move_menus(menu, old_pos_x, old_pos_y); + } + closeCascade(menu); + + (*entry->callback)(menu, entry); } else { - if (!menu->flags.buttoned) { - wMenuUnmap(menu); - move_menus(menu, old_pos_x, old_pos_y); - } - selectEntry(menu, -1); + if (!menu->flags.buttoned) { + wMenuUnmap(menu); + move_menus(menu, old_pos_x, old_pos_y); + } + selectEntry(menu, -1); } - + /* returns True if returning from a submenu to a parent menu, * False if exiting from menu */ return False; @@ -1159,8 +1138,8 @@ wMenuMapAt(WMenu *menu, int x, int y, int keyboard) int scr_height = menu->frame->screen_ptr->scr_height; if (!menu->flags.realized) { - menu->flags.realized=1; - wMenuRealize(menu); + menu->flags.realized=1; + wMenuRealize(menu); } if (!menu->flags.mapped) { if (wPreferences.wrap_menus) { @@ -1181,23 +1160,23 @@ wMenuMapAt(WMenu *menu, int x, int y, int keyboard) } else { selectEntry(menu, 0); } - + if (keyboard) - keyboardMenu(menu); + keyboardMenu(menu); } void wMenuMap(WMenu *menu) -{ +{ if (!menu->flags.realized) { - menu->flags.realized=1; - wMenuRealize(menu); + menu->flags.realized=1; + wMenuRealize(menu); } if (menu->flags.app_menu && menu->parent==NULL) { - menu->frame_x = menu->frame->screen_ptr->app_menu_x; - menu->frame_y = menu->frame->screen_ptr->app_menu_y; - XMoveWindow(dpy, menu->frame->core->window, menu->frame_x, menu->frame_y); + menu->frame_x = menu->frame->screen_ptr->app_menu_x; + menu->frame_y = menu->frame->screen_ptr->app_menu_y; + XMoveWindow(dpy, menu->frame->core->window, menu->frame_x, menu->frame_y); } XMapWindow(dpy, menu->frame->core->window); wRaiseFrame(menu->frame->core); @@ -1212,37 +1191,37 @@ wMenuUnmap(WMenu *menu) XUnmapWindow(dpy, menu->frame->core->window); if (menu->flags.titled && menu->flags.buttoned) { - wFrameWindowHideButton(menu->frame, WFF_RIGHT_BUTTON); + wFrameWindowHideButton(menu->frame, WFF_RIGHT_BUTTON); } menu->flags.buttoned = 0; menu->flags.mapped = 0; menu->flags.open_to_left = 0; for (i=0; icascade_no; i++) { - if (menu->cascades[i]!=NULL - && menu->cascades[i]->flags.mapped - && !menu->cascades[i]->flags.buttoned) { - - wMenuUnmap(menu->cascades[i]); - } + if (menu->cascades[i]!=NULL + && menu->cascades[i]->flags.mapped + && !menu->cascades[i]->flags.buttoned) { + + wMenuUnmap(menu->cascades[i]); + } } menu->selected_entry = -1; -} +} -void +void wMenuPaint(WMenu *menu) -{ +{ int i; - + if (!menu->flags.mapped) { - return; + return; } /* paint entries */ for (i=0; ientry_no; i++) { - paintEntry(menu, i, i==menu->selected_entry); + paintEntry(menu, i, i==menu->selected_entry); } } @@ -1270,80 +1249,80 @@ editEntry(WMenu *menu, WMenuEntry *entry) int done = 0; Window old_focus; int old_revert; - + menu->flags.editing = 1; text = wTextCreate(menu->menu, 1, menu->entry_height * entry->order, - menu->menu->width - 2, menu->entry_height - 1); + menu->menu->width - 2, menu->entry_height - 1); wTextPutText(text, entry->text); XGetInputFocus(dpy, &old_focus, &old_revert); XSetInputFocus(dpy, text->core->window, RevertToNone, CurrentTime); - + if (XGrabKeyboard(dpy, text->core->window, True, GrabModeAsync, - GrabModeAsync, CurrentTime)!=GrabSuccess) { - wwarning(_("could not grab keyboard")); - wTextDestroy(text); - - wSetFocusTo(menu->frame->screen_ptr, - menu->frame->screen_ptr->focused_window); - return; + GrabModeAsync, CurrentTime)!=GrabSuccess) { + wwarning(_("could not grab keyboard")); + wTextDestroy(text); + + wSetFocusTo(menu->frame->screen_ptr, + menu->frame->screen_ptr->focused_window); + return; } while (!done && !text->done) { - XSync(dpy, 0); - XAllowEvents(dpy, AsyncKeyboard|AsyncPointer, CurrentTime); - XSync(dpy, 0); - WMNextEvent(dpy, &event); + XSync(dpy, 0); + XAllowEvents(dpy, AsyncKeyboard|AsyncPointer, CurrentTime); + XSync(dpy, 0); + WMNextEvent(dpy, &event); - if (XFindContext(dpy, event.xany.window, wWinContext, - (XPointer *)&desc)==XCNOENT) - desc = NULL; - - if ((desc != NULL) && (desc->handle_anything != NULL)) { + if (XFindContext(dpy, event.xany.window, wWinContext, + (XPointer *)&desc)==XCNOENT) + desc = NULL; - (*desc->handle_anything)(desc, &event); + if ((desc != NULL) && (desc->handle_anything != NULL)) { - } else { - switch (event.type) { - case ButtonPress: - XAllowEvents(dpy, ReplayPointer, CurrentTime); - done = 1; + (*desc->handle_anything)(desc, &event); - default: - WMHandleEvent(&event); - break; - } - } + } else { + switch (event.type) { + case ButtonPress: + XAllowEvents(dpy, ReplayPointer, CurrentTime); + done = 1; + + default: + WMHandleEvent(&event); + break; + } + } } XSetInputFocus(dpy, old_focus, old_revert, CurrentTime); - wSetFocusTo(menu->frame->screen_ptr, - menu->frame->screen_ptr->focused_window); + wSetFocusTo(menu->frame->screen_ptr, + menu->frame->screen_ptr->focused_window); t = wTextGetText(text); /* if !t, the user has canceled editing */ if (t) { - if (entry->text) - wfree(entry->text); - entry->text = wstrdup(t); - - menu->flags.realized = 0; + if (entry->text) + wfree(entry->text); + entry->text = wstrdup(t); + + menu->flags.realized = 0; } wTextDestroy(text); - + XUngrabKeyboard(dpy, CurrentTime); - + if (t && menu->on_edit) - (*menu->on_edit)(menu, entry); - + (*menu->on_edit)(menu, entry); + menu->flags.editing = 0; if (!menu->flags.realized) - wMenuRealize(menu); + wMenuRealize(menu); } @@ -1355,59 +1334,59 @@ selectEntry(WMenu *menu, int entry_no) int old_entry; if (menu->entries==NULL) - return; - + return; + if (entry_no >= menu->entry_no) - return; + return; old_entry = menu->selected_entry; menu->selected_entry = entry_no; if (old_entry!=entry_no) { - - /* unselect previous entry */ - if (old_entry>=0) { - paintEntry(menu, old_entry, False); - entry = menu->entries[old_entry]; - - /* unmap cascade */ - if (entry->cascade>=0 && menu->cascades) { - if (!menu->cascades[entry->cascade]->flags.buttoned) { - wMenuUnmap(menu->cascades[entry->cascade]); - } - } - } - if (entry_no<0) { - menu->selected_entry = -1; - return; - } - entry = menu->entries[entry_no]; + /* unselect previous entry */ + if (old_entry>=0) { + paintEntry(menu, old_entry, False); + entry = menu->entries[old_entry]; - if (entry->cascade>=0 && menu->cascades && entry->flags.enabled) { - /* Callback for when the submenu is opened. - */ - submenu = menu->cascades[entry->cascade]; - if (submenu && submenu->flags.brother) - submenu = submenu->brother; + /* unmap cascade */ + if (entry->cascade>=0 && menu->cascades) { + if (!menu->cascades[entry->cascade]->flags.buttoned) { + wMenuUnmap(menu->cascades[entry->cascade]); + } + } + } - if (entry->callback) { - /* Only call the callback if the submenu is not yet mapped. - */ - if (menu->flags.brother) { - if (!submenu || !submenu->flags.mapped) - (*entry->callback)(menu->brother, entry); - } else { - if (!submenu || !submenu->flags.buttoned) - (*entry->callback)(menu, entry); - } - } + if (entry_no<0) { + menu->selected_entry = -1; + return; + } + entry = menu->entries[entry_no]; - /* the submenu menu might have changed */ - submenu = menu->cascades[entry->cascade]; - - /* map cascade */ - if (!submenu->flags.mapped) { + if (entry->cascade>=0 && menu->cascades && entry->flags.enabled) { + /* Callback for when the submenu is opened. + */ + submenu = menu->cascades[entry->cascade]; + if (submenu && submenu->flags.brother) + submenu = submenu->brother; + + if (entry->callback) { + /* Only call the callback if the submenu is not yet mapped. + */ + if (menu->flags.brother) { + if (!submenu || !submenu->flags.mapped) + (*entry->callback)(menu->brother, entry); + } else { + if (!submenu || !submenu->flags.buttoned) + (*entry->callback)(menu, entry); + } + } + + /* the submenu menu might have changed */ + submenu = menu->cascades[entry->cascade]; + + /* map cascade */ + if (!submenu->flags.mapped) { int x, y; if (!submenu->flags.realized) @@ -1426,7 +1405,7 @@ selectEntry(WMenu *menu, int entry_no) x = menu->frame_x + MENUW(menu); if (x + MENUW(submenu) - >= menu->frame->screen_ptr->scr_width) { + >= menu->frame->screen_ptr->scr_width) { x = menu->frame_x - MENUW(submenu); submenu->flags.open_to_left = 1; @@ -1434,7 +1413,7 @@ selectEntry(WMenu *menu, int entry_no) } } else { x = menu->frame_x + MENUW(menu); - } + } if (wPreferences.align_menus) { y = menu->frame_y; @@ -1465,20 +1444,20 @@ findMenu(WScreen *scr, int *x_ret, int *y_ret) Window root_ret, win, junk_win; int x, y, wx, wy; unsigned int mask; - + XQueryPointer(dpy, scr->root_win, &root_ret, &win, &x, &y, &wx, &wy, - &mask); - + &mask); + if (win==None) return NULL; - + if (XFindContext(dpy, win, wWinContext, (XPointer *)&desc)==XCNOENT) - return NULL; - + return NULL; + if (desc->parent_type == WCLASS_MENU) { - menu = (WMenu*)desc->parent; - XTranslateCoordinates(dpy, root_ret, menu->menu->window, wx, wy, - x_ret, y_ret, &junk_win); - return menu; + menu = (WMenu*)desc->parent; + XTranslateCoordinates(dpy, root_ret, menu->menu->window, wx, wy, + x_ret, y_ret, &junk_win); + return menu; } return NULL; } @@ -1491,26 +1470,26 @@ closeCascade(WMenu *menu) { WMenu *parent=menu->parent; - if (menu->flags.brother - || (!menu->flags.buttoned - && (!menu->flags.app_menu||menu->parent!=NULL))) { + if (menu->flags.brother + || (!menu->flags.buttoned + && (!menu->flags.app_menu||menu->parent!=NULL))) { - selectEntry(menu, -1); - XSync(dpy, 0); + selectEntry(menu, -1); + XSync(dpy, 0); #if (MENU_BLINK_DELAY > 2) - wusleep(MENU_BLINK_DELAY/2); + wusleep(MENU_BLINK_DELAY/2); #endif - wMenuUnmap(menu); - while (parent!=NULL - && (parent->parent!=NULL || !parent->flags.app_menu - || parent->flags.brother) - && !parent->flags.buttoned) { - selectEntry(parent, -1); - wMenuUnmap(parent); - parent = parent->parent; - } - if (parent) - selectEntry(parent, -1); + wMenuUnmap(menu); + while (parent!=NULL + && (parent->parent!=NULL || !parent->flags.app_menu + || parent->flags.brother) + && !parent->flags.buttoned) { + selectEntry(parent, -1); + wMenuUnmap(parent); + parent = parent->parent; + } + if (parent) + selectEntry(parent, -1); } } @@ -1520,18 +1499,18 @@ closeBrotherCascadesOf(WMenu *menu) { WMenu *tmp; int i; - + for (i=0; icascade_no; i++) { - if (menu->cascades[i]->flags.brother) { - tmp = menu->cascades[i]; - } else { - tmp = menu->cascades[i]->brother; - } - if (tmp->flags.mapped) { - selectEntry(tmp->parent, -1); - closeBrotherCascadesOf(tmp); - break; - } + if (menu->cascades[i]->flags.brother) { + tmp = menu->cascades[i]; + } else { + tmp = menu->cascades[i]->brother; + } + if (tmp->flags.mapped) { + selectEntry(tmp->parent, -1); + closeBrotherCascadesOf(tmp); + break; + } } } @@ -1546,7 +1525,7 @@ parentMenu(WMenu *menu) WMenuEntry *entry; if (menu->flags.buttoned) - return menu; + return menu; while (menu->parent && menu->parent->flags.mapped) { parent = menu->parent; @@ -1560,7 +1539,7 @@ parentMenu(WMenu *menu) if (menu->flags.buttoned) break; } - + return menu; } @@ -1644,36 +1623,36 @@ getScrollAmount(WMenu *menu, int *hamount, int *vamount) int screenW = scr->scr_width; int screenH = scr->scr_height; int xroot, yroot; - + *hamount = 0; *vamount = 0; - + getPointerPosition(scr, &xroot, &yroot); if (xroot <= 1 && menuX1 < 0) { - /* scroll to the right */ - *hamount = WMIN(MENU_SCROLL_STEP, abs(menuX1)); + /* scroll to the right */ + *hamount = WMIN(MENU_SCROLL_STEP, abs(menuX1)); } else if (xroot >= screenW-2 && menuX2 > screenW-1) { - /* scroll to the left */ - *hamount = WMIN(MENU_SCROLL_STEP, abs(menuX2-screenW-1)); - - if (*hamount==0) - *hamount = 1; + /* scroll to the left */ + *hamount = WMIN(MENU_SCROLL_STEP, abs(menuX2-screenW-1)); - *hamount = -*hamount; + if (*hamount==0) + *hamount = 1; + + *hamount = -*hamount; } - + if (yroot <= 1 && menuY1 < 0) { - /* scroll down */ - *vamount = WMIN(MENU_SCROLL_STEP, abs(menuY1)); - + /* scroll down */ + *vamount = WMIN(MENU_SCROLL_STEP, abs(menuY1)); + } else if (yroot >= screenH-2 && menuY2 > screenH-1) { - /* scroll up */ - *vamount = WMIN(MENU_SCROLL_STEP, abs(menuY2-screenH-2)); - - *vamount = -*vamount; + /* scroll up */ + *vamount = WMIN(MENU_SCROLL_STEP, abs(menuY2-screenH-2)); + + *vamount = -*vamount; } } @@ -1687,40 +1666,40 @@ dragScrollMenuCallback(void *data) int hamount, vamount; int x, y; int newSelectedEntry; - + getScrollAmount(menu, &hamount, &vamount); - - + + if (hamount != 0 || vamount != 0) { - wMenuMove(parent, parent->frame_x + hamount, - parent->frame_y + vamount, True); - if (findMenu(scr, &x, &y)) { - newSelectedEntry = getEntryAt(menu, x, y); - selectEntry(menu, newSelectedEntry); - } else { - /* Pointer fell outside of menu. If the selected entry is - * not a submenu, unselect it */ - if (menu->selected_entry >= 0 - && menu->entries[menu->selected_entry]->cascade<0) - selectEntry(menu, -1); - newSelectedEntry = 0; - } - - /* paranoid check */ - if (newSelectedEntry >= 0) { - /* keep scrolling */ - menu->timer = WMAddTimerHandler(MENU_SCROLL_DELAY, - dragScrollMenuCallback, menu); - } else { - menu->timer = NULL; - } + wMenuMove(parent, parent->frame_x + hamount, + parent->frame_y + vamount, True); + if (findMenu(scr, &x, &y)) { + newSelectedEntry = getEntryAt(menu, x, y); + selectEntry(menu, newSelectedEntry); + } else { + /* Pointer fell outside of menu. If the selected entry is + * not a submenu, unselect it */ + if (menu->selected_entry >= 0 + && menu->entries[menu->selected_entry]->cascade<0) + selectEntry(menu, -1); + newSelectedEntry = 0; + } + + /* paranoid check */ + if (newSelectedEntry >= 0) { + /* keep scrolling */ + menu->timer = WMAddTimerHandler(MENU_SCROLL_DELAY, + dragScrollMenuCallback, menu); + } else { + menu->timer = NULL; + } } else { - /* don't need to scroll anymore */ - menu->timer = NULL; - if (findMenu(scr, &x, &y)) { - newSelectedEntry = getEntryAt(menu, x, y); - selectEntry(menu, newSelectedEntry); - } + /* don't need to scroll anymore */ + menu->timer = NULL; + if (findMenu(scr, &x, &y)) { + newSelectedEntry = getEntryAt(menu, x, y); + selectEntry(menu, newSelectedEntry); + } } } @@ -1737,18 +1716,18 @@ scrollMenuCallback(void *data) /* don't scroll if it is in vdesk mode */ if (!wPreferences.vedge_thickness) #endif - getScrollAmount(menu, &hamount, &vamount); - - if (hamount != 0 || vamount != 0) { - wMenuMove(parent, parent->frame_x + hamount, - parent->frame_y + vamount, True); + getScrollAmount(menu, &hamount, &vamount); - /* keep scrolling */ - menu->timer = WMAddTimerHandler(MENU_SCROLL_DELAY, - scrollMenuCallback, menu); + if (hamount != 0 || vamount != 0) { + wMenuMove(parent, parent->frame_x + hamount, + parent->frame_y + vamount, True); + + /* keep scrolling */ + menu->timer = WMAddTimerHandler(MENU_SCROLL_DELAY, + scrollMenuCallback, menu); } else { - /* don't need to scroll anymore */ - menu->timer = NULL; + /* don't need to scroll anymore */ + menu->timer = NULL; } } @@ -1766,18 +1745,18 @@ isPointNearBoder(WMenu *menu, int x, int y) int scrXe = menu->menu->screen_ptr->scr_width-1; int scrYe = menu->menu->screen_ptr->scr_height-1; int flag = 0; - + if (x >= menuX1 && x <= menuX2 && (y < MENU_SCROLL_BORDER - || y > scrYe-MENU_SCROLL_BORDER)) - flag = 1; + || y > scrYe-MENU_SCROLL_BORDER)) + flag = 1; else if (y >= menuY1 && y <= menuY2 && (x < MENU_SCROLL_BORDER - || x > scrXe-MENU_SCROLL_BORDER)) - flag = 1; - + || x > scrXe-MENU_SCROLL_BORDER)) + flag = 1; + return flag; } - + typedef struct _delay { WWindow *wwin; WMenu *menu; @@ -1806,7 +1785,7 @@ wMenuScroll(WMenu *menu, XEvent *event) int old_frame_x = omenu->frame_x; int old_frame_y = omenu->frame_y; XEvent ev; - + if (omenu->jump_back) WMDeleteTimerWithClientData(omenu->jump_back); @@ -1822,70 +1801,70 @@ wMenuScroll(WMenu *menu, XEvent *event) raiseMenus(menu, False); if (!menu->timer) - scrollMenuCallback(menu); + scrollMenuCallback(menu); while(!done) { int x, y, on_border, on_x_edge, on_y_edge, on_title; WMNextEvent(dpy, &ev); switch (ev.type) { - case EnterNotify: - WMHandleEvent(&ev); - case MotionNotify: - x = (ev.type==MotionNotify) ? ev.xmotion.x_root : ev.xcrossing.x_root; - y = (ev.type==MotionNotify) ? ev.xmotion.y_root : ev.xcrossing.y_root; + case EnterNotify: + WMHandleEvent(&ev); + case MotionNotify: + x = (ev.type==MotionNotify) ? ev.xmotion.x_root : ev.xcrossing.x_root; + y = (ev.type==MotionNotify) ? ev.xmotion.y_root : ev.xcrossing.y_root; - /* on_border is != 0 if the pointer is between the menu - * and the screen border and is close enough to the border */ - on_border = isPointNearBoder(menu, x, y); + /* on_border is != 0 if the pointer is between the menu + * and the screen border and is close enough to the border */ + on_border = isPointNearBoder(menu, x, y); - smenu = wMenuUnderPointer(scr); + smenu = wMenuUnderPointer(scr); - if ((smenu==NULL && !on_border) || (smenu && parentMenu(smenu)!=omenu)) { - done = 1; - break; - } - - on_x_edge = x <= 1 || x >= scr->scr_width - 2; - on_y_edge = y <= 1 || y >= scr->scr_height - 2; - on_border = on_x_edge || on_y_edge; - - if (!on_border && !jump_back) { - done = 1; - break; - } - - if (menu->timer && (smenu!=menu || (!on_y_edge && !on_x_edge))) { - WMDeleteTimerHandler(menu->timer); - menu->timer = NULL; - } - - if (smenu != NULL) - menu = smenu; - - if (!menu->timer) - scrollMenuCallback(menu); - break; - case ButtonPress: - /* True if we push on title, or drag the omenu to other position */ - on_title = ev.xbutton.x_root >= omenu->frame_x && - ev.xbutton.x_root <= omenu->frame_x + MENUW(omenu) && - ev.xbutton.y_root >= omenu->frame_y && - ev.xbutton.y_root <= omenu->frame_y + omenu->frame->top_width; - WMHandleEvent(&ev); - smenu = wMenuUnderPointer(scr); - if (smenu == NULL || (smenu && smenu->flags.buttoned && smenu != omenu)) - done = 1; - else if (smenu==omenu && on_title) { - jump_back = 0; - done = 1; - } - break; - case KeyPress: + if ((smenu==NULL && !on_border) || (smenu && parentMenu(smenu)!=omenu)) { done = 1; - default: - WMHandleEvent(&ev); break; + } + + on_x_edge = x <= 1 || x >= scr->scr_width - 2; + on_y_edge = y <= 1 || y >= scr->scr_height - 2; + on_border = on_x_edge || on_y_edge; + + if (!on_border && !jump_back) { + done = 1; + break; + } + + if (menu->timer && (smenu!=menu || (!on_y_edge && !on_x_edge))) { + WMDeleteTimerHandler(menu->timer); + menu->timer = NULL; + } + + if (smenu != NULL) + menu = smenu; + + if (!menu->timer) + scrollMenuCallback(menu); + break; + case ButtonPress: + /* True if we push on title, or drag the omenu to other position */ + on_title = ev.xbutton.x_root >= omenu->frame_x && + ev.xbutton.x_root <= omenu->frame_x + MENUW(omenu) && + ev.xbutton.y_root >= omenu->frame_y && + ev.xbutton.y_root <= omenu->frame_y + omenu->frame->top_width; + WMHandleEvent(&ev); + smenu = wMenuUnderPointer(scr); + if (smenu == NULL || (smenu && smenu->flags.buttoned && smenu != omenu)) + done = 1; + else if (smenu==omenu && on_title) { + jump_back = 0; + done = 1; + } + break; + case KeyPress: + done = 1; + default: + WMHandleEvent(&ev); + break; } } @@ -1911,7 +1890,7 @@ wMenuScroll(WMenu *menu, XEvent *event) -static void +static void menuExpose(WObjDescriptor *desc, XEvent *event) { wMenuPaint(desc->parent); @@ -1939,17 +1918,17 @@ delaySelection(void *data) selectEntry(menu, entry_no); } if (d->delayed_select) - *(d->delayed_select) = 0; + *(d->delayed_select) = 0; } -static void +static void menuMouseDown(WObjDescriptor *desc, XEvent *event) { XButtonEvent *bev = &event->xbutton; WMenu *menu = desc->parent; WMenu *smenu; - WScreen *scr=menu->frame->screen_ptr; + WScreen *scr=menu->frame->screen_ptr; WMenuEntry *entry=NULL; XEvent ev; int close_on_exit=0; @@ -1972,61 +1951,61 @@ menuMouseDown(WObjDescriptor *desc, XEvent *event) d_data.delayed_select = &delayed_select; d_data.menu = menu; d_data.magic = WMAddTimerHandler(wPreferences.dblclick_time, - delaySelection, &d_data); + delaySelection, &d_data); } - + if (menu->flags.inside_handler) { - return; + return; } menu->flags.inside_handler = 1; wRaiseFrame(menu->frame->core); - + close_on_exit = (bev->send_event || menu->flags.brother); smenu = findMenu(scr, &x, &y); if (!smenu) { - x = -1; - y = -1; + x = -1; + y = -1; } else { - menu = smenu; + menu = smenu; } if (menu->flags.editing) { - goto byebye; + goto byebye; } entry_no = getEntryAt(menu, x, y); if (entry_no>=0) { - entry = menu->entries[entry_no]; + entry = menu->entries[entry_no]; - if (!close_on_exit && (bev->state & ControlMask) && smenu - && entry->flags.editable) { - editEntry(smenu, entry); - goto byebye; - } else if (bev->state & ControlMask) { - goto byebye; - } + if (!close_on_exit && (bev->state & ControlMask) && smenu + && entry->flags.editable) { + editEntry(smenu, entry); + goto byebye; + } else if (bev->state & ControlMask) { + goto byebye; + } - if (entry->flags.enabled && entry->cascade>=0 && menu->cascades) { - WMenu *submenu = menu->cascades[entry->cascade]; - /* map cascade */ + if (entry->flags.enabled && entry->cascade>=0 && menu->cascades) { + WMenu *submenu = menu->cascades[entry->cascade]; + /* map cascade */ if (submenu->flags.mapped && !submenu->flags.buttoned && menu->selected_entry!=entry_no) { - wMenuUnmap(submenu); + wMenuUnmap(submenu); } if (!submenu->flags.mapped && !delayed_select) { - selectEntry(menu, entry_no); - } else if (!submenu->flags.buttoned) { - selectEntry(menu, -1); - } - + selectEntry(menu, entry_no); + } else if (!submenu->flags.buttoned) { + selectEntry(menu, -1); + } + } else if (!delayed_select) { selectEntry(menu, entry_no); } if (!wPreferences.wrap_menus && !wPreferences.scrollable_menus) { - if (!menu->timer) - dragScrollMenuCallback(menu); + if (!menu->timer) + dragScrollMenuCallback(menu); } } @@ -2035,17 +2014,17 @@ menuMouseDown(WObjDescriptor *desc, XEvent *event) wWorkspaceLowerEdge(scr); } #endif - + prevx = bev->x_root; prevy = bev->y_root; while (!done) { - int x, y; + int x, y; - XAllowEvents(dpy, AsyncPointer|SyncPointer, CurrentTime); + XAllowEvents(dpy, AsyncPointer|SyncPointer, CurrentTime); - WMMaskEvent(dpy, ExposureMask|ButtonMotionMask|ButtonReleaseMask - |ButtonPressMask, &ev); - switch (ev.type) { + WMMaskEvent(dpy, ExposureMask|ButtonMotionMask|ButtonReleaseMask + |ButtonPressMask, &ev); + switch (ev.type) { case MotionNotify: smenu = findMenu(scr, &x, &y); @@ -2057,8 +2036,8 @@ menuMouseDown(WObjDescriptor *desc, XEvent *event) d_data.magic = NULL; } if (menu==NULL - || (menu->selected_entry>=0 - && menu->entries[menu->selected_entry]->cascade>=0)) { + || (menu->selected_entry>=0 + && menu->entries[menu->selected_entry]->cascade>=0)) { prevx = ev.xmotion.x_root; prevy = ev.xmotion.y_root; @@ -2070,8 +2049,8 @@ menuMouseDown(WObjDescriptor *desc, XEvent *event) prevy = ev.xmotion.y_root; break; } else if (menu && menu!=smenu - && (menu->selected_entry<0 - || menu->entries[menu->selected_entry]->cascade<0)) { + && (menu->selected_entry<0 + || menu->entries[menu->selected_entry]->cascade<0)) { selectEntry(menu, -1); if (!delayed_select && d_data.magic) { @@ -2082,7 +2061,7 @@ menuMouseDown(WObjDescriptor *desc, XEvent *event) /* hysteresis for item selection */ - /* check if the motion was to the side, indicating that + /* check if the motion was to the side, indicating that * the user may want to cross to a submenu */ if (!delayed_select && menu) { int dx; @@ -2092,11 +2071,11 @@ menuMouseDown(WObjDescriptor *desc, XEvent *event) moved_to_submenu = False; if (dx > 0 /* if moved enough to the side */ - /* maybe a open submenu */ - && menu->selected_entry>=0 - /* moving to the right direction */ - && (wPreferences.align_menus - || ev.xmotion.y_root >= prevy)) { + /* maybe a open submenu */ + && menu->selected_entry>=0 + /* moving to the right direction */ + && (wPreferences.align_menus + || ev.xmotion.y_root >= prevy)) { int index; index = menu->entries[menu->selected_entry]->cascade; @@ -2124,9 +2103,9 @@ menuMouseDown(WObjDescriptor *desc, XEvent *event) } d_data.delayed_select = NULL; d_data.menu = menu; - d_data.magic = WMAddTimerHandler(MENU_SELECT_DELAY, - delaySelection, - &d_data); + d_data.magic = WMAddTimerHandler(MENU_SELECT_DELAY, + delaySelection, + &d_data); prevx = ev.xmotion.x_root; prevy = ev.xmotion.y_root; break; @@ -2157,10 +2136,10 @@ menuMouseDown(WObjDescriptor *desc, XEvent *event) if (entry_no>=0) { entry = menu->entries[entry_no]; if (entry->flags.enabled && entry->cascade>=0 && - menu->cascades) { + menu->cascades) { WMenu *submenu = menu->cascades[entry->cascade]; if (submenu->flags.mapped && !submenu->flags.buttoned - && menu->selected_entry!=entry_no) { + && menu->selected_entry!=entry_no) { wMenuUnmap(submenu); } } @@ -2177,7 +2156,7 @@ menuMouseDown(WObjDescriptor *desc, XEvent *event) done=1; break; - case Expose: + case Expose: WMHandleEvent(&ev); #ifdef VIRTUAL_DESKTOP /* since expose will raise edge up.. I need another ugly hack here */ @@ -2186,61 +2165,61 @@ menuMouseDown(WObjDescriptor *desc, XEvent *event) } #endif break; - } + } } if (menu && menu->timer) { - WMDeleteTimerHandler(menu->timer); - menu->timer = NULL; + WMDeleteTimerHandler(menu->timer); + menu->timer = NULL; } if (d_data.magic!=NULL) WMDeleteTimerHandler(d_data.magic); - + if (menu && menu->selected_entry>=0) { - entry = menu->entries[menu->selected_entry]; - if (entry->callback!=NULL && entry->flags.enabled - && entry->cascade < 0) { - /* blink and erase menu selection */ + entry = menu->entries[menu->selected_entry]; + if (entry->callback!=NULL && entry->flags.enabled + && entry->cascade < 0) { + /* blink and erase menu selection */ #if (MENU_BLINK_DELAY > 0) - int sel = menu->selected_entry; - int i; + int sel = menu->selected_entry; + int i; - for (i=0; iflags.buttoned && - (!menu->flags.app_menu||menu->parent!=NULL)) { - closeCascade(menu); - } else { - selectEntry(menu, -1); - } - (*entry->callback)(menu, entry); + /* unmap the menu, it's parents and call the callback */ + if (!menu->flags.buttoned && + (!menu->flags.app_menu||menu->parent!=NULL)) { + closeCascade(menu); + } else { + selectEntry(menu, -1); + } + (*entry->callback)(menu, entry); - /* If the user double clicks an entry, the entry will - * be executed twice, which is not good for things like - * the root menu. So, ignore any clicks that were generated - * while the entry was being executed */ - while (XCheckTypedWindowEvent(dpy, menu->menu->window, - ButtonPress, &ev)); - } else if (entry->callback!=NULL && entry->cascade<0) { - selectEntry(menu, -1); - } else { - if (entry->cascade>=0 && menu->cascades - && menu->cascades[entry->cascade]->flags.brother) { - selectEntry(menu, -1); - } - } + /* If the user double clicks an entry, the entry will + * be executed twice, which is not good for things like + * the root menu. So, ignore any clicks that were generated + * while the entry was being executed */ + while (XCheckTypedWindowEvent(dpy, menu->menu->window, + ButtonPress, &ev)); + } else if (entry->callback!=NULL && entry->cascade<0) { + selectEntry(menu, -1); + } else { + if (entry->cascade>=0 && menu->cascades + && menu->cascades[entry->cascade]->flags.brother) { + selectEntry(menu, -1); + } + } } if (((WMenu*)desc->parent)->flags.brother || close_on_exit || !smenu) - closeCascade(desc->parent); + closeCascade(desc->parent); /* close the cascade windows that should not remain opened */ closeBrotherCascadesOf(desc->parent); @@ -2248,7 +2227,7 @@ menuMouseDown(WObjDescriptor *desc, XEvent *event) if (!wPreferences.wrap_menus) wMenuMove(parentMenu(desc->parent), old_frame_x, old_frame_y, True); -byebye: +byebye: ((WMenu*)desc->parent)->flags.inside_handler = 0; #ifdef VIRTUAL_DESKTOP if (wPreferences.vedge_thickness) { @@ -2263,38 +2242,38 @@ wMenuMove(WMenu *menu, int x, int y, int submenus) { WMenu *submenu; int i; - + if (!menu) return; - + menu->frame_x = x; menu->frame_y = y; XMoveWindow(dpy, menu->frame->core->window, x, y); - + if (submenus>0 && menu->selected_entry>=0) { - i = menu->entries[menu->selected_entry]->cascade; - - if (i>=0 && menu->cascades) { - submenu = menu->cascades[i]; - if (submenu->flags.mapped && !submenu->flags.buttoned) { - if (wPreferences.align_menus) { - wMenuMove(submenu, x + MENUW(menu), y, submenus); - } else { - wMenuMove(submenu, x+ MENUW(menu), - y + submenu->entry_height*menu->selected_entry, - submenus); - } - } - } + i = menu->entries[menu->selected_entry]->cascade; + + if (i>=0 && menu->cascades) { + submenu = menu->cascades[i]; + if (submenu->flags.mapped && !submenu->flags.buttoned) { + if (wPreferences.align_menus) { + wMenuMove(submenu, x + MENUW(menu), y, submenus); + } else { + wMenuMove(submenu, x+ MENUW(menu), + y + submenu->entry_height*menu->selected_entry, + submenus); + } + } + } } if (submenus<0 && menu->parent!=NULL && menu->parent->flags.mapped && - !menu->parent->flags.buttoned) { - if (wPreferences.align_menus) { - wMenuMove(menu->parent, x - MENUW(menu->parent), y, submenus); - } else { - wMenuMove(menu->parent, x - MENUW(menu->parent), menu->frame_y - - menu->parent->entry_height*menu->parent->selected_entry, - submenus); - } + !menu->parent->flags.buttoned) { + if (wPreferences.align_menus) { + wMenuMove(menu->parent, x - MENUW(menu->parent), y, submenus); + } else { + wMenuMove(menu->parent, x - MENUW(menu->parent), menu->frame_y + - menu->parent->entry_height*menu->parent->selected_entry, + submenus); + } } } @@ -2305,44 +2284,44 @@ changeMenuLevels(WMenu *menu, int lower) int i; if (!lower) { - ChangeStackingLevel(menu->frame->core, (!menu->parent ? WMMainMenuLevel - : WMSubmenuLevel)); - wRaiseFrame(menu->frame->core); - menu->flags.lowered = 0; + ChangeStackingLevel(menu->frame->core, (!menu->parent ? WMMainMenuLevel + : WMSubmenuLevel)); + wRaiseFrame(menu->frame->core); + menu->flags.lowered = 0; } else { - ChangeStackingLevel(menu->frame->core, WMNormalLevel); - wLowerFrame(menu->frame->core); - menu->flags.lowered = 1; + ChangeStackingLevel(menu->frame->core, WMNormalLevel); + wLowerFrame(menu->frame->core); + menu->flags.lowered = 1; } for (i=0; icascade_no; i++) { - if (menu->cascades[i] - && !menu->cascades[i]->flags.buttoned - && menu->cascades[i]->flags.lowered!=lower) { - changeMenuLevels(menu->cascades[i], lower); - } + if (menu->cascades[i] + && !menu->cascades[i]->flags.buttoned + && menu->cascades[i]->flags.lowered!=lower) { + changeMenuLevels(menu->cascades[i], lower); + } } } -static void +static void menuTitleDoubleClick(WCoreWindow *sender, void *data, XEvent *event) { WMenu *menu = data; int lower; - + if (event->xbutton.state & MOD_MASK) { - if (menu->flags.lowered) { - lower = 0; - } else { - lower = 1; - } - changeMenuLevels(menu, lower); + if (menu->flags.lowered) { + lower = 0; + } else { + lower = 1; + } + changeMenuLevels(menu, lower); } } -static void +static void menuTitleMouseDown(WCoreWindow *sender, void *data, XEvent *event) { WMenu *menu = data; @@ -2355,94 +2334,94 @@ menuTitleMouseDown(WCoreWindow *sender, void *data, XEvent *event) /* can't touch the menu copy */ if (menu->flags.brother) - return; + return; if (event->xbutton.button != Button1 && event->xbutton.button != Button2) - return; + return; if (event->xbutton.state & MOD_MASK) { - wLowerFrame(menu->frame->core); - lower = 1; + wLowerFrame(menu->frame->core); + lower = 1; } else { - wRaiseFrame(menu->frame->core); - lower = 0; + wRaiseFrame(menu->frame->core); + lower = 0; } tmp = menu; /* lower/raise all submenus */ while (1) { - if (tmp->selected_entry>=0 && tmp->cascades - && tmp->entries[tmp->selected_entry]->cascade>=0) { - tmp = tmp->cascades[tmp->entries[tmp->selected_entry]->cascade]; - if (!tmp || !tmp->flags.mapped) - break; - if (lower) - wLowerFrame(tmp->frame->core); - else - wRaiseFrame(tmp->frame->core); - } else { - break; - } + if (tmp->selected_entry>=0 && tmp->cascades + && tmp->entries[tmp->selected_entry]->cascade>=0) { + tmp = tmp->cascades[tmp->entries[tmp->selected_entry]->cascade]; + if (!tmp || !tmp->flags.mapped) + break; + if (lower) + wLowerFrame(tmp->frame->core); + else + wRaiseFrame(tmp->frame->core); + } else { + break; + } } - /* tear off the menu if it's a root menu or a cascade + /* tear off the menu if it's a root menu or a cascade application menu */ - if (!menu->flags.buttoned && !menu->flags.brother - && (!menu->flags.app_menu||menu->parent!=NULL)) { - menu->flags.buttoned=1; - wFrameWindowShowButton(menu->frame, WFF_RIGHT_BUTTON); - if (menu->parent) { - /* turn off selected menu entry in parent menu */ - selectEntry(menu->parent, -1); + if (!menu->flags.buttoned && !menu->flags.brother + && (!menu->flags.app_menu||menu->parent!=NULL)) { + menu->flags.buttoned=1; + wFrameWindowShowButton(menu->frame, WFF_RIGHT_BUTTON); + if (menu->parent) { + /* turn off selected menu entry in parent menu */ + selectEntry(menu->parent, -1); - /* make parent map the copy in place of the original */ - for (i=0; iparent->cascade_no; i++) { - if (menu->parent->cascades[i] == menu) { - menu->parent->cascades[i] = menu->brother; - break; - } - } - } + /* make parent map the copy in place of the original */ + for (i=0; iparent->cascade_no; i++) { + if (menu->parent->cascades[i] == menu) { + menu->parent->cascades[i] = menu->brother; + break; + } + } + } } started = False; while(1) { - WMMaskEvent(dpy, ButtonMotionMask|ButtonReleaseMask|ButtonPressMask - |ExposureMask, &ev); - switch (ev.type) { - case MotionNotify: - if (started) { - x += ev.xmotion.x_root - dx; - y += ev.xmotion.y_root - dy; - dx = ev.xmotion.x_root; - dy = ev.xmotion.y_root; - wMenuMove(menu, x, y, True); - } else { - if (abs(ev.xmotion.x_root - dx) > MOVE_THRESHOLD - || abs(ev.xmotion.y_root - dy) > MOVE_THRESHOLD) { - started = True; - XGrabPointer(dpy, menu->frame->titlebar->window, False, - ButtonMotionMask|ButtonReleaseMask - |ButtonPressMask, - GrabModeAsync, GrabModeAsync, None, - wCursor[WCUR_MOVE], CurrentTime); - } - } - break; + WMMaskEvent(dpy, ButtonMotionMask|ButtonReleaseMask|ButtonPressMask + |ExposureMask, &ev); + switch (ev.type) { + case MotionNotify: + if (started) { + x += ev.xmotion.x_root - dx; + y += ev.xmotion.y_root - dy; + dx = ev.xmotion.x_root; + dy = ev.xmotion.y_root; + wMenuMove(menu, x, y, True); + } else { + if (abs(ev.xmotion.x_root - dx) > MOVE_THRESHOLD + || abs(ev.xmotion.y_root - dy) > MOVE_THRESHOLD) { + started = True; + XGrabPointer(dpy, menu->frame->titlebar->window, False, + ButtonMotionMask|ButtonReleaseMask + |ButtonPressMask, + GrabModeAsync, GrabModeAsync, None, + wCursor[WCUR_MOVE], CurrentTime); + } + } + break; - case ButtonPress: - break; + case ButtonPress: + break; - case ButtonRelease: - if (ev.xbutton.button != event->xbutton.button) - break; - XUngrabPointer(dpy, CurrentTime); - return; + case ButtonRelease: + if (ev.xbutton.button != event->xbutton.button) + break; + XUngrabPointer(dpy, CurrentTime); + return; - default: - WMHandleEvent(&ev); - break; - } + default: + WMHandleEvent(&ev); + break; + } } } @@ -2450,30 +2429,30 @@ menuTitleMouseDown(WCoreWindow *sender, void *data, XEvent *event) *---------------------------------------------------------------------- * menuCloseClick-- * Handles mouse click on the close button of menus. The menu is - * closed when the button is clicked. - * + * closed when the button is clicked. + * * Side effects: * The closed menu is reinserted at it's parent menus * cascade list. - *---------------------------------------------------------------------- + *---------------------------------------------------------------------- */ -static void +static void menuCloseClick(WCoreWindow *sender, void *data, XEvent *event) { WMenu *menu = (WMenu*)data; WMenu *parent = menu->parent; int i; - + if (parent) { - for (i=0; icascade_no; i++) { - /* find the entry that points to the copy */ - if (parent->cascades[i] == menu->brother) { - /* make it point to the original */ - parent->cascades[i] = menu; - menu->parent = parent; - break; - } - } + for (i=0; icascade_no; i++) { + /* find the entry that points to the copy */ + if (parent->cascades[i] == menu->brother) { + /* make it point to the original */ + parent->cascades[i] = menu; + menu->parent = parent; + break; + } + } } wMenuUnmap(menu); } @@ -2489,7 +2468,7 @@ saveMenuInfo(WMPropList *dict, WMenu *menu, WMPropList *key) value = WMCreatePLString(buffer); list = WMCreatePLArray(value, NULL); if (menu->flags.lowered) - WMAddToPLArray(list, WMCreatePLString("lowered")); + WMAddToPLArray(list, WMCreatePLString("lowered")); WMPutInPLDictionary(dict, key, list); WMReleasePropList(value); WMReleasePropList(list); @@ -2506,23 +2485,23 @@ wMenuSaveState(WScreen *scr) #ifndef LITE if (scr->switch_menu && scr->switch_menu->flags.buttoned) { - key = WMCreatePLString("SwitchMenu"); - saveMenuInfo(menus, scr->switch_menu, key); - WMReleasePropList(key); + key = WMCreatePLString("SwitchMenu"); + saveMenuInfo(menus, scr->switch_menu, key); + WMReleasePropList(key); save_menus = 1; } if (saveMenuRecurs(menus, scr, scr->root_menu)) - save_menus = 1; + save_menus = 1; #endif /* !LITE */ if (scr->workspace_menu && scr->workspace_menu->flags.buttoned) { key = WMCreatePLString("WorkspaceMenu"); - saveMenuInfo(menus, scr->workspace_menu, key); + saveMenuInfo(menus, scr->workspace_menu, key); WMReleasePropList(key); save_menus = 1; } - + if (save_menus) { key = WMCreatePLString("Menus"); WMPutInPLDictionary(scr->session_state, key, menus); @@ -2541,16 +2520,16 @@ getMenuPath(WMenu *menu, char *buffer, int bufSize) int len = 0; if (!menu->flags.titled || !menu->frame->title[0]) - return False; + return False; len = strlen(menu->frame->title); if (len >= bufSize) - return False; + return False; if (menu->parent) { - ok = getMenuPath(menu->parent, buffer, bufSize - len - 1); - if (!ok) - return False; + ok = getMenuPath(menu->parent, buffer, bufSize - len - 1); + if (!ok) + return False; } strcat(buffer, "\\"); @@ -2568,28 +2547,28 @@ saveMenuRecurs(WMPropList *menus, WScreen *scr, WMenu *menu) char buffer[512]; Bool ok = True; - + if (menu->flags.brother) - menu = menu->brother; + menu = menu->brother; if (menu->flags.buttoned && menu != scr->switch_menu) { - buffer[0] = '\0'; - ok = getMenuPath(menu, buffer, 510); + buffer[0] = '\0'; + ok = getMenuPath(menu, buffer, 510); - if (ok) { - key = WMCreatePLString(buffer); - saveMenuInfo(menus, menu, key); - WMReleasePropList(key); - save_menus = 1; - } + if (ok) { + key = WMCreatePLString(buffer); + saveMenuInfo(menus, menu, key); + WMReleasePropList(key); + save_menus = 1; + } } if (ok) { - for (i = 0; i < menu->cascade_no; i++) { - if (saveMenuRecurs(menus, scr, menu->cascades[i])) - save_menus = 1; - } + for (i = 0; i < menu->cascade_no; i++) { + if (saveMenuRecurs(menus, scr, menu->cascades[i])) + save_menus = 1; + } } return save_menus; } @@ -2603,27 +2582,27 @@ static Bool getMenuInfo(WMPropList *info, int *x, int *y, Bool *lowered) { WMPropList *pos; - + *lowered = False; - + if (WMIsPLArray(info)) { - WMPropList *flags; - pos = WMGetFromPLArray(info, 0); - flags = WMGetFromPLArray(info, 1); - if (flags != NULL && WMIsPLString(flags) && WMGetFromPLString(flags) != NULL - && strcmp(WMGetFromPLString(flags), "lowered") == 0) { - *lowered = True; - } + WMPropList *flags; + pos = WMGetFromPLArray(info, 0); + flags = WMGetFromPLArray(info, 1); + if (flags != NULL && WMIsPLString(flags) && WMGetFromPLString(flags) != NULL + && strcmp(WMGetFromPLString(flags), "lowered") == 0) { + *lowered = True; + } } else { - pos = info; + pos = info; } if (pos != NULL && WMIsPLString(pos)) { - if (sscanf(WMGetFromPLString(pos), "%i,%i", x, y)!=2) - COMPLAIN("Position"); + if (sscanf(WMGetFromPLString(pos), "%i,%i", x, y)!=2) + COMPLAIN("Position"); } else { - COMPLAIN("(position, flags...)"); - return False; + COMPLAIN("(position, flags...)"); + return False; } return True; @@ -2638,10 +2617,10 @@ restoreMenu(WScreen *scr, WMPropList *menu, int which) WMenu *pmenu = NULL; if (!menu) - return False; - + return False; + if (!getMenuInfo(menu, &x, &y, &lowered)) - return False; + return False; #ifndef LITE @@ -2654,11 +2633,11 @@ restoreMenu(WScreen *scr, WMPropList *menu, int which) if (pmenu) { int width = MENUW(pmenu); int height = MENUH(pmenu); - - if (lowered) { - changeMenuLevels(pmenu, True); - } - + + if (lowered) { + changeMenuLevels(pmenu, True); + } + x = (x < -width) ? 0 : x; x = (x > scr->scr_width) ? scr->scr_width - width : x; y = (y < 0) ? 0 : y; @@ -2682,7 +2661,7 @@ restoreMenuRecurs(WScreen *scr, WMPropList *menus, WMenu *menu, char *path) Bool lowered; if (strlen(path) + strlen(menu->frame->title) > 510) - return False; + return False; snprintf(buffer, sizeof(buffer), "%s\\%s", path, menu->frame->title); key = WMCreatePLString(buffer); @@ -2691,40 +2670,40 @@ restoreMenuRecurs(WScreen *scr, WMPropList *menus, WMenu *menu, char *path) if (entry && getMenuInfo(entry, &x, &y, &lowered)) { - if (!menu->flags.mapped) { - int width = MENUW(menu); - int height = MENUH(menu); + if (!menu->flags.mapped) { + int width = MENUW(menu); + int height = MENUH(menu); - wMenuMapAt(menu, x, y, False); + wMenuMapAt(menu, x, y, False); - if (menu->parent) { - /* make parent map the copy in place of the original */ - for (i=0; iparent->cascade_no; i++) { - if (menu->parent->cascades[i] == menu) { - menu->parent->cascades[i] = menu->brother; - break; - } - } - } - if (lowered) { - changeMenuLevels(menu, True); - } - x = (x < -width) ? 0 : x; - x = (x > scr->scr_width) ? scr->scr_width - width : x; - y = (y < 0) ? 0 : y; - y = (y > scr->scr_height) ? scr->scr_height - height : y; - wMenuMove(menu, x, y, True); - menu->flags.buttoned = 1; - wFrameWindowShowButton(menu->frame, WFF_RIGHT_BUTTON); - res = True; - } + if (menu->parent) { + /* make parent map the copy in place of the original */ + for (i=0; iparent->cascade_no; i++) { + if (menu->parent->cascades[i] == menu) { + menu->parent->cascades[i] = menu->brother; + break; + } + } + } + if (lowered) { + changeMenuLevels(menu, True); + } + x = (x < -width) ? 0 : x; + x = (x > scr->scr_width) ? scr->scr_width - width : x; + y = (y < 0) ? 0 : y; + y = (y > scr->scr_height) ? scr->scr_height - height : y; + wMenuMove(menu, x, y, True); + menu->flags.buttoned = 1; + wFrameWindowShowButton(menu->frame, WFF_RIGHT_BUTTON); + res = True; + } } - + WMReleasePropList(key); for (i=0; icascade_no; i++) { - if (restoreMenuRecurs(scr, menus, menu->cascades[i], buffer) != False) - res = True; + if (restoreMenuRecurs(scr, menus, menu->cascades[i], buffer) != False) + res = True; } return res; @@ -2788,7 +2767,7 @@ OpenWorkspaceMenu(WScreen *scr, int x, int y) } } else { wRaiseFrame(menu->frame->core); - wMenuMapCopyAt(menu, x, y); + wMenuMapCopyAt(menu, x, y); } } else { wMenuMapAt(menu, x, y, False); diff --git a/src/moveres.c b/src/moveres.c index 2c780cf1..983a8c86 100644 --- a/src/moveres.c +++ b/src/moveres.c @@ -278,7 +278,7 @@ showGeometry(WWindow *wwin, int x1, int y1, int x2, int y2, int direction) wwin->normal_hints->height_inc); fw = WMWidthOfString(scr->info_text_font, num, strlen(num)); - /* XSetForeground(dpy, gc, scr->window_title_pixel[WS_UNFOCUSED]); */ + /* XSetForeground(dpy, gc, WMColorPixel(scr->window_title_color[WS_UNFOCUSED])); */ color = WMBlackColor(scr->wmscreen); saveGC = scr->wmscreen->drawStringGC; @@ -286,7 +286,7 @@ showGeometry(WWindow *wwin, int x1, int y1, int x2, int y2, int direction) /* Display the height. */ - /* ugly hack */ + /* // ugly hack */ color->color.pixel = scr->line_pixel; scr->wmscreen->drawStringGC = gc; WMDrawString(scr->wmscreen, root, color, scr->info_text_font, @@ -344,10 +344,10 @@ showGeometry(WWindow *wwin, int x1, int y1, int x2, int y2, int direction) XDrawSegments(dpy, root, gc, segment, 4); - /* XSetForeground(dpy, gc, scr->window_title_pixel[WS_UNFOCUSED]); */ + /* XSetForeground(dpy, gc, WMColorPixel(scr->window_title_color[WS_UNFOCUSED])); */ /* Display the width. */ - /* ugly hack */ + /* // ugly hack */ color->color.pixel = scr->line_pixel; scr->wmscreen->drawStringGC = gc; WMDrawString(scr->wmscreen, root, color, scr->info_text_font, diff --git a/src/screen.c b/src/screen.c index ca3735cd..a4b9ec35 100644 --- a/src/screen.c +++ b/src/screen.c @@ -266,7 +266,6 @@ allocGCs(WScreen *scr) { XGCValues gcv; XColor color; - unsigned long mtextcolor; int gcm; scr->stipple_bitmap = @@ -291,7 +290,7 @@ allocGCs(WScreen *scr) gcv.dash_offset = 0; gcv.dashes = 4; gcv.graphics_exposures = False; - + gcm = GCFunction | GCGraphicsExposures; gcm |= GCForeground | GCBackground; gcm |= GCLineWidth | GCLineStyle; @@ -300,30 +299,11 @@ allocGCs(WScreen *scr) scr->icon_select_gc = XCreateGC(dpy, scr->w_win, gcm, &gcv); - gcm = GCForeground|GCGraphicsExposures; - - scr->menu_title_pixel[0] = scr->white_pixel; - gcv.foreground = scr->white_pixel; - gcv.graphics_exposures = False; - scr->menu_title_gc = XCreateGC(dpy, scr->w_win, gcm, &gcv); + scr->menu_title_color[0] = WMRetainColor(scr->white); - scr->mtext_pixel = scr->black_pixel; - mtextcolor = gcv.foreground = scr->black_pixel; - scr->menu_entry_gc = XCreateGC(dpy, scr->w_win, gcm, &gcv); - - /* selected menu entry GC */ - gcm = GCForeground|GCBackground|GCGraphicsExposures; - gcv.foreground = scr->white_pixel; - gcv.background = scr->white_pixel; - gcv.graphics_exposures = False; - scr->select_menu_gc = XCreateGC(dpy, scr->w_win, gcm, &gcv); - - /* disabled menu entry GC */ - scr->dtext_pixel = scr->black_pixel; - gcm = GCForeground|GCBackground|GCStipple|GCGraphicsExposures; - gcv.stipple = scr->stipple_bitmap; - gcv.graphics_exposures = False; - scr->disabled_menu_entry_gc = XCreateGC(dpy, scr->w_win, gcm, &gcv); + /* don't retain scr->black here because we may alter its alpha */ + scr->mtext_color = WMCreateRGBColor(scr->wmscreen, 0, 0, 0, True); + scr->dtext_color = WMCreateRGBColor(scr->wmscreen, 0, 0, 0, True); /* frame GC */ wGetColor(scr, DEF_FRAME_COLOR, &color); @@ -359,11 +339,11 @@ allocGCs(WScreen *scr) gcv.cap_style = CapRound; gcv.graphics_exposures = False; gcm = GCForeground|GCFunction|GCSubwindowMode|GCLineWidth|GCCapStyle - |GCGraphicsExposures; + |GCGraphicsExposures; scr->line_gc = XCreateGC(dpy, scr->root_win, gcm, &gcv); scr->line_pixel = gcv.foreground; - + /* copy GC */ gcv.foreground = scr->white_pixel; gcv.background = scr->black_pixel; @@ -371,10 +351,6 @@ allocGCs(WScreen *scr) scr->copy_gc = XCreateGC(dpy, scr->w_win, GCForeground|GCBackground |GCGraphicsExposures, &gcv); - /* window title text GC */ - gcv.graphics_exposures = False; - scr->window_title_gc = XCreateGC(dpy, scr->w_win,GCGraphicsExposures,&gcv); - /* clip title GC */ scr->clip_title_gc = XCreateGC(dpy, scr->w_win, GCGraphicsExposures, &gcv); @@ -764,26 +740,24 @@ wScreenInit(int screen_number) scr->w_depth = scr->rcontext->depth; scr->w_colormap = scr->rcontext->cmap; - scr->black_pixel = scr->rcontext->black; - scr->white_pixel = scr->rcontext->white; - /* create screen descriptor for WINGs */ scr->wmscreen = WMCreateScreenWithRContext(dpy, screen_number, scr->rcontext); if (!scr->wmscreen) { - wfatal(_("could not do initialization of WINGs widget set")); - + wfatal(_("could not initialize WINGs widget set")); return NULL; } - color = WMGrayColor(scr->wmscreen); - scr->light_pixel = WMColorPixel(color); - WMReleaseColor(color); + scr->black = WMBlackColor(scr->wmscreen); + scr->white = WMWhiteColor(scr->wmscreen); + scr->gray = WMGrayColor(scr->wmscreen); + scr->darkGray = WMDarkGrayColor(scr->wmscreen); - color = WMDarkGrayColor(scr->wmscreen); - scr->dark_pixel = WMColorPixel(color); - WMReleaseColor(color); + scr->black_pixel = WMColorPixel(scr->black); /*scr->rcontext->black;*/ + scr->white_pixel = WMColorPixel(scr->white); /*scr->rcontext->white;*/ + scr->light_pixel = WMColorPixel(scr->gray); + scr->dark_pixel = WMColorPixel(scr->darkGray); { XColor xcol; @@ -795,7 +769,6 @@ wScreenInit(int screen_number) /* create GCs with default values */ allocGCs(scr); - /* for our window manager info notice board. Need to * create before reading the defaults, because it will be used there. */ diff --git a/src/screen.h b/src/screen.h index a787659d..dfd01c07 100644 --- a/src/screen.h +++ b/src/screen.h @@ -140,6 +140,10 @@ typedef struct _WScreen { WArea totalUsableArea; /* same as above, but including * the dock and other stuff */ + WMColor *black; + WMColor *white; + WMColor *gray; + WMColor *darkGray; WMPixel black_pixel; WMPixel white_pixel; @@ -159,14 +163,14 @@ typedef struct _WScreen { * hint boxes */ WMFont *workspace_name_font; - WMPixel select_pixel; - WMPixel select_text_pixel; + WMColor *select_color; + WMColor *select_text_color; /* foreground colors */ - WMPixel window_title_pixel[3]; /* window titlebar text (foc, unfoc, pfoc)*/ - WMPixel menu_title_pixel[3]; /* menu titlebar text */ + WMColor *window_title_color[3]; /* window titlebar text (foc, unfoc, pfoc)*/ + WMColor *menu_title_color[3]; /* menu titlebar text */ WMColor *clip_title_color[2]; /* clip title text */ - WMPixel mtext_pixel; /* menu item text */ - WMPixel dtext_pixel; /* disabled menu item text */ + WMColor *mtext_color; /* menu item text */ + WMColor *dtext_color; /* disabled menu item text */ WMPixel line_pixel; WMPixel frame_border_pixel; /* frame border */ @@ -180,19 +184,14 @@ typedef struct _WScreen { struct WTexSolid *menu_item_auxtexture; /* additional texture to draw menu * cascade arrows */ struct WTexSolid *icon_title_texture;/* icon titles */ - + struct WTexSolid *widget_texture; struct WTexSolid *icon_back_texture; /* icon back color for shadowing */ - GC window_title_gc; /* window title text GC */ - GC menu_title_gc; /* menu titles */ - + WMColor *icon_title_color; /* icon title color */ GC clip_title_gc; /* clip title */ - GC menu_entry_gc; /* menu entries */ - GC select_menu_gc; /* selected menu entries */ - GC disabled_menu_entry_gc; /* disabled menu entries */ GC info_text_gc; /* for size/position display */ GC icon_select_gc; diff --git a/src/text.c b/src/text.c index 03d45fda..80bf821d 100644 --- a/src/text.c +++ b/src/text.c @@ -322,72 +322,65 @@ wTextDestroy( WTextInput *wtext ) * Global: dpy - the display * \********************************************************************/ static void -textRefresh( WTextInput *wtext ) +textRefresh(WTextInput *wtext) { - int x1,x2,y1,y2; - char *ptr = wtext->text.txt; - WMColor *black, *white; - - /* x1,y1 is the upper left corner of the text box */ - x1 = wtext->xOffset; - y1 = wtext->yOffset; - /* x2,y2 is the lower right corner of the text box */ - x2 = wtext->core->width - wtext->xOffset; - y2 = wtext->core->height - wtext->yOffset; + WScreen *scr = wtext->core->screen_ptr; + char *ptr = wtext->text.txt; + int x1,x2,y1,y2; - /* Fill in the text field. Use the invGC to draw the rectangle, - * becuase then it will be the background color */ - XFillRectangle( dpy, wtext->core->window, wtext->invGC, - x1, y1, x2-x1, y2-y1 ); + /* x1,y1 is the upper left corner of the text box */ + x1 = wtext->xOffset; + y1 = wtext->yOffset; + /* x2,y2 is the lower right corner of the text box */ + x2 = wtext->core->width - wtext->xOffset; + y2 = wtext->core->height - wtext->yOffset; - black = WMBlackColor(wtext->core->screen_ptr->wmscreen); - white = WMWhiteColor(wtext->core->screen_ptr->wmscreen); - /* Draw the text normally */ - WMDrawImageString(wtext->core->screen_ptr->wmscreen, wtext->core->window, - black, white, wtext->font, x1, y1, ptr, wtext->text.length); + /* Fill in the text field. Use the invGC to draw the rectangle, + * becuase then it will be the background color */ + XFillRectangle(dpy, wtext->core->window, wtext->invGC, + x1, y1, x2-x1, y2-y1); - /* Draw the selected text */ - if( wtext->text.startPos != wtext->text.endPos ) - { - int sp,ep; - /* we need sp < ep */ - if( wtext->text.startPos > wtext->text.endPos ) - { - sp = wtext->text.endPos; - ep = wtext->text.startPos; - } - else - { - sp = wtext->text.startPos; - ep = wtext->text.endPos; - } - - /* x1,y1 is now the upper-left of the selected area */ - x1 += WMWidthOfString( wtext->font, ptr, sp ); - /* and x2,y2 is the lower-right of the selected area */ - ptr += sp * sizeof(char); - x2 = x1 + WMWidthOfString( wtext->font, ptr, (ep - sp) ); - /* Fill in the area where the selected text will go: * - * use the regGC to draw the rectangle, becuase then it * - * will be the color of the non-selected text */ - XFillRectangle( dpy, wtext->core->window, wtext->regGC, - x1, y1, x2-x1, y2-y1 ); - - /* Draw the selected text... use invGC so it will be the - * opposite color as the filled rectangle */ - WMDrawImageString(wtext->core->screen_ptr->wmscreen, wtext->core->window, - white, black, wtext->font, x1, y1, ptr, (ep - sp)); + /* Draw the text normally */ + WMDrawImageString(scr->wmscreen, wtext->core->window, + scr->black, scr->white, wtext->font, x1, y1, ptr, + wtext->text.length); + + /* Draw the selected text */ + if (wtext->text.startPos != wtext->text.endPos) { + int sp,ep; + /* we need sp < ep */ + if (wtext->text.startPos > wtext->text.endPos) { + sp = wtext->text.endPos; + ep = wtext->text.startPos; + } else { + sp = wtext->text.startPos; + ep = wtext->text.endPos; + } + + /* x1,y1 is now the upper-left of the selected area */ + x1 += WMWidthOfString(wtext->font, ptr, sp); + /* and x2,y2 is the lower-right of the selected area */ + ptr += sp * sizeof(char); + x2 = x1 + WMWidthOfString(wtext->font, ptr, (ep - sp)); + /* Fill in the area where the selected text will go: * + * use the regGC to draw the rectangle, becuase then it * + * will be the color of the non-selected text */ + XFillRectangle(dpy, wtext->core->window, wtext->regGC, + x1, y1, x2-x1, y2-y1); + + /* Draw the selected text... use invGC so it will be the + * opposite color as the filled rectangle */ + WMDrawImageString(scr->wmscreen, wtext->core->window, + scr->white, scr->black, wtext->font, x1, y1, ptr, + (ep - sp)); } - WMReleaseColor(white); - WMReleaseColor(black); - - /* And draw a quick little line for the cursor position */ - x1 = WMWidthOfString( wtext->font, wtext->text.txt, wtext->text.endPos ) - + wtext->xOffset; - XDrawLine( dpy, wtext->core->window, wtext->regGC, x1, 2, x1, - wtext->core->height - 3 ); - } + /* And draw a quick little line for the cursor position */ + x1 = WMWidthOfString(wtext->font, wtext->text.txt, wtext->text.endPos) + + wtext->xOffset; + XDrawLine(dpy, wtext->core->window, wtext->regGC, x1, 2, x1, + wtext->core->height - 3); +} /********************************************************************\ diff --git a/src/window.c b/src/window.c index e6aef476..52119537 100644 --- a/src/window.c +++ b/src/window.c @@ -1154,7 +1154,7 @@ wManageWindow(WScreen *scr, Window window) &wPreferences.window_title_clearance, foo, scr->window_title_texture, scr->resizebar_texture, - scr->window_title_pixel, + scr->window_title_color, &scr->title_font); wwin->frame->flags.is_client_window_frame = 1; @@ -1513,7 +1513,7 @@ wManageInternalWindow(WScreen *scr, Window window, Window owner, &wPreferences.window_title_clearance, foo, scr->window_title_texture, scr->resizebar_texture, - scr->window_title_pixel, + scr->window_title_color, &scr->title_font); XSaveContext(dpy, window, wWinContext, (XPointer)&wwin->client_descriptor); diff --git a/src/workspace.c b/src/workspace.c index bc938539..f760827c 100644 --- a/src/workspace.c +++ b/src/workspace.c @@ -275,7 +275,6 @@ showWorkspaceName(WScreen *scr, int workspace) WorkspaceNameData *data; RXImage *ximg; Pixmap text, mask; - WMColor *color; int w, h; int px, py; char *name = scr->workspaces[workspace]->name; @@ -342,40 +341,34 @@ showWorkspaceName(WScreen *scr, int workspace) text = XCreatePixmap(dpy, scr->w_win, w+4, h+4, scr->w_depth); mask = XCreatePixmap(dpy, scr->w_win, w+4, h+4, 1); - XSetForeground(dpy, scr->draw_gc, scr->black_pixel); - XFillRectangle(dpy, text, scr->draw_gc, 0, 0, w+4, h+4); + /*XSetForeground(dpy, scr->mono_gc, 0); + XFillRectangle(dpy, mask, scr->mono_gc, 0, 0, w+4, h+4);*/ - XSetForeground(dpy, scr->mono_gc, 0); - XFillRectangle(dpy, mask, scr->mono_gc, 0, 0, w+4, h+4); - - XSetForeground(dpy, scr->mono_gc, 1); - - color = WMWhiteColor(scr->wmscreen); + XFillRectangle(dpy, text, WMColorGC(scr->black), 0, 0, w+4, h+4); for (x = 0; x <= 4; x++) { - GC saveGC = scr->wmscreen->drawStringGC; - WMPixel pixel = color->color.pixel; - - /* ugly hack */ - color->color.pixel = 1; - scr->wmscreen->drawStringGC = scr->mono_gc; - for (y = 0; y <= 4; y++) { - WMDrawString(scr->wmscreen, mask, color, - scr->workspace_name_font, x, y, name, len); + WMDrawString(scr->wmscreen, text, scr->white, + scr->workspace_name_font, x, y, name, len); } - - scr->wmscreen->drawStringGC = saveGC; - color->color.pixel = pixel; } - WMDrawString(scr->wmscreen, text, color, scr->workspace_name_font, - 2, 2, scr->workspaces[workspace]->name, - strlen(scr->workspaces[workspace]->name)); - WMReleaseColor(color); + XSetForeground(dpy, scr->mono_gc, 1); + XSetBackground(dpy, scr->mono_gc, 0); + + XCopyPlane(dpy, text, mask, scr->mono_gc, 0, 0, w+4, h+4, 0, 0, 1<<(scr->w_depth-1)); + + /*XSetForeground(dpy, scr->mono_gc, 1);*/ + XSetBackground(dpy, scr->mono_gc, 1); + + XFillRectangle(dpy, text, WMColorGC(scr->black), 0, 0, w+4, h+4); + + WMDrawString(scr->wmscreen, text, scr->white, scr->workspace_name_font, + 2, 2, name, len); + #ifdef SHAPE XShapeCombineMask(dpy, scr->workspace_name, ShapeBounding, 0, 0, mask, - ShapeSet); + ShapeSet); #endif XSetWindowBackgroundPixmap(dpy, scr->workspace_name, text); XClearWindow(dpy, scr->workspace_name);