Submitted By: Oliver Brakmann Date: 2004-10-27 Initial Package version: Windowmaker 0.91.0 Origin: http://vlaadworld.net/ Description: Adds translucency to Windowmaker menus. To set the level of translucency, start WPrefs.app and select 'Apperance Preferences -> Options -> Transparency' diff -Naur WindowMaker-0.91.0-orig/WPrefs.app/Appearance.c WindowMaker-0.91.0/WPrefs.app/Appearance.c --- WindowMaker-0.91.0-orig/WPrefs.app/Appearance.c 2004-10-26 18:34:28.000000000 +0200 +++ WindowMaker-0.91.0/WPrefs.app/Appearance.c 2004-10-26 18:40:51.000000000 +0200 @@ -82,6 +82,11 @@ WMFrame *taliF; WMButton *taliB[3]; + WMFrame *tranceF; + WMButton *tranceB; + WMSlider *tranceSl; + WMLabel *tranceL; + /* root bg */ WMFrame *bgF; @@ -1714,6 +1719,23 @@ } } +static void +tranceCallback(WMWidget *self, void *data) +{ + _Panel *panel = (_Panel*)data; + char buffer[5]; + int i; + + i = WMGetSliderValue(panel->tranceSl); + i = 10*(10-i); + + if (i == 0) { + WMSetLabelText(panel->tranceL, "OFF"); + } else { + sprintf(buffer, "%i%%", i); + WMSetLabelText(panel->tranceL, buffer); + } +} static void createPanel(Panel *p) @@ -2005,7 +2027,7 @@ panel->taliF = WMCreateFrame(panel->optF); - WMResizeWidget(panel->taliF, 110, 80); + WMResizeWidget(panel->taliF, 105, 80); WMMoveWidget(panel->taliF, 15, 100); WMSetFrameTitle(panel->taliF, _("Title Alignment")); @@ -2023,7 +2045,7 @@ WMSetButtonText(panel->taliB[i], _("Right")); break; } - WMResizeWidget(panel->taliB[i], 90, 18); + WMResizeWidget(panel->taliB[i], 85, 18); WMMoveWidget(panel->taliB[i], 10, 15 + 20*i); } WMGroupButtons(panel->taliB[0], panel->taliB[1]); @@ -2031,6 +2053,36 @@ WMMapSubwidgets(panel->taliF); + panel->tranceF = WMCreateFrame(panel->optF); + WMResizeWidget(panel->tranceF, 105,80); + WMMoveWidget(panel->tranceF, 125, 100); + WMSetFrameTitle(panel->tranceF,_("Transparency")); + + WMSetBalloonTextForView(_(" i love windowmaker\n" + " get some fresh sand-wich-es\n" + " heh\n" + " transparency\n" + " moo\n" + " :P\n"), WMWidgetView(panel->tranceF)); + + panel->tranceB = WMCreateSwitchButton(panel->tranceF); + WMSetButtonText(panel->tranceB, _("Menu")); + WMResizeWidget(panel->tranceB,85,18); + WMMoveWidget(panel->tranceB, 10, 15); + + panel->tranceSl = WMCreateSlider(panel->tranceF); + WMResizeWidget(panel->tranceSl, 70, 18); + WMMoveWidget(panel->tranceSl, 17, 15 + 20*2); + WMSetSliderMinValue(panel->tranceSl, 0); + WMSetSliderMaxValue(panel->tranceSl, 10); + WMSetSliderAction(panel->tranceSl, tranceCallback, panel); + + panel->tranceL = WMCreateLabel(panel->tranceF); + WMResizeWidget(panel->tranceL, 27, 18); + WMMoveWidget(panel->tranceL, 40, 35); + + WMMapSubwidgets(panel->tranceF); + WMMapSubwidgets(panel->optF); /**/ @@ -2089,6 +2141,7 @@ static void showData(_Panel *panel) { + int x; int i; char *str; @@ -2134,6 +2187,13 @@ WMSetButtonSelected(panel->mstyB[panel->menuStyle], True); WMSetButtonSelected(panel->taliB[panel->titleAlignment], True); + + + WMSetButtonSelected(panel->tranceB, GetBoolForKey("MenuTrance")); + + x = GetIntegerForKey("TranceAmount"); + WMSetSliderValue(panel->tranceSl, x); + tranceCallback(NULL, panel); } @@ -2185,6 +2245,9 @@ SetStringForKey("center", "TitleJustify"); break; } + + SetBoolForKey(WMGetButtonSelected(panel->tranceB), "MenuTrance"); + SetIntegerForKey(WMGetSliderValue(panel->tranceSl), "TranceAmount"); } diff -Naur WindowMaker-0.91.0-orig/src/WindowMaker.h WindowMaker-0.91.0/src/WindowMaker.h --- WindowMaker-0.91.0-orig/src/WindowMaker.h 2004-10-26 18:34:28.000000000 +0200 +++ WindowMaker-0.91.0/src/WindowMaker.h 2004-10-26 18:40:51.000000000 +0200 @@ -339,6 +339,8 @@ char opaque_move; /* update window position during */ /* move */ + char menu_trance; /* whether menu should be translucent */ + int trance_amount; /* percentage of translucency */ char wrap_menus; /* wrap menus at edge of screen */ char scrollable_menus; /* let them be scrolled */ char align_menus; /* align menu with their parents */ diff -Naur WindowMaker-0.91.0-orig/src/defaults.c WindowMaker-0.91.0/src/defaults.c --- WindowMaker-0.91.0-orig/src/defaults.c 2004-10-26 18:34:28.000000000 +0200 +++ WindowMaker-0.91.0/src/defaults.c 2004-10-26 18:40:51.000000000 +0200 @@ -502,6 +502,12 @@ {"UseSaveUnders", "NO", NULL, &wPreferences.use_saveunders, getBool, NULL }, + {"MenuTrance", "NO", NULL, + &wPreferences.menu_trance, getBool, NULL + }, + {"TranceAmount", "30", NULL, + &wPreferences.trance_amount, getInt, NULL + }, {"OpaqueMove", "NO", NULL, &wPreferences.opaque_move, getBool, NULL }, diff -Naur WindowMaker-0.91.0-orig/src/menu.c WindowMaker-0.91.0/src/menu.c --- WindowMaker-0.91.0-orig/src/menu.c 2004-10-26 18:34:28.000000000 +0200 +++ WindowMaker-0.91.0/src/menu.c 2004-10-26 18:40:51.000000000 +0200 @@ -93,6 +93,7 @@ static void menuCloseClick(WCoreWindow *sender, void *data, XEvent *event); static void updateTexture(WMenu *menu); +static void clipDimensionsToScreen(WMenu *menu, int *x, int *y, int *width, int *height); #ifndef LITE static int saveMenuRecurs(WMPropList *menus, WScreen *scr, WMenu *menu); @@ -498,6 +499,120 @@ static void +clipDimensionsToScreen(WMenu *menu, int *x, int *y, int *width, int *height) +{ + int sw, sh; + int fx, fy; + + sw = menu->menu->screen_ptr->scr_width; + sh = menu->menu->screen_ptr->scr_height; + + fx = *x + *width; + fy = *y + *height; + + /* CLAMP everything */ + if (*x > sw) { *x = sw; } else if (*x < 0) { *x = 0; } + if (*y > sh) { *y = sh; } else if (*y < 0) { *y = 0; } + if (fx > sw) { fx = sw; } else if (fx < 0) { fx = 0; } + if (fy > sh) { fy = sh; } else if (fy < 0) { fy = 0; } + + /* Make sure that height and width are positive */ + if (fx < *x) { *width = 0; } else { *width = fx - *x; } + if (fy < *y) { *height = 0; } else { *height = fy - *y; } +} + +static Pixmap +tranceMenu(WMenu *menu) +{ + WScreen *scr = menu->menu->screen_ptr; + + XImage *back, *front; + RImage *trance, *menu_image, *msnormal; + Pixmap original, result; + + int mw, mh, dx, dy; /* these correspond to the menu proper */ + int gx, gy, gw, gh; /* these correspond to what we grab from the root window */ + int tamount; + unsigned long red_mask, green_mask, blue_mask; + + unsigned int w, h, bar; + int foo; + Window baz; + + mw = gw = menu->menu->width; + mh = gh = menu->menu->height; + dx = gx = menu->frame_x + 1; + dy = gy = menu->frame_y + menu->frame->top_width + 1; + + tamount = wPreferences.trance_amount; + clipDimensionsToScreen(menu, &gx, &gy, &gw, &gh); + back = XGetImage(dpy, scr->root_win, gx, gy, gw, gh, + AllPlanes, ZPixmap); + if (!back) { + wwarning(_("error capturing \"back\" image"),RMessageForError(RErrorCode)); + return None; + } else { + red_mask = back->red_mask; + green_mask = back->green_mask; + blue_mask = back->blue_mask; + + trance = RCreateImageFromXImage(scr->rcontext, back, NULL); + XDestroyImage(back); + if (!trance) { + wwarning(_("error rendering \"trance\" image"), + RMessageForError(RErrorCode)); + return None; + } else { + /************************************************************/ + original = renderTexture(menu); + + XGetGeometry(dpy, original, &baz, &foo, + &foo, &w, &h, &bar, &bar); + front = XGetImage(dpy, original, 0, 0, w, h, + AllPlanes, ZPixmap); + if (!front) { + wwarning(_("error capturing \"front\" image"), + RMessageForError(RErrorCode)); + return None; + } + front->red_mask = red_mask; + front->green_mask = green_mask; + front->blue_mask = blue_mask; + + menu_image=RCreateImageFromXImage(scr->rcontext,front,NULL); + + XDestroyImage(front); + /************************************************************/ + if (original) { + FREE_PIXMAP(original); + } + if (!menu_image) { + wwarning(_("error rendering \"menu_image\""), + RMessageForError(RErrorCode)); + return None; + } else { + if (wPreferences.menu_style == MS_NORMAL) { + msnormal = RMakeTiledImage(menu_image, mw, mh); + RCombineAreaWithOpaqueness(trance, msnormal,0,0,gw,gh, + gx - dx,gy - dy,256*tamount/10); + RReleaseImage(menu_image); + RReleaseImage(msnormal); + } else { + RCombineAreaWithOpaqueness(trance, menu_image,0,0,gw,gh, + gx - dx,gy - dy,256*tamount/10); + RReleaseImage(menu_image); + } + RConvertImage(scr->rcontext, trance, + &result); + } + RReleaseImage(trance); + } + } + return result; +} + + +static void updateTexture(WMenu *menu) { WScreen *scr = menu->menu->screen_ptr; @@ -507,7 +622,11 @@ if (!menu->flags.brother) { FREE_PIXMAP(menu->menu_texture_data); - menu->menu_texture_data = renderTexture(menu); + if (wPreferences.menu_trance) { + menu->menu_texture_data = tranceMenu(menu); + } else { + menu->menu_texture_data = renderTexture(menu); + } XSetWindowBackgroundPixmap(dpy, menu->menu->window, menu->menu_texture_data); @@ -1163,6 +1282,11 @@ XMoveWindow(dpy, menu->frame->core->window, x, y); menu->frame_x = x; menu->frame_y = y; + /* FIXME: needs an if */ + if (wPreferences.menu_trance) { + updateTexture(menu); + } + /* */ XMapWindow(dpy, menu->frame->core->window); wRaiseFrame(menu->frame->core); menu->flags.mapped = 1; @@ -1187,6 +1311,11 @@ menu->frame_y = menu->frame->screen_ptr->app_menu_y; XMoveWindow(dpy, menu->frame->core->window, menu->frame_x, menu->frame_y); } + /* FIXME: needs an if */ + if (wPreferences.menu_trance) { + updateTexture(menu); + } + /* */ XMapWindow(dpy, menu->frame->core->window); wRaiseFrame(menu->frame->core); menu->flags.mapped = 1; --- WindowMaker-0.92.0/WPrefs.app/po/pl.po.orig 2006-02-02 23:44:37.461334000 +0100 +++ WindowMaker-0.92.0/WPrefs.app/po/pl.po 2006-02-02 23:48:23.431456750 +0100 @@ -16,72 +16,72 @@ "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: ../../WPrefs.app/Appearance.c:1154 +#: ../../WPrefs.app/Appearance.c:1159 msgid "Select File" msgstr "Wybór pliku" -#: ../../WPrefs.app/Appearance.c:1555 +#: ../../WPrefs.app/Appearance.c:1560 msgid "Focused Window" msgstr "Okno aktywne" -#: ../../WPrefs.app/Appearance.c:1560 +#: ../../WPrefs.app/Appearance.c:1565 msgid "Unfocused Window" msgstr "Okno nieaktywne" -#: ../../WPrefs.app/Appearance.c:1565 +#: ../../WPrefs.app/Appearance.c:1570 msgid "Owner of Focused Window" msgstr "Właściciel okna aktywnego" -#: ../../WPrefs.app/Appearance.c:1570 ../../WPrefs.app/Appearance.c:1893 +#: ../../WPrefs.app/Appearance.c:1575 ../../WPrefs.app/Appearance.c:1915 #: ../../WPrefs.app/FontSimple.c:108 msgid "Menu Title" msgstr "Tytuł menu" -#: ../../WPrefs.app/Appearance.c:1575 ../../WPrefs.app/Appearance.c:1578 +#: ../../WPrefs.app/Appearance.c:1580 ../../WPrefs.app/Appearance.c:1583 msgid "Normal Item" msgstr "Normalny" -#: ../../WPrefs.app/Appearance.c:1583 +#: ../../WPrefs.app/Appearance.c:1588 msgid "Disabled Item" msgstr "Wyłączony" -#: ../../WPrefs.app/Appearance.c:1595 +#: ../../WPrefs.app/Appearance.c:1600 msgid "Highlighted" msgstr "Podświetlony" -#: ../../WPrefs.app/Appearance.c:1786 +#: ../../WPrefs.app/Appearance.c:1808 msgid "Texture" msgstr "Tekstura" -#: ../../WPrefs.app/Appearance.c:1794 +#: ../../WPrefs.app/Appearance.c:1816 msgid "Titlebar of Focused Window" msgstr "Pasek tytułowy okna aktywnego" -#: ../../WPrefs.app/Appearance.c:1795 +#: ../../WPrefs.app/Appearance.c:1817 msgid "Titlebar of Unfocused Windows" msgstr "Pasek tytułowy okna nieaktywnego" -#: ../../WPrefs.app/Appearance.c:1796 +#: ../../WPrefs.app/Appearance.c:1818 msgid "Titlebar of Focused Window's Owner" msgstr "Pasek tytułowy właściciela aktywnego" -#: ../../WPrefs.app/Appearance.c:1797 +#: ../../WPrefs.app/Appearance.c:1819 msgid "Window Resizebar" msgstr "Pasek zmiany rozmiaru okna" -#: ../../WPrefs.app/Appearance.c:1798 +#: ../../WPrefs.app/Appearance.c:1820 msgid "Titlebar of Menus" msgstr "Pasek tytułowy menu" -#: ../../WPrefs.app/Appearance.c:1799 +#: ../../WPrefs.app/Appearance.c:1821 msgid "Menu Items" msgstr "Elementy menu" -#: ../../WPrefs.app/Appearance.c:1800 +#: ../../WPrefs.app/Appearance.c:1822 msgid "Icon Background" msgstr "Tło ikony" -#: ../../WPrefs.app/Appearance.c:1815 +#: ../../WPrefs.app/Appearance.c:1837 msgid "" "Double click in the texture you want to use\n" "for the selected item." @@ -89,87 +89,87 @@ "Proszę kliknąć na teksturze, która ma być\n" "używana dla wybranego elementu." -#: ../../WPrefs.app/Appearance.c:1829 +#: ../../WPrefs.app/Appearance.c:1851 msgid "New" msgstr "Nowa" -#: ../../WPrefs.app/Appearance.c:1833 +#: ../../WPrefs.app/Appearance.c:1855 msgid "Create a new texture." msgstr "Utworzenie nowej tekstury." -#: ../../WPrefs.app/Appearance.c:1841 +#: ../../WPrefs.app/Appearance.c:1863 msgid "Extract..." msgstr "Wyciągnij..." -#: ../../WPrefs.app/Appearance.c:1845 +#: ../../WPrefs.app/Appearance.c:1867 msgid "Extract texture(s) from a theme or a style file." msgstr "Wyciągnięcie tekstur(y) z pliku motywu lub stylu." -#: ../../WPrefs.app/Appearance.c:1855 +#: ../../WPrefs.app/Appearance.c:1877 msgid "Edit" msgstr "Edycja" -#: ../../WPrefs.app/Appearance.c:1858 +#: ../../WPrefs.app/Appearance.c:1880 msgid "Edit the highlighted texture." msgstr "Edycja podświetlonej tekstury." -#: ../../WPrefs.app/Appearance.c:1866 ../../WPrefs.app/TexturePanel.c:1318 +#: ../../WPrefs.app/Appearance.c:1888 ../../WPrefs.app/TexturePanel.c:1318 msgid "Delete" msgstr "Usuń" -#: ../../WPrefs.app/Appearance.c:1870 +#: ../../WPrefs.app/Appearance.c:1892 msgid "Delete the highlighted texture." msgstr "Usunięcie podświetlonej tekstury." -#: ../../WPrefs.app/Appearance.c:1883 +#: ../../WPrefs.app/Appearance.c:1905 msgid "Color" msgstr "Kolor" -#: ../../WPrefs.app/Appearance.c:1890 +#: ../../WPrefs.app/Appearance.c:1912 msgid "Focused Window Title" msgstr "Tytuł okna aktywnego" -#: ../../WPrefs.app/Appearance.c:1891 +#: ../../WPrefs.app/Appearance.c:1913 msgid "Unfocused Window Title" msgstr "Tytuł okna nieaktywnego" -#: ../../WPrefs.app/Appearance.c:1892 +#: ../../WPrefs.app/Appearance.c:1914 msgid "Owner of Focused Window Title" msgstr "Tytuł właściciela okna aktywnego" -#: ../../WPrefs.app/Appearance.c:1894 +#: ../../WPrefs.app/Appearance.c:1916 msgid "Menu Item Text" msgstr "Tekst elementu menu" -#: ../../WPrefs.app/Appearance.c:1895 +#: ../../WPrefs.app/Appearance.c:1917 msgid "Disabled Menu Item Text" msgstr "Tekst wyłączonego elementu menu" -#: ../../WPrefs.app/Appearance.c:1896 +#: ../../WPrefs.app/Appearance.c:1918 msgid "Menu Highlight Color" msgstr "Kolor podświetlenia menu" -#: ../../WPrefs.app/Appearance.c:1897 +#: ../../WPrefs.app/Appearance.c:1919 msgid "Highlighted Menu Text Color" msgstr "Kolor podświetlonego tekstu menu" -#: ../../WPrefs.app/Appearance.c:1936 +#: ../../WPrefs.app/Appearance.c:1958 msgid "Background" msgstr "Tło" -#: ../../WPrefs.app/Appearance.c:1948 ../../WPrefs.app/TexturePanel.c:1504 +#: ../../WPrefs.app/Appearance.c:1970 ../../WPrefs.app/TexturePanel.c:1504 msgid "Browse..." msgstr "Przeglądaj..." -#: ../../WPrefs.app/Appearance.c:1961 +#: ../../WPrefs.app/Appearance.c:1983 msgid "Options" msgstr "Opcje" -#: ../../WPrefs.app/Appearance.c:1968 +#: ../../WPrefs.app/Appearance.c:1990 msgid "Menu Style" msgstr "Styl menu" -#: ../../WPrefs.app/Appearance.c:1996 ../../WPrefs.app/Configurations.c:241 +#: ../../WPrefs.app/Appearance.c:2018 ../../WPrefs.app/Configurations.c:241 #: ../../WPrefs.app/Configurations.c:253 ../../WPrefs.app/Focus.c:288 #: ../../WPrefs.app/Focus.c:299 ../../WPrefs.app/MenuPreferences.c:134 #: ../../WPrefs.app/MenuPreferences.c:145 @@ -181,28 +181,52 @@ msgid "could not load icon file %s" msgstr "nie można załadować pliku ikony %s" -#: ../../WPrefs.app/Appearance.c:2010 +#: ../../WPrefs.app/Appearance.c:2032 msgid "Title Alignment" msgstr "Wyrównanie tytułu" -#: ../../WPrefs.app/Appearance.c:2017 +#: ../../WPrefs.app/Appearance.c:2039 msgid "Left" msgstr "Do lewej" -#: ../../WPrefs.app/Appearance.c:2020 ../../WPrefs.app/TexturePanel.c:1518 +#: ../../WPrefs.app/Appearance.c:2042 ../../WPrefs.app/TexturePanel.c:1518 #: ../../WPrefs.app/Workspace.c:270 msgid "Center" msgstr "Pośrodku" -#: ../../WPrefs.app/Appearance.c:2023 +#: ../../WPrefs.app/Appearance.c:2045 msgid "Right" msgstr "Do prawej" -#: ../../WPrefs.app/Appearance.c:2247 +#: ../../WPrefs.app/Appearance.c:2059 +msgid "Transparency" +msgstr "Przezroczystość" + +#: ../../WPrefs.app/Appearance.c:2061 +msgid "" +" i love windowmaker\n" +" get some fresh sand-wich-es\n" +" heh\n" +" transparency\n" +" moo\n" +" :P\n" +msgstr "" +" uwielbiam windowmakera\n" +" weź sobie świeże kanapki\n" +" heh\n" +" przezroczystość\n" +" muu\n" +" :P\n" + +#: ../../WPrefs.app/Appearance.c:2069 +msgid "Menu" +msgstr "Menu" + +#: ../../WPrefs.app/Appearance.c:2310 msgid "Appearance Preferences" msgstr "Ustawienia wyglądu" -#: ../../WPrefs.app/Appearance.c:2249 +#: ../../WPrefs.app/Appearance.c:2312 msgid "" "Background texture configuration for windows,\n" "menus and icons." @@ -210,19 +234,19 @@ "Ustawienia tekstury w tle dla okien, menu\n" "i ikon." -#: ../../WPrefs.app/Appearance.c:2294 +#: ../../WPrefs.app/Appearance.c:2357 msgid "Extract Texture" msgstr "Wyciągnij teksturę" -#: ../../WPrefs.app/Appearance.c:2314 +#: ../../WPrefs.app/Appearance.c:2377 msgid "Textures" msgstr "Tekstury" -#: ../../WPrefs.app/Appearance.c:2325 ../../WPrefs.app/WPrefs.c:301 +#: ../../WPrefs.app/Appearance.c:2388 ../../WPrefs.app/WPrefs.c:301 msgid "Close" msgstr "Zamknij" -#: ../../WPrefs.app/Appearance.c:2330 +#: ../../WPrefs.app/Appearance.c:2393 msgid "Extract" msgstr "Wyciągnij"